[llvm] 5692a0c - [DAG] visitFP_TO_SINT/FP_TO_UINT - use FoldConstantArithmetic to attempt to constant fold
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 17 04:50:32 PDT 2024
Author: Simon Pilgrim
Date: 2024-10-17T12:50:09+01:00
New Revision: 5692a0c6f846f9b1bacd445f4adedadf66c558ea
URL: https://github.com/llvm/llvm-project/commit/5692a0c6f846f9b1bacd445f4adedadf66c558ea
DIFF: https://github.com/llvm/llvm-project/commit/5692a0c6f846f9b1bacd445f4adedadf66c558ea.diff
LOG: [DAG] visitFP_TO_SINT/FP_TO_UINT - use FoldConstantArithmetic to attempt to constant fold
Don't rely on isConstantFPBuildVectorOrConstantFP followed by getNode() will constant fold - FoldConstantArithmetic will do all of this for us.
Cleanup for #112682
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 ff1ee01b8e43e4..8efa74a3ea7260 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -18128,8 +18128,8 @@ SDValue DAGCombiner::visitFP_TO_SINT(SDNode *N) {
return DAG.getUNDEF(VT);
// fold (fp_to_sint c1fp) -> c1
- if (DAG.isConstantFPBuildVectorOrConstantFP(N0))
- return DAG.getNode(ISD::FP_TO_SINT, DL, VT, N0);
+ if (SDValue C = DAG.FoldConstantArithmetic(ISD::FP_TO_SINT, DL, VT, {N0}))
+ return C;
return FoldIntToFPToInt(N, DL, DAG);
}
@@ -18144,8 +18144,8 @@ SDValue DAGCombiner::visitFP_TO_UINT(SDNode *N) {
return DAG.getUNDEF(VT);
// fold (fp_to_uint c1fp) -> c1
- if (DAG.isConstantFPBuildVectorOrConstantFP(N0))
- return DAG.getNode(ISD::FP_TO_UINT, DL, VT, N0);
+ if (SDValue C = DAG.FoldConstantArithmetic(ISD::FP_TO_UINT, DL, VT, {N0}))
+ return C;
return FoldIntToFPToInt(N, DL, DAG);
}
More information about the llvm-commits
mailing list