aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 9a93b55..d612e2e 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -1737,7 +1737,12 @@ static void computeKnownBitsFromOperator(const Operator *I,
}
break;
case Instruction::ShuffleVector: {
- auto *Shuf = cast<ShuffleVectorInst>(I);
+ auto *Shuf = dyn_cast<ShuffleVectorInst>(I);
+ // FIXME: Do we need to handle ConstantExpr involving shufflevectors?
+ if (!Shuf) {
+ Known.resetAll();
+ return;
+ }
// For undef elements, we don't know anything about the common state of
// the shuffle result.
APInt DemandedLHS, DemandedRHS;
@@ -1763,10 +1768,9 @@ static void computeKnownBitsFromOperator(const Operator *I,
break;
}
case Instruction::InsertElement: {
- auto *IEI = cast<InsertElementInst>(I);
- Value *Vec = IEI->getOperand(0);
- Value *Elt = IEI->getOperand(1);
- auto *CIdx = dyn_cast<ConstantInt>(IEI->getOperand(2));
+ const Value *Vec = I->getOperand(0);
+ const Value *Elt = I->getOperand(1);
+ auto *CIdx = dyn_cast<ConstantInt>(I->getOperand(2));
// Early out if the index is non-constant or out-of-range.
unsigned NumElts = DemandedElts.getBitWidth();
if (!CIdx || CIdx->getValue().uge(NumElts)) {
@@ -1796,9 +1800,8 @@ static void computeKnownBitsFromOperator(const Operator *I,
case Instruction::ExtractElement: {
// Look through extract element. If the index is non-constant or
// out-of-range demand all elements, otherwise just the extracted element.
- auto* EEI = cast<ExtractElementInst>(I);
- const Value* Vec = EEI->getVectorOperand();
- const Value* Idx = EEI->getIndexOperand();
+ const Value *Vec = I->getOperand(0);
+ const Value *Idx = I->getOperand(1);
auto *CIdx = dyn_cast<ConstantInt>(Idx);
unsigned NumElts = Vec->getType()->getVectorNumElements();
APInt DemandedVecElts = APInt::getAllOnesValue(NumElts);