[PATCH] D62663: [DAGCombine] Use FoldConstantArithmetic() to perform C2-(A+C1) -> (C2-C1)-A fold
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 30 07:14:18 PDT 2019
lebedev.ri created this revision.
lebedev.ri added reviewers: spatel, RKSimon, craig.topper.
lebedev.ri added a project: LLVM.
lebedev.ri added a parent revision: D62662: [DAGCombine] ((A-c1)+c2) -> (A+(c2-c1)) constant-fold.
No tests change, and i'm not sure how to test this, but it's better safe than sorry.
Repository:
rL LLVM
https://reviews.llvm.org/D62663
Files:
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -2875,7 +2875,9 @@
SDValue N11 = N1.getOperand(1);
if (isConstantOrConstantVector(N0, /* NoOpaques */ true) &&
isConstantOrConstantVector(N11, /* NoOpaques */ true)) {
- SDValue NewC = DAG.getNode(ISD::SUB, DL, VT, N0, N11);
+ SDValue NewC = DAG.FoldConstantArithmetic(ISD::SUB, DL, VT, N0.getNode(),
+ N11.getNode());
+ assert(NewC && "Constant folding failed");
return DAG.getNode(ISD::SUB, DL, VT, NewC, N1.getOperand(0));
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62663.202182.patch
Type: text/x-patch
Size: 735 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190530/f58f7b88/attachment.bin>
More information about the llvm-commits
mailing list