[llvm] r279300 - [InstCombine] remove an icmp fold that is already handled by InstSimplify
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 19 12:03:07 PDT 2016
Author: spatel
Date: Fri Aug 19 14:03:07 2016
New Revision: 279300
URL: http://llvm.org/viewvc/llvm-project?rev=279300&view=rev
Log:
[InstCombine] remove an icmp fold that is already handled by InstSimplify
Specifically, this is done near the end of "SimplifyICmpInst" using
computeKnownBits() as the broader solution. There are even vector
tests (yay!) for this in test/Transforms/InstSimplify/compare.ll.
I considered putting an assert here instead of just deleting, but
then we could assert every possible fold in InstSimplify in
InstCombine, so...less is more?
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=279300&r1=279299&r2=279300&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Fri Aug 19 14:03:07 2016
@@ -2009,16 +2009,6 @@ Instruction *InstCombiner::foldICmpShlCo
ICmpInst::Predicate Pred = Cmp.getPredicate();
Value *X = Shl->getOperand(0);
if (Cmp.isEquality()) {
- // If we are comparing against bits always shifted out, the comparison
- // cannot succeed.
- Constant *Comp =
- ConstantExpr::getShl(ConstantExpr::getLShr(RHS, ShAmt), ShAmt);
- if (Comp != RHS) { // Comparing against a bit that we know is zero.
- bool IsICMP_NE = Pred == ICmpInst::ICMP_NE;
- Constant *Cst = Builder->getInt1(IsICMP_NE);
- return replaceInstUsesWith(Cmp, Cst);
- }
-
// If the shift is NUW, then it is just shifting out zeros, no need for an
// AND.
if (cast<BinaryOperator>(Shl)->hasNoUnsignedWrap())
More information about the llvm-commits
mailing list