summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2019-05-30 16:07:11 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2019-05-30 16:07:11 +0000
commit019d270e43967558de00ee4b6d624a2225a2fb77 (patch)
tree945cdfd751c4c967f28261d5b3b871334ec439c1 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parent0317e46a6322037cef6160dd7216dfe0499aaa4b (diff)
downloadbcm5719-llvm-019d270e43967558de00ee4b6d624a2225a2fb77.tar.gz
bcm5719-llvm-019d270e43967558de00ee4b6d624a2225a2fb77.zip
[DAGCombine] Revert of recommit of "binop-with-const hoisting" patches
I was looking into an endless combine loop the uncommitted follow-up patch was causing, and it appears even these patches can exibit such an endless loop. The root cause is that we try to hoist one binop (add/sub) with constant operand, and if we get two such binops both of which are eligible for this hoisting, we get stuck. Some cases may highlight missing constant-folds. Reverts r361871,r361872,r361873,r361874. llvm-svn: 362109
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp34
1 files changed, 0 insertions, 34 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 1518efd1256..d2045d764a0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -2303,13 +2303,6 @@ SDValue DAGCombiner::visitADDLike(SDNode *N) {
}
}
- // (x - y) + -1 -> add (xor y, -1), x
- if (N0.hasOneUse() && N0.getOpcode() == ISD::SUB &&
- isAllOnesOrAllOnesSplat(N1)) {
- SDValue Xor = DAG.getNode(ISD::XOR, DL, VT, N0.getOperand(1), N1);
- return DAG.getNode(ISD::ADD, DL, VT, Xor, N0.getOperand(0));
- }
-
if (SDValue Combined = visitADDLikeCommutative(N0, N1, N))
return Combined;
@@ -2930,33 +2923,6 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {
if (SDValue V = foldAddSubMasked1(false, N0, N1, DAG, SDLoc(N)))
return V;
- // (x - y) - 1 -> add (xor y, -1), x
- if (N0.hasOneUse() && N0.getOpcode() == ISD::SUB && isOneOrOneSplat(N1)) {
- SDValue Xor = DAG.getNode(ISD::XOR, DL, VT, N0.getOperand(1),
- DAG.getAllOnesConstant(DL, VT));
- return DAG.getNode(ISD::ADD, DL, VT, Xor, N0.getOperand(0));
- }
-
- // Hoist one-use addition by constant: (x + C) - y -> (x - y) + C
- if (N0.hasOneUse() && N0.getOpcode() == ISD::ADD &&
- isConstantOrConstantVector(N0.getOperand(1))) {
- SDValue Sub = DAG.getNode(ISD::SUB, DL, VT, N0.getOperand(0), N1);
- return DAG.getNode(ISD::ADD, DL, VT, Sub, N0.getOperand(1));
- }
- // y - (x + C) -> (y - x) - C
- if (N1.hasOneUse() && N1.getOpcode() == ISD::ADD &&
- isConstantOrConstantVector(N1.getOperand(1))) {
- SDValue Sub = DAG.getNode(ISD::SUB, DL, VT, N0, N1.getOperand(0));
- return DAG.getNode(ISD::SUB, DL, VT, Sub, N1.getOperand(1));
- }
- // (x - C) - y -> (x - y) - C
- // This is necessary because SUB(X,C) -> ADD(X,-C) doesn't work for vectors.
- if (N0.hasOneUse() && N0.getOpcode() == ISD::SUB &&
- isConstantOrConstantVector(N0.getOperand(1))) {
- SDValue Sub = DAG.getNode(ISD::SUB, DL, VT, N0.getOperand(0), N1);
- return DAG.getNode(ISD::SUB, DL, VT, Sub, N0.getOperand(1));
- }
-
// If the target's bool is represented as 0/-1, prefer to make this 'add 0/-1'
// rather than 'sub 0/1' (the sext should get folded).
// sub X, (zext i1 Y) --> add X, (sext i1 Y)
OpenPOWER on IntegriCloud