summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2019-09-18 18:38:40 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2019-09-18 18:38:40 +0000
commitba4cad9039660d322937f7f44bcb30b4849c3d58 (patch)
tree5511853a4ccb39c5b81b0c218f099d0413cf212c /llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
parent8b719a3b8a4efc8f0b84400fcbb7cdfea6d3b2f3 (diff)
downloadbcm5719-llvm-ba4cad9039660d322937f7f44bcb30b4849c3d58.tar.gz
bcm5719-llvm-ba4cad9039660d322937f7f44bcb30b4849c3d58.zip
[InstCombine] dropRedundantMaskingOfLeftShiftInput(): some cleanup before upcoming patch
llvm-svn: 372245
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
index cda83544a4d..fee95927cd2 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
@@ -164,6 +164,7 @@ dropRedundantMaskingOfLeftShiftInput(BinaryOperator *OuterShift,
// In this pattern SumOfShAmts correlates with the number of low bits that
// shall remain in the root value (OuterShift). If SumOfShAmts is less than
// bitwidth, we'll need to also produce a mask to keep SumOfShAmts low bits.
+ // So, does *any* channel need a mask?
if (!match(SumOfShAmts, m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGE,
APInt(BitWidth, BitWidth))))
return nullptr; // FIXME.
@@ -172,15 +173,17 @@ dropRedundantMaskingOfLeftShiftInput(BinaryOperator *OuterShift,
match(Masked, m_Shr(m_Shl(m_Value(X), m_Value(MaskShAmt)),
m_Deferred(MaskShAmt)))) {
// Can we simplify (ShiftShAmt-MaskShAmt) ?
- Value *ShAmtsDiff =
+ auto *ShAmtsDiff = dyn_cast_or_null<Constant>(
SimplifySubInst(ShiftShAmt, MaskShAmt, /*IsNSW=*/false, /*IsNUW=*/false,
- SQ.getWithInstruction(OuterShift));
+ SQ.getWithInstruction(OuterShift)));
if (!ShAmtsDiff)
return nullptr; // Did not simplify.
- // Is the difference non-negative? (is ShiftShAmt u>= MaskShAmt ?)
- // FIXME: could also rely on ConstantRange.
+ // In this pattern ShAmtsDiff correlates with the number of high bits that
+ // shall be unset in the root value (OuterShift). If ShAmtsDiff is negative,
+ // we'll need to also produce a mask to unset ShAmtsDiff high bits.
+ // So, does *any* channel need a mask? (is ShiftShAmt u>= MaskShAmt ?)
if (!match(ShAmtsDiff, m_NonNegative()))
- return nullptr;
+ return nullptr; // FIXME.
// All good, we can do this fold.
} else
return nullptr; // Don't know anything about this pattern.
OpenPOWER on IntegriCloud