diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2018-07-14 20:08:37 +0000 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2018-07-14 20:08:37 +0000 |
commit | f14426101e9b3d796ea2b3bb1a8021c52119201c (patch) | |
tree | b50c58aec6635886181ddaca0c2196525a90e86e /llvm/lib | |
parent | 53a014e61d0208a600b597b68f8baee2b497c61b (diff) | |
download | bcm5719-llvm-f14426101e9b3d796ea2b3bb1a8021c52119201c.tar.gz bcm5719-llvm-f14426101e9b3d796ea2b3bb1a8021c52119201c.zip |
[InstCombine] Fold x & (-1 >> y) s>= x 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: 337109
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 9bd5d53382e..b43520d9e92 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_SGE: + // x & (-1 >> y) s>= x -> x s<= (-1 >> y) + if (X != I.getOperand(1)) // X must be on RHS of comparison! + return nullptr; // Ignore the other case. + DstPred = ICmpInst::Predicate::ICMP_SLE; + 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! |