Skip to content

Commit 651b405

Browse files
committed
[DAG] visitABS - use FoldConstantArithmetic to perform constant folding.
Avoid needing to perform extra isConstantIntBuildVectorOrConstantInt checks
1 parent 75fdf7f commit 651b405

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10617,8 +10617,8 @@ SDValue DAGCombiner::visitABS(SDNode *N) {
1061710617
EVT VT = N->getValueType(0);
1061810618

1061910619
// fold (abs c1) -> c2
10620-
if (DAG.isConstantIntBuildVectorOrConstantInt(N0))
10621-
return DAG.getNode(ISD::ABS, SDLoc(N), VT, N0);
10620+
if (SDValue C = DAG.FoldConstantArithmetic(ISD::ABS, SDLoc(N), VT, {N0}))
10621+
return C;
1062210622
// fold (abs (abs x)) -> (abs x)
1062310623
if (N0.getOpcode() == ISD::ABS)
1062410624
return N0;

0 commit comments

Comments
 (0)