diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2018-07-14 20:08:16 +0000 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2018-07-14 20:08:16 +0000 |
commit | 859e14aeaabb3c32c0cd09cee89a40e228dd07c1 (patch) | |
tree | 8bad5f38d22482ad85e8567206a9c7a19a1bcea7 /llvm/lib | |
parent | 62d050d2c47d9275e8d2ed827dbe89149fb440e3 (diff) | |
download | bcm5719-llvm-859e14aeaabb3c32c0cd09cee89a40e228dd07c1.tar.gz bcm5719-llvm-859e14aeaabb3c32c0cd09cee89a40e228dd07c1.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: 337105
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 2a8d83fde2c..4e42b9e3b44 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -2912,6 +2912,12 @@ static Value *foldICmpWithLowBitMaskedVal(ICmpInst &I, assert(X == I.getOperand(0) && "instsimplify took care of commut. variant"); DstPred = ICmpInst::Predicate::ICMP_ULE; break; + case ICmpInst::Predicate::ICMP_SGT: + // 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_SGT; + break; // TODO: more folds are possible, https://bugs.llvm.org/show_bug.cgi?id=38123 default: return nullptr; |