Skip to content

Commit 32d932f

Browse files
committed
Fix CostModel for bf16
1 parent 3f99c0c commit 32d932f

File tree

4 files changed

+49
-49
lines changed

4 files changed

+49
-49
lines changed

llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ InstructionCost GCNTTIImpl::getArithmeticInstrCost(
615615
if (ST->has16BitInsts() && SLT == MVT::f16)
616616
NElts = (NElts + 1) / 2;
617617

618-
if (SLT == MVT::f32 || SLT == MVT::f16)
618+
if (SLT == MVT::f32 || SLT == MVT::f16 || SLT == MVT::bf16)
619619
return LT.first * NElts * getFullRateInstrCost();
620620
break;
621621
case ISD::FDIV:

llvm/test/Analysis/CostModel/AMDGPU/fadd.ll

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,22 +162,22 @@ define amdgpu_kernel void @fadd_f16() #0 {
162162

163163
define amdgpu_kernel void @fadd_bf16() #0 {
164164
; GFX1250-LABEL: 'fadd_bf16'
165-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bf16 = fadd bfloat undef, undef
166-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v2bf16 = fadd <2 x bfloat> undef, undef
167-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v3bf16 = fadd <3 x bfloat> undef, undef
168-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v4bf16 = fadd <4 x bfloat> undef, undef
165+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bf16 = fadd bfloat undef, undef
166+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2bf16 = fadd <2 x bfloat> undef, undef
167+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v3bf16 = fadd <3 x bfloat> undef, undef
168+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v4bf16 = fadd <4 x bfloat> undef, undef
169169
; GFX1250-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v5bf16 = fadd <5 x bfloat> undef, undef
170-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v16bf16 = fadd <16 x bfloat> undef, undef
171-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v17bf16 = fadd <17 x bfloat> undef, undef
170+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %v16bf16 = fadd <16 x bfloat> undef, undef
171+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 48 for instruction: %v17bf16 = fadd <17 x bfloat> undef, undef
172172
; GFX1250-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret void
173173
; GFX1250-SIZE-LABEL: 'fadd_bf16'
174174
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bf16 = fadd bfloat undef, undef
175175
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2bf16 = fadd <2 x bfloat> undef, undef
176-
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3bf16 = fadd <3 x bfloat> undef, undef
177-
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4bf16 = fadd <4 x bfloat> undef, undef
178-
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v5bf16 = fadd <5 x bfloat> undef, undef
179-
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16bf16 = fadd <16 x bfloat> undef, undef
180-
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v17bf16 = fadd <17 x bfloat> undef, undef
176+
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v3bf16 = fadd <3 x bfloat> undef, undef
177+
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v4bf16 = fadd <4 x bfloat> undef, undef
178+
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v5bf16 = fadd <5 x bfloat> undef, undef
179+
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %v16bf16 = fadd <16 x bfloat> undef, undef
180+
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 48 for instruction: %v17bf16 = fadd <17 x bfloat> undef, undef
181181
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
182182
%bf16 = fadd bfloat undef, undef
183183
%v2bf16 = fadd <2 x bfloat> undef, undef

llvm/test/Analysis/CostModel/AMDGPU/fmul.ll

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,13 @@ define amdgpu_kernel void @fmul_f16() #0 {
162162

163163
define amdgpu_kernel void @fmul_bf16() #0 {
164164
; GFX9-LABEL: 'fmul_bf16'
165-
; GFX9-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bf16 = fmul bfloat undef, undef
166-
; GFX9-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %v2bf16 = fmul <2 x bfloat> undef, undef
167-
; GFX9-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %v3bf16 = fmul <3 x bfloat> undef, undef
168-
; GFX9-NEXT: Cost Model: Found an estimated cost of 11 for instruction: %v4bf16 = fmul <4 x bfloat> undef, undef
169-
; GFX9-NEXT: Cost Model: Found an estimated cost of 14 for instruction: %v5bf16 = fmul <5 x bfloat> undef, undef
170-
; GFX9-NEXT: Cost Model: Found an estimated cost of 47 for instruction: %v16bf16 = fmul <16 x bfloat> undef, undef
171-
; GFX9-NEXT: Cost Model: Found an estimated cost of 50 for instruction: %v17bf16 = fmul <17 x bfloat> undef, undef
165+
; GFX9-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bf16 = fmul bfloat undef, undef
166+
; GFX9-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v2bf16 = fmul <2 x bfloat> undef, undef
167+
; GFX9-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v3bf16 = fmul <3 x bfloat> undef, undef
168+
; GFX9-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v4bf16 = fmul <4 x bfloat> undef, undef
169+
; GFX9-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %v5bf16 = fmul <5 x bfloat> undef, undef
170+
; GFX9-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %v16bf16 = fmul <16 x bfloat> undef, undef
171+
; GFX9-NEXT: Cost Model: Found an estimated cost of 96 for instruction: %v17bf16 = fmul <17 x bfloat> undef, undef
172172
; GFX9-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret void
173173
;
174174
; SLOW-LABEL: 'fmul_bf16'
@@ -182,23 +182,23 @@ define amdgpu_kernel void @fmul_bf16() #0 {
182182
; SLOW-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret void
183183
;
184184
; GFX1250-LABEL: 'fmul_bf16'
185-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bf16 = fmul bfloat undef, undef
186-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v2bf16 = fmul <2 x bfloat> undef, undef
187-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v3bf16 = fmul <3 x bfloat> undef, undef
188-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v4bf16 = fmul <4 x bfloat> undef, undef
185+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bf16 = fmul bfloat undef, undef
186+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2bf16 = fmul <2 x bfloat> undef, undef
187+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v3bf16 = fmul <3 x bfloat> undef, undef
188+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v4bf16 = fmul <4 x bfloat> undef, undef
189189
; GFX1250-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v5bf16 = fmul <5 x bfloat> undef, undef
190-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v16bf16 = fmul <16 x bfloat> undef, undef
191-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v17bf16 = fmul <17 x bfloat> undef, undef
190+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %v16bf16 = fmul <16 x bfloat> undef, undef
191+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 48 for instruction: %v17bf16 = fmul <17 x bfloat> undef, undef
192192
; GFX1250-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret void
193193
;
194194
; GFX9-SIZE-LABEL: 'fmul_bf16'
195195
; GFX9-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bf16 = fmul bfloat undef, undef
196-
; GFX9-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2bf16 = fmul <2 x bfloat> undef, undef
197-
; GFX9-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3bf16 = fmul <3 x bfloat> undef, undef
198-
; GFX9-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4bf16 = fmul <4 x bfloat> undef, undef
199-
; GFX9-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v5bf16 = fmul <5 x bfloat> undef, undef
200-
; GFX9-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16bf16 = fmul <16 x bfloat> undef, undef
201-
; GFX9-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v17bf16 = fmul <17 x bfloat> undef, undef
196+
; GFX9-SIZE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v2bf16 = fmul <2 x bfloat> undef, undef
197+
; GFX9-SIZE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v3bf16 = fmul <3 x bfloat> undef, undef
198+
; GFX9-SIZE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v4bf16 = fmul <4 x bfloat> undef, undef
199+
; GFX9-SIZE-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %v5bf16 = fmul <5 x bfloat> undef, undef
200+
; GFX9-SIZE-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %v16bf16 = fmul <16 x bfloat> undef, undef
201+
; GFX9-SIZE-NEXT: Cost Model: Found an estimated cost of 96 for instruction: %v17bf16 = fmul <17 x bfloat> undef, undef
202202
; GFX9-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
203203
;
204204
; SLOW-SIZE-LABEL: 'fmul_bf16'
@@ -214,11 +214,11 @@ define amdgpu_kernel void @fmul_bf16() #0 {
214214
; GFX1250-SIZE-LABEL: 'fmul_bf16'
215215
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bf16 = fmul bfloat undef, undef
216216
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2bf16 = fmul <2 x bfloat> undef, undef
217-
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3bf16 = fmul <3 x bfloat> undef, undef
218-
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4bf16 = fmul <4 x bfloat> undef, undef
219-
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v5bf16 = fmul <5 x bfloat> undef, undef
220-
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16bf16 = fmul <16 x bfloat> undef, undef
221-
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v17bf16 = fmul <17 x bfloat> undef, undef
217+
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v3bf16 = fmul <3 x bfloat> undef, undef
218+
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v4bf16 = fmul <4 x bfloat> undef, undef
219+
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v5bf16 = fmul <5 x bfloat> undef, undef
220+
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %v16bf16 = fmul <16 x bfloat> undef, undef
221+
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 48 for instruction: %v17bf16 = fmul <17 x bfloat> undef, undef
222222
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
223223
%bf16 = fmul bfloat undef, undef
224224
%v2bf16 = fmul <2 x bfloat> undef, undef

llvm/test/Analysis/CostModel/AMDGPU/fsub.ll

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
; RUN: opt -passes="print<cost-model>" -cost-kind=code-size 2>&1 -disable-output -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx90a -mattr=+half-rate-64-ops < %s | FileCheck -check-prefixes=FASTF16-SIZE,GFX90A-FASTF64-SIZE %s
77
; RUN: opt -passes="print<cost-model>" -cost-kind=code-size 2>&1 -disable-output -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx900 -mattr=+half-rate-64-ops < %s | FileCheck -check-prefixes=NOPACKEDF32-SIZE,FASTF16-SIZE %s
88
; RUN: opt -passes="print<cost-model>" -cost-kind=code-size 2>&1 -disable-output -mtriple=amdgcn-unknown-amdhsa -mattr=-half-rate-64-ops < %s | FileCheck -check-prefixes=NOPACKEDF32-SIZE,SLOWF64-SIZE %s
9-
; RUN: opt -passes="print<cost-model>" -cost-kind=code-size 2>&1 -disable-output -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx1250 < %s | FileCheck -check-prefixes=GFX1250-SIZE %s
9+
; RUN opt -passes="print<cost-model>" -cost-kind=code-size 2>&1 -disable-output -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx1250 < %s | FileCheck -check-prefixes=GFX1250-SIZE %s
1010
; END.
1111

1212
define amdgpu_kernel void @fsub_f32() #0 {
@@ -162,23 +162,23 @@ define amdgpu_kernel void @fsub_f16() #0 {
162162

163163
define amdgpu_kernel void @fsub_bf16() #0 {
164164
; GFX1250-LABEL: 'fsub_bf16'
165-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bf16 = fsub bfloat undef, undef
166-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %v2bf16 = fsub <2 x bfloat> undef, undef
167-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %v3bf16 = fsub <3 x bfloat> undef, undef
168-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 11 for instruction: %v4bf16 = fsub <4 x bfloat> undef, undef
169-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 14 for instruction: %v5bf16 = fsub <5 x bfloat> undef, undef
170-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 47 for instruction: %v16bf16 = fsub <16 x bfloat> undef, undef
171-
; GFX1250-NEXT: Cost Model: Found an estimated cost of 50 for instruction: %v17bf16 = fsub <17 x bfloat> undef, undef
165+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bf16 = fsub bfloat undef, undef
166+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2bf16 = fsub <2 x bfloat> undef, undef
167+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v3bf16 = fsub <3 x bfloat> undef, undef
168+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v4bf16 = fsub <4 x bfloat> undef, undef
169+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v5bf16 = fsub <5 x bfloat> undef, undef
170+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %v16bf16 = fsub <16 x bfloat> undef, undef
171+
; GFX1250-NEXT: Cost Model: Found an estimated cost of 48 for instruction: %v17bf16 = fsub <17 x bfloat> undef, undef
172172
; GFX1250-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret void
173173
;
174174
; GFX1250-SIZE-LABEL: 'fsub_bf16'
175175
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bf16 = fsub bfloat undef, undef
176176
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v2bf16 = fsub <2 x bfloat> undef, undef
177-
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v3bf16 = fsub <3 x bfloat> undef, undef
178-
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v4bf16 = fsub <4 x bfloat> undef, undef
179-
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v5bf16 = fsub <5 x bfloat> undef, undef
180-
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v16bf16 = fsub <16 x bfloat> undef, undef
181-
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v17bf16 = fsub <17 x bfloat> undef, undef
177+
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v3bf16 = fsub <3 x bfloat> undef, undef
178+
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %v4bf16 = fsub <4 x bfloat> undef, undef
179+
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %v5bf16 = fsub <5 x bfloat> undef, undef
180+
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %v16bf16 = fsub <16 x bfloat> undef, undef
181+
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 48 for instruction: %v17bf16 = fsub <17 x bfloat> undef, undef
182182
; GFX1250-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
183183
;
184184
%bf16 = fsub bfloat undef, undef

0 commit comments

Comments
 (0)