[llvm] 651b405 - [DAG] visitABS - use FoldConstantArithmetic to perform constant folding.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 21 10:23:42 PDT 2023
Author: Simon Pilgrim
Date: 2023-03-21T17:23:27Z
New Revision: 651b4054a019cb681bb879e31a01054a3105ea90
URL: https://github.com/llvm/llvm-project/commit/651b4054a019cb681bb879e31a01054a3105ea90
DIFF: https://github.com/llvm/llvm-project/commit/651b4054a019cb681bb879e31a01054a3105ea90.diff
LOG: [DAG] visitABS - use FoldConstantArithmetic to perform constant folding.
Avoid needing to perform extra isConstantIntBuildVectorOrConstantInt checks
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 5a331ceb96d64..4a34d4724ae8f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -10617,8 +10617,8 @@ SDValue DAGCombiner::visitABS(SDNode *N) {
EVT VT = N->getValueType(0);
// fold (abs c1) -> c2
- if (DAG.isConstantIntBuildVectorOrConstantInt(N0))
- return DAG.getNode(ISD::ABS, SDLoc(N), VT, N0);
+ if (SDValue C = DAG.FoldConstantArithmetic(ISD::ABS, SDLoc(N), VT, {N0}))
+ return C;
// fold (abs (abs x)) -> (abs x)
if (N0.getOpcode() == ISD::ABS)
return N0;
More information about the llvm-commits
mailing list