[PATCH] D9819: [TTI/CostModel] improve TTI::getGEPCost and use it in CostModel::getInstructionCost
Jingyue Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 30 15:07:40 PST 2016
jingyue added inline comments.
================
Comment at: include/llvm/Analysis/TargetTransformInfoImpl.h:424
+ if (static_cast<T *>(this)->isLegalAddressingMode(
+ PointerType::get(*GTI, AS), const_cast<GlobalValue *>(BaseGV),
+ BaseOffset, HasBaseReg, Scale, AS)) {
----------------
haicheng wrote:
> I think we should use *GTI here rather than PointerType::get(*GTI, AS).
>
> For example, on AArch64, the GEP in the following IRs can be folded
>
> ```
> %"class.boost::array.16" = type { [24 x i32] }
> %arrayidx.i17 = getelementptr inbounds %"class.boost::array.16", %"class.boost::array.16"* %moves, i64 0, i32 0, i64 %conv7
> store i32 %add, i32* %arrayidx.i17, align 4, !tbaa !18
> ```
> The assembly is simple as
>
> ```
> str w24, [x20, x8, lsl #2]
> ```
>
> However, isLegalAddressingMode() here returns false because we pass a wrong type.
>
> I checked the implementation of isLegalAddressingMode() in several different backends (including ARM) and several other passes (LoopStrengthReduce and CodeGenPrepare) that call isLegalAddressingMode(). It think I am correct.
Thanks! I think you are right. Can you create a patch and add a unit test for this?
https://reviews.llvm.org/D9819
More information about the llvm-commits
mailing list