diff options
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index 84e773a..78e21aee 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -880,7 +880,7 @@ Constant *llvm::ConstantFoldExtractElementInstruction(Constant *Val, // ee (gep (ptr, idx0, ...), idx) -> gep (ee (ptr, idx), ee (idx0, idx), ...) if (auto *CE = dyn_cast<ConstantExpr>(Val)) { - if (CE->getOpcode() == Instruction::GetElementPtr) { + if (auto *GEP = dyn_cast<GEPOperator>(CE)) { SmallVector<Constant *, 8> Ops; Ops.reserve(CE->getNumOperands()); for (unsigned i = 0, e = CE->getNumOperands(); i != e; ++i) { @@ -894,7 +894,7 @@ Constant *llvm::ConstantFoldExtractElementInstruction(Constant *Val, Ops.push_back(Op); } return CE->getWithOperands(Ops, ValVTy->getElementType(), false, - Ops[0]->getType()->getPointerElementType()); + GEP->getSourceElementType()); } else if (CE->getOpcode() == Instruction::InsertElement) { if (const auto *IEIdx = dyn_cast<ConstantInt>(CE->getOperand(2))) { if (APSInt::isSameValue(APSInt(IEIdx->getValue()), |