[llvm] [AMDGPU] Fix vector legalization for bf16 valu ops (PR #158439)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 24 02:35:06 PDT 2025


================
@@ -157,3 +159,34 @@ define amdgpu_kernel void @fsub_f16() #0 {
   %v17f16 = fsub <17 x half> undef, undef
   ret void
 }
+
+define amdgpu_kernel void @fsub_bf16() #0 {
+; GFX1250-LABEL: 'fsub_bf16'
+; GFX1250-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %bf16 = fsub bfloat undef, undef
+; GFX1250-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v2bf16 = fsub <2 x bfloat> undef, undef
+; GFX1250-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %v3bf16 = fsub <3 x bfloat> undef, undef
+; GFX1250-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %v4bf16 = fsub <4 x bfloat> undef, undef
+; GFX1250-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %v5bf16 = fsub <5 x bfloat> undef, undef
+; GFX1250-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %v16bf16 = fsub <16 x bfloat> undef, undef
+; GFX1250-NEXT:  Cost Model: Found an estimated cost of 48 for instruction: %v17bf16 = fsub <17 x bfloat> undef, undef
+; GFX1250-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: ret void
+;
+; GFX1250-SIZE-LABEL: 'fsub_bf16'
+; GFX1250-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %bf16 = fsub bfloat undef, undef
+; GFX1250-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %v2bf16 = fsub <2 x bfloat> undef, undef
+; GFX1250-SIZE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %v3bf16 = fsub <3 x bfloat> undef, undef
+; GFX1250-SIZE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %v4bf16 = fsub <4 x bfloat> undef, undef
+; GFX1250-SIZE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %v5bf16 = fsub <5 x bfloat> undef, undef
+; GFX1250-SIZE-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %v16bf16 = fsub <16 x bfloat> undef, undef
+; GFX1250-SIZE-NEXT:  Cost Model: Found an estimated cost of 48 for instruction: %v17bf16 = fsub <17 x bfloat> undef, undef
+; GFX1250-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret void
+;
+  %bf16 = fsub bfloat undef, undef
----------------
arsenm wrote:

s/undef/poison

https://github.com/llvm/llvm-project/pull/158439


More information about the llvm-commits mailing list