[PATCH] D16281: [opaque pointer types] [breaking-change] [NFC] SimplifyGEPInst: take the source element type of the GEP as an argument.
Manuel Jacob via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 17 14:50:44 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL258024: [opaque pointer types] [breaking-change] [NFC] SimplifyGEPInst: take theā¦ (authored by mjacob).
Changed prior to commit:
http://reviews.llvm.org/D16281?vs=45127&id=45131#toc
Repository:
rL LLVM
http://reviews.llvm.org/D16281
Files:
llvm/trunk/include/llvm/Analysis/InstructionSimplify.h
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
llvm/trunk/lib/Analysis/PHITransAddr.cpp
llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
Index: llvm/trunk/include/llvm/Analysis/InstructionSimplify.h
===================================================================
--- llvm/trunk/include/llvm/Analysis/InstructionSimplify.h
+++ llvm/trunk/include/llvm/Analysis/InstructionSimplify.h
@@ -229,7 +229,8 @@
/// SimplifyGEPInst - Given operands for an GetElementPtrInst, see if we can
/// fold the result. If not, this returns null.
- Value *SimplifyGEPInst(ArrayRef<Value *> Ops, const DataLayout &DL,
+ Value *SimplifyGEPInst(Type *SrcTy, ArrayRef<Value *> Ops,
+ const DataLayout &DL,
const TargetLibraryInfo *TLI = nullptr,
const DominatorTree *DT = nullptr,
AssumptionCache *AC = nullptr,
Index: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp
@@ -3527,13 +3527,13 @@
Ops.slice(1));
}
-Value *llvm::SimplifyGEPInst(ArrayRef<Value *> Ops, const DataLayout &DL,
+Value *llvm::SimplifyGEPInst(Type *SrcTy, ArrayRef<Value *> Ops,
+ const DataLayout &DL,
const TargetLibraryInfo *TLI,
const DominatorTree *DT, AssumptionCache *AC,
const Instruction *CxtI) {
- return ::SimplifyGEPInst(
- cast<PointerType>(Ops[0]->getType()->getScalarType())->getElementType(),
- Ops, Query(DL, TLI, DT, AC, CxtI), RecursionLimit);
+ return ::SimplifyGEPInst(SrcTy, Ops,
+ Query(DL, TLI, DT, AC, CxtI), RecursionLimit);
}
/// Given operands for an InsertValueInst, see if we can fold the result.
@@ -4038,7 +4038,8 @@
break;
case Instruction::GetElementPtr: {
SmallVector<Value*, 8> Ops(I->op_begin(), I->op_end());
- Result = SimplifyGEPInst(Ops, DL, TLI, DT, AC, I);
+ Result = SimplifyGEPInst(cast<GetElementPtrInst>(I)->getSourceElementType(),
+ Ops, DL, TLI, DT, AC, I);
break;
}
case Instruction::InsertValue: {
Index: llvm/trunk/lib/Analysis/PHITransAddr.cpp
===================================================================
--- llvm/trunk/lib/Analysis/PHITransAddr.cpp
+++ llvm/trunk/lib/Analysis/PHITransAddr.cpp
@@ -229,7 +229,8 @@
return GEP;
// Simplify the GEP to handle 'gep x, 0' -> x etc.
- if (Value *V = SimplifyGEPInst(GEPOps, DL, TLI, DT, AC)) {
+ if (Value *V = SimplifyGEPInst(GEP->getSourceElementType(),
+ GEPOps, DL, TLI, DT, AC)) {
for (unsigned i = 0, e = GEPOps.size(); i != e; ++i)
RemoveInstInputs(GEPOps[i], InstInputs);
Index: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -1334,7 +1334,7 @@
Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
SmallVector<Value*, 8> Ops(GEP.op_begin(), GEP.op_end());
- if (Value *V = SimplifyGEPInst(Ops, DL, TLI, DT, AC))
+ if (Value *V = SimplifyGEPInst(GEP.getSourceElementType(), Ops, DL, TLI, DT, AC))
return ReplaceInstUsesWith(GEP, V);
Value *PtrOp = GEP.getOperand(0);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16281.45131.patch
Type: text/x-patch
Size: 3472 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160117/d5f1c13d/attachment.bin>
More information about the llvm-commits
mailing list