From dd861964d125349be735267409dde25cf3bc9f6e Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Thu, 1 Sep 2016 14:20:43 +0000 Subject: [InstCombine] remove fold of an icmp pattern that should never happen While removing a scalar shackle from an icmp fold, I noticed that I couldn't find any tests to trigger this code path. The 'and' shrinking transform should be handled by InstCombiner::foldCastedBitwiseLogic() or eliminated with InstSimplify. The icmp narrowing is part of InstCombiner::foldICmpWithCastAndCast(). Differential Revision: https://reviews.llvm.org/D24031 llvm-svn: 280370 --- llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index d05b8d10e3c..d0675b77444 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -1526,21 +1526,6 @@ Instruction *InstCombiner::foldICmpAndConstConst(ICmpInst &Cmp, } } - // If the LHS is an AND of a zext, and we have an equality compare, we can - // shrink the and/compare to the smaller type, eliminating the cast. - if (ZExtInst *Cast = dyn_cast(And->getOperand(0))) { - IntegerType *Ty = cast(Cast->getSrcTy()); - // Make sure we don't compare the upper bits, SimplifyDemandedBits - // should fold the icmp to true/false in that case. - if (Cmp.isEquality() && C1->getActiveBits() <= Ty->getBitWidth()) { - Value *NewAnd = Builder->CreateAnd(Cast->getOperand(0), - ConstantExpr::getTrunc(C2, Ty)); - NewAnd->takeName(And); - return new ICmpInst(Cmp.getPredicate(), NewAnd, - ConstantExpr::getTrunc(RHS, Ty)); - } - } - if (Instruction *I = foldICmpAndShift(Cmp, And, C1)) return I; -- cgit v1.2.3