Index: include/llvm/Analysis/TargetTransformInfoImpl.h =================================================================== --- include/llvm/Analysis/TargetTransformInfoImpl.h +++ include/llvm/Analysis/TargetTransformInfoImpl.h @@ -740,6 +740,9 @@ if (isa(U)) return TTI::TCC_Free; // Model all PHI nodes as free. + if (isa(U)) + return TTI::TCC_Free; + if (const GEPOperator *GEP = dyn_cast(U)) { return static_cast(this)->getGEPCost(GEP->getSourceElementType(), GEP->getPointerOperand(), Index: test/Analysis/CostModel/X86/costmodel.ll =================================================================== --- test/Analysis/CostModel/X86/costmodel.ll +++ test/Analysis/CostModel/X86/costmodel.ll @@ -7,6 +7,10 @@ define i64 @foo(i64 %arg) { + ; LATENCY: cost of 0 {{.*}} alloca + ; CODESIZE: cost of 0 {{.*}} alloca + %A = alloca i64, align 8 + ; LATENCY: cost of 1 {{.*}} %I64 = add ; CODESIZE: cost of 1 {{.*}} %I64 = add %I64 = add i64 undef, undef