aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/ConstantFold.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r--llvm/lib/IR/ConstantFold.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index d3caf04..03d7c5e 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -789,11 +789,10 @@ Constant *llvm::ConstantFoldExtractElementInstruction(Constant *Val,
return UndefValue::get(Val->getType()->getVectorElementType());
if (ConstantInt *CIdx = dyn_cast<ConstantInt>(Idx)) {
- uint64_t Index = CIdx->getZExtValue();
// ee({w,x,y,z}, wrong_value) -> undef
- if (Index >= Val->getType()->getVectorNumElements())
+ if (CIdx->uge(Val->getType()->getVectorNumElements()))
return UndefValue::get(Val->getType()->getVectorElementType());
- return Val->getAggregateElement(Index);
+ return Val->getAggregateElement(CIdx->getZExtValue());
}
return nullptr;
}