diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-08-23 21:01:35 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-08-23 21:01:35 +0000 |
commit | 6ef22da9ec85e89a958cfaf17074e1984d734bd5 (patch) | |
tree | 81e5355dea1e243b154769ca2d5123911b07ccfd /llvm/lib/Transforms | |
parent | bdf67c9a00d0cba65506f39edc4d06d4aac98cff (diff) | |
download | bcm5719-llvm-6ef22da9ec85e89a958cfaf17074e1984d734bd5.tar.gz bcm5719-llvm-6ef22da9ec85e89a958cfaf17074e1984d734bd5.zip |
[InstCombine] remove icmp shr folds that are already handled by InstSimplify
AFAICT, these already worked in all cases for scalar types, and I enhanced
the code to work for vector types in:
https://reviews.llvm.org/rL279543
llvm-svn: 279568
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index e6879d57eb9..4c1d9676d9e 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -1391,24 +1391,10 @@ Instruction *InstCombiner::foldICmpShrConstConst(ICmpInst &ICI, return Res; } - // If we are comparing against bits always shifted out, the - // comparison cannot succeed. - APInt Comp = CmpRHSV << ShAmtVal; - ConstantInt *ShiftedCmpRHS = Builder->getInt(Comp); - if (Shr->getOpcode() == Instruction::LShr) - Comp = Comp.lshr(ShAmtVal); - else - Comp = Comp.ashr(ShAmtVal); - - if (Comp != CmpRHSV) { // Comparing against a bit that we know is zero. - bool IsICMP_NE = ICI.getPredicate() == ICmpInst::ICMP_NE; - Constant *Cst = Builder->getInt1(IsICMP_NE); - return replaceInstUsesWith(ICI, Cst); - } - - // Otherwise, check to see if the bits shifted out are known to be zero. - // If so, we can compare against the unshifted value: + // Check if the bits shifted out are known to be zero. If so, we can compare + // against the unshifted value: // (X & 4) >> 1 == 2 --> (X & 4) == 4. + ConstantInt *ShiftedCmpRHS = Builder->getInt(CmpRHSV << ShAmtVal); if (Shr->hasOneUse() && Shr->isExact()) return new ICmpInst(ICI.getPredicate(), Shr->getOperand(0), ShiftedCmpRHS); |