1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[TargetTransformInfo] Static alloca has 0 cost

Static alloca usually doesn't generate any machine instructions, so it has 0 cost.

Differential Revision: https://reviews.llvm.org/D37879

llvm-svn: 313410
This commit is contained in:
Guozhi Wei 2017-09-15 22:28:12 +00:00
parent 4a434efc2a
commit 24cd70c139
2 changed files with 13 additions and 0 deletions

View File

@ -740,6 +740,11 @@ public:
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(),

View File

@ -7,6 +7,14 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
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