diff options
| author | Roman Lebedev <lebedev.ri@gmail.com> | 2018-07-14 20:08:26 +0000 |
|---|---|---|
| committer | Roman Lebedev <lebedev.ri@gmail.com> | 2018-07-14 20:08:26 +0000 |
| commit | 1e61e358a4ed048c3900c32dc84a2665c592cc4c (patch) | |
| tree | ba5ab990b610515db09fca9e5bc26b13cc0fa5fd /llvm/lib | |
| parent | f1a351cf3a36091428bd65e2ab6a7605c183cbbf (diff) | |
| download | bcm5719-llvm-1e61e358a4ed048c3900c32dc84a2665c592cc4c.tar.gz bcm5719-llvm-1e61e358a4ed048c3900c32dc84a2665c592cc4c.zip | |
[InstCombine] Fold x s<= x & (-1 >> y) to x s<= (-1 >> y)
https://bugs.llvm.org/show_bug.cgi?id=38123
https://rise4fun.com/Alive/I3O
This pattern is not commutative!
We must make sure not to fold the commuted version!
llvm-svn: 337107
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 4e42b9e3b44..9bd5d53382e 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -2918,6 +2918,12 @@ static Value *foldICmpWithLowBitMaskedVal(ICmpInst &I, return nullptr; // Ignore the other case. DstPred = ICmpInst::Predicate::ICMP_SGT; break; + case ICmpInst::Predicate::ICMP_SLE: + // x s<= x & (-1 >> y) -> x s<= (-1 >> y) + if (X != I.getOperand(0)) // X must be on LHS of comparison! + return nullptr; // Ignore the other case. + DstPred = ICmpInst::Predicate::ICMP_SLE; + break; // TODO: more folds are possible, https://bugs.llvm.org/show_bug.cgi?id=38123 default: return nullptr; |

