diff options
| author | Roman Lebedev <lebedev.ri@gmail.com> | 2019-10-23 11:58:50 +0300 |
|---|---|---|
| committer | Roman Lebedev <lebedev.ri@gmail.com> | 2019-10-23 12:01:40 +0300 |
| commit | 20bf0cf2f020ce3b344838b88d8a86e156c05443 (patch) | |
| tree | 0961afc31652a7e4a3c49cf5aa8e084be62c616b /llvm/lib | |
| parent | d052a578de58cbbb638cbe2dba05242d1ff443b9 (diff) | |
| download | bcm5719-llvm-20bf0cf2f020ce3b344838b88d8a86e156c05443.tar.gz bcm5719-llvm-20bf0cf2f020ce3b344838b88d8a86e156c05443.zip | |
[TargetLowering] optimizeSetCCToComparisonWithZero(): add extra sanity checks (PR43769)
We should do the fold only if both constants are plain,
non-opaque constants, at least that is the DAG.FoldConstantArithmetic()
requirement.
And if the constant we are comparing with is zero - we shouldn't be
trying to do this fold in the first place.
Fixes https://bugs.llvm.org/show_bug.cgi?id=43769
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index c0b846adc04..5af2663d29e 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -3052,6 +3052,10 @@ SDValue TargetLowering::optimizeSetCCToComparisonWithZero( assert((Cond == ISD::SETEQ || Cond == ISD::SETNE) && "Only for equality-comparisons."); + // The constant we are comparing with must be a non-zero, non-opaque constant. + if (N1C->isNullValue() || N1C->isOpaque()) + return SDValue(); + // LHS should not be used elsewhere, to avoid creating an extra node. if (!N0.hasOneUse()) return SDValue(); @@ -3072,9 +3076,9 @@ SDValue TargetLowering::optimizeSetCCToComparisonWithZero( break; } - // Second operand must be a constant. + // Second operand must be a non-opaque constant. ConstantSDNode *N01C = isConstOrConstSplat(N0.getOperand(1)); - if (!N01C) + if (!N01C || N01C->isOpaque()) return SDValue(); // And let's be even more specific for now, it must be a zero constant. |

