summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/Analysis/TargetTransformInfoImpl.h4
-rw-r--r--llvm/test/Analysis/CostModel/ARM/gep.ll3
2 files changed, 5 insertions, 2 deletions
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index 2434f593bbb..905609e1afc 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -720,10 +720,10 @@ public:
// 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;
}
diff --git a/llvm/test/Analysis/CostModel/ARM/gep.ll b/llvm/test/Analysis/CostModel/ARM/gep.ll
index 9d74da4c2d3..12e314e2407 100644
--- a/llvm/test/Analysis/CostModel/ARM/gep.ll
+++ b/llvm/test/Analysis/CostModel/ARM/gep.ll
@@ -83,5 +83,8 @@ define void @test_geps(i32 %i) {
;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
}
OpenPOWER on IntegriCloud