From: wanglian Date: Wed, 24 Aug 2022 11:04:08 +0000 (+0800) Subject: [DAGCombiner] Use FoldConstantArithmetic instead of dyn_cast in visitFP_ROUND. X-Git-Tag: upstream/17.0.6~35447 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2887d7786f012b1cde2a01b7b5d66c59a38fa8db;p=platform%2Fupstream%2Fllvm.git [DAGCombiner] Use FoldConstantArithmetic instead of dyn_cast in visitFP_ROUND. Reviewed By: RKSimon Differential Revision: https://reviews.llvm.org/D132439 --- diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index b1d6b3e..1b699f8 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -15858,12 +15858,12 @@ SDValue DAGCombiner::visitFP_TO_UINT(SDNode *N) { SDValue DAGCombiner::visitFP_ROUND(SDNode *N) { SDValue N0 = N->getOperand(0); SDValue N1 = N->getOperand(1); - ConstantFPSDNode *N0CFP = dyn_cast(N0); EVT VT = N->getValueType(0); // fold (fp_round c1fp) -> c1fp - if (N0CFP) - return DAG.getNode(ISD::FP_ROUND, SDLoc(N), VT, N0, N1); + if (SDValue C = + DAG.FoldConstantArithmetic(ISD::FP_ROUND, SDLoc(N), VT, {N0, N1})) + return C; // fold (fp_round (fp_extend x)) -> x if (N0.getOpcode() == ISD::FP_EXTEND && VT == N0.getOperand(0).getValueType())