[DAGCombiner] Use FoldConstantArithmetic instead of dyn_cast in visitFP_ROUND.
authorwanglian <Lian.Wang@streamcomputing.com>
Wed, 24 Aug 2022 11:04:08 +0000 (19:04 +0800)
committerwanglian <Lian.Wang@streamcomputing.com>
Thu, 25 Aug 2022 03:29:05 +0000 (11:29 +0800)
Reviewed By: RKSimon

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

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index b1d6b3e..1b699f8 100644 (file)
@@ -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())