[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:49:15 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL314935: Convert an APInt to int64_t properly in TTI::getGEPCost(). (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D38557?vs=117720&id=117734#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38557

Files:
  llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/trunk/test/Analysis/CostModel/ARM/gep.ll


Index: llvm/trunk/test/Analysis/CostModel/ARM/gep.ll
===================================================================
--- llvm/trunk/test/Analysis/CostModel/ARM/gep.ll
+++ llvm/trunk/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/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
===================================================================
--- llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -720,10 +720,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.117734.patch
Type: text/x-patch
Size: 1352 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171004/7447351b/attachment.bin>


More information about the llvm-commits mailing list