diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2016-10-13 12:49:31 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2016-10-13 12:49:31 +0000 |
commit | fa8fadc0e55e0929a9cfd7e70e7ae38e20e00f8b (patch) | |
tree | 9b6c2e06b5d631ec900fb87cf6ae237b76309478 /llvm/lib/CodeGen/SelectionDAG | |
parent | dac31db12f4c70bf0e9e26c7c75b13ce7eeae26c (diff) | |
download | bcm5719-llvm-fa8fadc0e55e0929a9cfd7e70e7ae38e20e00f8b.tar.gz bcm5719-llvm-fa8fadc0e55e0929a9cfd7e70e7ae38e20e00f8b.zip |
[DAGCombiner] Add vector support to C2-(A+C1) -> (C2-C1)-A folding
llvm-svn: 284117
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index d01606e07e8..da37c777f33 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -1939,7 +1939,6 @@ SDValue DAGCombiner::visitSUB(SDNode *N) { N1.getNode()); } - ConstantSDNode *N0C = getAsNonOpaqueConstant(N0); ConstantSDNode *N1C = getAsNonOpaqueConstant(N1); // fold (sub x, c) -> (add x, -c) @@ -1965,10 +1964,11 @@ SDValue DAGCombiner::visitSUB(SDNode *N) { return N0.getOperand(0); // fold C2-(A+C1) -> (C2-C1)-A - if (N1.getOpcode() == ISD::ADD && N0C) { - if (auto *N1C1 = dyn_cast<ConstantSDNode>(N1.getOperand(1).getNode())) { - SDValue NewC = - DAG.getConstant(N0C->getAPIntValue() - N1C1->getAPIntValue(), DL, VT); + if (N1.getOpcode() == ISD::ADD) { + SDValue N11 = N1.getOperand(1); + if (isConstantOrConstantVector(N0, /* NoOpaques */ true) && + isConstantOrConstantVector(N11, /* NoOpaques */ true)) { + SDValue NewC = DAG.getNode(ISD::SUB, DL, VT, N0, N11); return DAG.getNode(ISD::SUB, DL, VT, NewC, N1.getOperand(0)); } } |