Skip to content

Commit 5692a0c

Browse files
committed
[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
1 parent 784c15a commit 5692a0c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18128,8 +18128,8 @@ SDValue DAGCombiner::visitFP_TO_SINT(SDNode *N) {
1812818128
return DAG.getUNDEF(VT);
1812918129

1813018130
// fold (fp_to_sint c1fp) -> c1
18131-
if (DAG.isConstantFPBuildVectorOrConstantFP(N0))
18132-
return DAG.getNode(ISD::FP_TO_SINT, DL, VT, N0);
18131+
if (SDValue C = DAG.FoldConstantArithmetic(ISD::FP_TO_SINT, DL, VT, {N0}))
18132+
return C;
1813318133

1813418134
return FoldIntToFPToInt(N, DL, DAG);
1813518135
}
@@ -18144,8 +18144,8 @@ SDValue DAGCombiner::visitFP_TO_UINT(SDNode *N) {
1814418144
return DAG.getUNDEF(VT);
1814518145

1814618146
// fold (fp_to_uint c1fp) -> c1
18147-
if (DAG.isConstantFPBuildVectorOrConstantFP(N0))
18148-
return DAG.getNode(ISD::FP_TO_UINT, DL, VT, N0);
18147+
if (SDValue C = DAG.FoldConstantArithmetic(ISD::FP_TO_UINT, DL, VT, {N0}))
18148+
return C;
1814918149

1815018150
return FoldIntToFPToInt(N, DL, DAG);
1815118151
}

0 commit comments

Comments
 (0)