diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-12-06 18:16:32 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-12-06 18:16:32 +0000 |
commit | c3717cd0d557ac2df0ce8a58487aacd8a502e69d (patch) | |
tree | 24611ffa84031f9ae4bd35c5536f012aa52fb62e /llvm/lib/CodeGen | |
parent | 2a23317e69ee33bc3ffcc22ec92464637ee9fc0a (diff) | |
download | bcm5719-llvm-c3717cd0d557ac2df0ce8a58487aacd8a502e69d.tar.gz bcm5719-llvm-c3717cd0d557ac2df0ce8a58487aacd8a502e69d.zip |
[DAGCombiner] don't hoist logic op if operands have other uses
The AVX512 diffs are neutral, but the bswap test shows a clear overreach in
hoistLogicOpWithSameOpcodeHands(). If we don't check for other uses, we can
increase the instruction count.
This could also fight with transforms trying to go in the opposite direction
and possibly blow up/infinite loop. This might be enough to solve the bug
noted here:
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20181203/608593.html
I did not add the hasOneUse() checks to all opcodes because I see a perf
regression for at least one opcode. We may decide that's irrelevant in the
face of potential compiler crashing, but I'll see if I can salvage that first.
llvm-svn: 348508
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index d9290c6dbe5..5a70deebd68 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -3715,8 +3715,8 @@ SDValue DAGCombiner::hoistLogicOpWithSameOpcodeHands(SDNode *N) { if (N0.getNumOperands() == 0) return SDValue(); - // FIXME: We need to check number of uses of the operands to not increase - // the instruction count. + // FIXME: We should check number of uses of the operands to not increase + // the instruction count for all transforms. EVT Op0VT = N0.getOperand(0).getValueType(); switch (HandOpcode) { @@ -3725,6 +3725,10 @@ SDValue DAGCombiner::hoistLogicOpWithSameOpcodeHands(SDNode *N) { case ISD::ZERO_EXTEND: case ISD::SIGN_EXTEND: case ISD::BSWAP: + // If both operands have other uses, this transform would create extra + // instructions without eliminating anything. + if (!N0.hasOneUse() && !N1.hasOneUse()) + return SDValue(); // We need matching integer source types. // Do not hoist logic op inside of a vector extend, since it may combine // into a vsetcc. |