[PATCH] D38557: Convert an APInt to int64_t properly in TTI::getGEPCost().
Justin Lebar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 4 13:08:55 PDT 2017
jlebar updated this revision to Diff 117720.
jlebar marked an inline comment as done.
jlebar added a comment.
Address efriedma's comment.
https://reviews.llvm.org/D38557
Files:
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/test/Analysis/CostModel/ARM/gep.ll
Index: llvm/test/Analysis/CostModel/ARM/gep.ll
===================================================================
--- llvm/test/Analysis/CostModel/ARM/gep.ll
+++ llvm/test/Analysis/CostModel/ARM/gep.ll
@@ -83,5 +83,8 @@
;CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds <4 x double>, <4 x double>*
%c12 = getelementptr inbounds <4 x double>, <4 x double>* undef, i32 %i
+;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i8, i8*
+ %d0 = getelementptr inbounds i8, i8* undef, i32 -1
+
ret void
}
Index: llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
===================================================================
--- llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -718,10 +718,10 @@
// Assumes the address space is 0 when Ptr is nullptr.
unsigned AS =
(Ptr == nullptr ? 0 : Ptr->getType()->getPointerAddressSpace());
+
if (static_cast<T *>(this)->isLegalAddressingMode(
TargetType, const_cast<GlobalValue *>(BaseGV),
- static_cast<int64_t>(BaseOffset.getLimitedValue()), HasBaseReg,
- Scale, AS))
+ BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
return TTI::TCC_Free;
return TTI::TCC_Basic;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38557.117720.patch
Type: text/x-patch
Size: 1316 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171004/915eed14/attachment.bin>
More information about the llvm-commits
mailing list