[PATCH] D26594: IR: Change the gep_type_iterator API to avoid always exposing the "current" type.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 2 13:30:50 PST 2016
pcc added inline comments.
================
Comment at: llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h:516
if (static_cast<T *>(this)->isLegalAddressingMode(
- PointerType::get(*GTI, AS), const_cast<GlobalValue *>(BaseGV),
+ PointerType::get(Type::getInt8Ty(PointeeType->getContext()), AS),
+ const_cast<GlobalValue *>(BaseGV),
----------------
haicheng wrote:
> Hi Peter,
>
> Would you please take a look at D27357 ?
>
> Should I change this line to fix the bug in the baseline?
>
> Thank you,
>
> Haicheng
Yes please, sorry about the conflict. This would appear to be the right code change for D27357:
```
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index 2934e9c..7bc6415 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -483,7 +483,9 @@ public:
int64_t Scale = 0;
auto GTI = gep_type_begin(PointeeType, Operands);
+ Type *TargetType;
for (auto I = Operands.begin(); I != Operands.end(); ++I, ++GTI) {
+ TargetType = GTI.getIndexedType();
// We assume that the cost of Scalar GEP with constant index and the
// cost of Vector GEP with splat constant index are the same.
const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
@@ -513,9 +515,8 @@ public:
unsigned AS =
(Ptr == nullptr ? 0 : Ptr->getType()->getPointerAddressSpace());
if (static_cast<T *>(this)->isLegalAddressingMode(
- PointerType::get(Type::getInt8Ty(PointeeType->getContext()), AS),
- const_cast<GlobalValue *>(BaseGV),
- BaseOffset, HasBaseReg, Scale, AS)) {
+ TargetType, const_cast<GlobalValue *>(BaseGV), BaseOffset,
+ HasBaseReg, Scale, AS)) {
return TTI::TCC_Free;
}
return TTI::TCC_Basic;
```
Repository:
rL LLVM
https://reviews.llvm.org/D26594
More information about the llvm-commits
mailing list