[llvm] 2887d77 - [DAGCombiner] Use FoldConstantArithmetic instead of dyn_cast in visitFP_ROUND.

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 24 20:42:43 PDT 2022


Author: wanglian
Date: 2022-08-25T11:29:05+08:00
New Revision: 2887d7786f012b1cde2a01b7b5d66c59a38fa8db

URL: https://github.com/llvm/llvm-project/commit/2887d7786f012b1cde2a01b7b5d66c59a38fa8db
DIFF: https://github.com/llvm/llvm-project/commit/2887d7786f012b1cde2a01b7b5d66c59a38fa8db.diff

LOG: [DAGCombiner] Use FoldConstantArithmetic instead of dyn_cast in visitFP_ROUND.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D132439

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index b1d6b3e11d69..1b699f86783d 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<ConstantFPSDNode>(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())


        


More information about the llvm-commits mailing list