aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/ConstantFold.cpp
diff options
context:
space:
mode:
authorArthur Eubanks <aeubanks@google.com>2021-05-26 20:32:04 -0700
committerArthur Eubanks <aeubanks@google.com>2021-05-31 09:54:57 -0700
commit2c3afa32377693514e400aee10f27b691887b4cf (patch)
treebc1dbf36094e54522a498350411c3200c32bcce0 /llvm/lib/IR/ConstantFold.cpp
parent116179c2ee5213f2ae8f07a400ac98f0c995b3d3 (diff)
downloadllvm-2c3afa32377693514e400aee10f27b691887b4cf.zip
llvm-2c3afa32377693514e400aee10f27b691887b4cf.tar.gz
llvm-2c3afa32377693514e400aee10f27b691887b4cf.tar.bz2
[OpaquePtr] Clean up some uses of Type::getPointerElementType()
These depend on pointee types.
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r--llvm/lib/IR/ConstantFold.cpp4
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()),