summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2017-09-20 23:48:58 +0000
committerCraig Topper <craig.topper@intel.com>2017-09-20 23:48:58 +0000
commit18887bf1795715fd3b52c22ca543ff7290defa1b (patch)
tree0ce939a170f471548df20d4e25d8215641bf59c6 /llvm/lib/Transforms/InstCombine
parenteb0f71f2328a04ebafa0791700ca682647157ca4 (diff)
downloadbcm5719-llvm-18887bf1795715fd3b52c22ca543ff7290defa1b.tar.gz
bcm5719-llvm-18887bf1795715fd3b52c22ca543ff7290defa1b.zip
[InstCombine] Teach getDemandedBitsLHSMask to handle constant splat vectors
This replaces a ConstantInt dyn_cast with m_APInt Differential Revision: https://reviews.llvm.org/D38100 llvm-svn: 313840
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 90b98dd71ae..1f981720ad1 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -3926,26 +3926,22 @@ static APInt getDemandedBitsLHSMask(ICmpInst &I, unsigned BitWidth,
if (isSignCheck)
return APInt::getSignMask(BitWidth);
- ConstantInt *CI = dyn_cast<ConstantInt>(I.getOperand(1));
- if (!CI) return APInt::getAllOnesValue(BitWidth);
- const APInt &RHS = CI->getValue();
+ const APInt *RHS;
+ if (!match(I.getOperand(1), m_APInt(RHS)))
+ return APInt::getAllOnesValue(BitWidth);
switch (I.getPredicate()) {
// For a UGT comparison, we don't care about any bits that
// correspond to the trailing ones of the comparand. The value of these
// bits doesn't impact the outcome of the comparison, because any value
// greater than the RHS must differ in a bit higher than these due to carry.
- case ICmpInst::ICMP_UGT: {
- unsigned trailingOnes = RHS.countTrailingOnes();
- return APInt::getBitsSetFrom(BitWidth, trailingOnes);
- }
+ case ICmpInst::ICMP_UGT:
+ return APInt::getBitsSetFrom(BitWidth, RHS->countTrailingOnes());
// Similarly, for a ULT comparison, we don't care about the trailing zeros.
// Any value less than the RHS must differ in a higher bit because of carries.
- case ICmpInst::ICMP_ULT: {
- unsigned trailingZeros = RHS.countTrailingZeros();
- return APInt::getBitsSetFrom(BitWidth, trailingZeros);
- }
+ case ICmpInst::ICMP_ULT:
+ return APInt::getBitsSetFrom(BitWidth, RHS->countTrailingZeros());
default:
return APInt::getAllOnesValue(BitWidth);
OpenPOWER on IntegriCloud