[PATCH] D37879: [TargetTransformInfo] Static alloca has 0 cost
Guozhi Wei via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 15 15:29:51 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313410: [TargetTransformInfo] Static alloca has 0 cost (authored by Carrot).
Changed prior to commit:
https://reviews.llvm.org/D37879?vs=115429&id=115511#toc
Repository:
rL LLVM
https://reviews.llvm.org/D37879
Files:
llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/trunk/test/Analysis/CostModel/X86/costmodel.ll
Index: llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
===================================================================
--- llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -740,6 +740,11 @@
if (isa<PHINode>(U))
return TTI::TCC_Free; // Model all PHI nodes as free.
+ // Static alloca doesn't generate target instructions.
+ if (auto *A = dyn_cast<AllocaInst>(U))
+ if (A->isStaticAlloca())
+ return TTI::TCC_Free;
+
if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
GEP->getPointerOperand(),
Index: llvm/trunk/test/Analysis/CostModel/X86/costmodel.ll
===================================================================
--- llvm/trunk/test/Analysis/CostModel/X86/costmodel.ll
+++ llvm/trunk/test/Analysis/CostModel/X86/costmodel.ll
@@ -7,6 +7,14 @@
define i64 @foo(i64 %arg) {
+ ; LATENCY: cost of 0 {{.*}} alloca i32
+ ; CODESIZE: cost of 0 {{.*}} alloca i32
+ %A1 = alloca i32, align 8
+
+ ; LATENCY: cost of 1 {{.*}} alloca i64, i64 undef
+ ; CODESIZE: cost of 1 {{.*}} alloca i64, i64 undef
+ %A2 = alloca i64, i64 undef, align 8
+
; LATENCY: cost of 1 {{.*}} %I64 = add
; CODESIZE: cost of 1 {{.*}} %I64 = add
%I64 = add i64 undef, undef
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37879.115511.patch
Type: text/x-patch
Size: 1427 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170915/69024c93/attachment.bin>
More information about the llvm-commits
mailing list