diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-08-04 17:48:04 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-08-04 17:48:04 +0000 |
commit | bcaf6f39dd28ee563afb2719cd001d506de7ca2d (patch) | |
tree | 8db9bcb7084b56a94c357bb5a5c9626d50a16ecd /llvm/lib/Analysis/InstructionSimplify.cpp | |
parent | 3dbce52c16959942229875b3b070c42a6ea7e56e (diff) | |
download | llvm-bcaf6f39dd28ee563afb2719cd001d506de7ca2d.zip llvm-bcaf6f39dd28ee563afb2719cd001d506de7ca2d.tar.gz llvm-bcaf6f39dd28ee563afb2719cd001d506de7ca2d.tar.bz2 |
[InstCombine] use m_APInt to allow icmp eq (op X, Y), C folds for splat constant vectors
I'm removing a misplaced pair of more specific folds from InstCombine in this patch as well,
so we know where those folds are happening in InstSimplify.
llvm-svn: 277738
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index ac03fdc..70f3ec0 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -3121,17 +3121,16 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, // If a bit is known to be zero for A and known to be one for B, // then A and B cannot be equal. if (ICmpInst::isEquality(Pred)) { - if (ConstantInt *CI = dyn_cast<ConstantInt>(RHS)) { - uint32_t BitWidth = CI->getBitWidth(); + const APInt *RHSVal; + if (match(RHS, m_APInt(RHSVal))) { + unsigned BitWidth = RHSVal->getBitWidth(); APInt LHSKnownZero(BitWidth, 0); APInt LHSKnownOne(BitWidth, 0); computeKnownBits(LHS, LHSKnownZero, LHSKnownOne, Q.DL, /*Depth=*/0, Q.AC, Q.CxtI, Q.DT); - const APInt &RHSVal = CI->getValue(); - if (((LHSKnownZero & RHSVal) != 0) || ((LHSKnownOne & ~RHSVal) != 0)) - return Pred == ICmpInst::ICMP_EQ - ? ConstantInt::getFalse(CI->getContext()) - : ConstantInt::getTrue(CI->getContext()); + if (((LHSKnownZero & *RHSVal) != 0) || ((LHSKnownOne & ~(*RHSVal)) != 0)) + return Pred == ICmpInst::ICMP_EQ ? ConstantInt::getFalse(ITy) + : ConstantInt::getTrue(ITy); } } |