summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2017-01-13 18:39:09 +0000
committerSanjay Patel <spatel@rotateright.com>2017-01-13 18:39:09 +0000
commitb22f6c5f26730bc8d73904d0c98c71ebc50e2919 (patch)
treea98bf46637d771fd883f2a3c8230f11626e29fd5 /llvm/lib/Transforms/InstCombine
parentd066f3af61c92710374822c1c91e820ab739a1ee (diff)
downloadbcm5719-llvm-b22f6c5f26730bc8d73904d0c98c71ebc50e2919.tar.gz
bcm5719-llvm-b22f6c5f26730bc8d73904d0c98c71ebc50e2919.zip
[InstCombine] use m_APInt to allow shl folds for vectors with splat constants
llvm-svn: 291934
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
index 7249ef415d4..a79a630e5ec 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
@@ -723,8 +723,9 @@ Instruction *InstCombiner::visitShl(BinaryOperator &I) {
if (Instruction *V = commonShiftTransforms(I))
return V;
- if (ConstantInt *Op1C = dyn_cast<ConstantInt>(Op1)) {
- unsigned ShAmt = Op1C->getZExtValue();
+ const APInt *ShAmtAPInt;
+ if (match(Op1, m_APInt(ShAmtAPInt))) {
+ unsigned ShAmt = ShAmtAPInt->getZExtValue();
// Turn:
// %zext = zext i32 %V to i64
@@ -748,7 +749,8 @@ Instruction *InstCombiner::visitShl(BinaryOperator &I) {
// If the shifted-out value is known-zero, then this is a NUW shift.
if (!I.hasNoUnsignedWrap() &&
MaskedValueIsZero(
- Op0, APInt::getHighBitsSet(Op1C->getBitWidth(), ShAmt), 0, &I)) {
+ Op0, APInt::getHighBitsSet(ShAmtAPInt->getBitWidth(), ShAmt), 0,
+ &I)) {
I.setHasNoUnsignedWrap();
return &I;
}
OpenPOWER on IntegriCloud