summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2017-01-16 19:35:45 +0000
committerSanjay Patel <spatel@rotateright.com>2017-01-16 19:35:45 +0000
commitab8b32de7199703905f2d3a5f891bfa163bba2d0 (patch)
tree72076d7752d17bf51a97b7b5580dac7fa2e2e05a /llvm/lib/Transforms/InstCombine
parentcd06f6fe10640ced55acecb128a5b8bff1830106 (diff)
downloadbcm5719-llvm-ab8b32de7199703905f2d3a5f891bfa163bba2d0.tar.gz
bcm5719-llvm-ab8b32de7199703905f2d3a5f891bfa163bba2d0.zip
[InstCombine] use m_APInt to allow shift-shift folds for vectors with splat constants
Some existing 'FIXME' tests are still not folded because of splat holes in value tracking. llvm-svn: 292151
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
index 8ccbd5cf33d..2a42fe7af61 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
@@ -72,9 +72,9 @@ static bool canEvaluateShiftedShift(unsigned FirstShiftAmt,
Instruction *CxtI) {
assert(SecondShift->isLogicalShift() && "Unexpected instruction type");
- // We need constant shifts.
- auto *SecondShiftConst = dyn_cast<ConstantInt>(SecondShift->getOperand(1));
- if (!SecondShiftConst)
+ // We need constant scalar or constant splat shifts.
+ const APInt *SecondShiftConst;
+ if (!match(SecondShift->getOperand(1), m_APInt(SecondShiftConst)))
return false;
unsigned SecondShiftAmt = SecondShiftConst->getZExtValue();
@@ -200,7 +200,8 @@ static Value *foldShiftedShift(BinaryOperator *InnerShift, unsigned OuterShAmt,
unsigned TypeWidth = ShType->getScalarSizeInBits();
// We only accept shifts-by-a-constant in canEvaluateShifted().
- ConstantInt *C1 = cast<ConstantInt>(InnerShift->getOperand(1));
+ const APInt *C1;
+ match(InnerShift->getOperand(1), m_APInt(C1));
unsigned InnerShAmt = C1->getZExtValue();
// Change the shift amount and clear the appropriate IR flags.
OpenPOWER on IntegriCloud