summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2017-09-22 18:57:23 +0000
committerCraig Topper <craig.topper@intel.com>2017-09-22 18:57:23 +0000
commit3edda87c428236e263b872888e757b1f778878a4 (patch)
treead2f5b25a243d2539340b1c7a0037e377eb43104 /llvm
parent5b35b687856581bf9c08cafdcd88ff4054f47ec3 (diff)
downloadbcm5719-llvm-3edda87c428236e263b872888e757b1f778878a4.tar.gz
bcm5719-llvm-3edda87c428236e263b872888e757b1f778878a4.zip
[InstCombine] Move the call to isSignBitCheck into getDemandedBitsLHSMask instead of calling it outside and passing its result through a flag. NFCI
The result of the isSignBitCheck isn't used anywhere else and this allows us to share the m_APInt call in the likely case that it isn't a sign bit check. llvm-svn: 314018
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp23
1 files changed, 8 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index d9ead9893ea..cd59366d5ee 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -3921,15 +3921,17 @@ static Instruction *processUMulZExtIdiom(ICmpInst &I, Value *MulVal,
/// When performing a comparison against a constant, it is possible that not all
/// the bits in the LHS are demanded. This helper method computes the mask that
/// IS demanded.
-static APInt getDemandedBitsLHSMask(ICmpInst &I, unsigned BitWidth,
- bool isSignCheck) {
- if (isSignCheck)
- return APInt::getSignMask(BitWidth);
-
+static APInt getDemandedBitsLHSMask(ICmpInst &I, unsigned BitWidth) {
const APInt *RHS;
if (!match(I.getOperand(1), m_APInt(RHS)))
return APInt::getAllOnesValue(BitWidth);
+ // If this is a normal comparison, it demands all bits. If it is a sign bit
+ // comparison, it only demands the sign bit.
+ bool UnusedBit;
+ if (isSignBitCheck(I.getPredicate(), *RHS, UnusedBit))
+ return APInt::getSignMask(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
@@ -4115,20 +4117,11 @@ Instruction *InstCombiner::foldICmpUsingKnownBits(ICmpInst &I) {
if (!BitWidth)
return nullptr;
- // If this is a normal comparison, it demands all bits. If it is a sign bit
- // comparison, it only demands the sign bit.
- bool IsSignBit = false;
- const APInt *CmpC;
- if (match(Op1, m_APInt(CmpC))) {
- bool UnusedBit;
- IsSignBit = isSignBitCheck(Pred, *CmpC, UnusedBit);
- }
-
KnownBits Op0Known(BitWidth);
KnownBits Op1Known(BitWidth);
if (SimplifyDemandedBits(&I, 0,
- getDemandedBitsLHSMask(I, BitWidth, IsSignBit),
+ getDemandedBitsLHSMask(I, BitWidth),
Op0Known, 0))
return &I;
OpenPOWER on IntegriCloud