Skip to content

[AMDGPU] Disable V_WMMA_F{16|32}_16X16X128_[BF]P8_[BF]P8 on gfx1250-strict - #228564

Merged
rampitec merged 2 commits into
mainfrom
users/rampitec/disable-16x16x128-fp8-on-strict
Oct 2, 2026
Merged

rampitec merged 2 commits into
mainfrom
users/rampitec/disable-16x16x128-fp8-on-strict

Conversation

@rampitec

@rampitec rampitec commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes: LCOMPILER-2899

@rampitec

rampitec commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by sgh.

@rampitec
rampitec marked this pull request as ready for review October 2, 2026 20:23
@rampitec
rampitec enabled auto-merge (squash) October 2, 2026 20:23
@llvmorg-github-actions llvmorg-github-actions Bot added backend:AMDGPU clang:frontend Language frontend issues, e.g. anything involving "Sema" llvm:ir labels Oct 2, 2026
@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-backend-amdgpu

Author: Stanislav Mekhanoshin (rampitec)

Changes

Fixes: LCOMPILER-2899


Patch is 20.96 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/228564.diff

6 Files Affected:

  • (modified) clang/include/clang/Basic/BuiltinsAMDGPU.td (+8-8)
  • (modified) clang/test/SemaOpenCL/builtins-amdgcn-error-gfx1250-strict.cl (+11-1)
  • (modified) llvm/include/llvm/IR/IntrinsicsAMDGPU.td (+8-5)
  • (modified) llvm/lib/Target/AMDGPU/AMDGPU.td (+7-1)
  • (modified) llvm/lib/Target/AMDGPU/VOP3PInstructions.td (+18-12)
  • (modified) llvm/test/MC/AMDGPU/gfx1250-strict_err.s (+24)
diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.td b/clang/include/clang/Basic/BuiltinsAMDGPU.td
index c66f8c10a84c7..483df0561fc20 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.td
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.td
@@ -1236,19 +1236,19 @@ def __builtin_amdgcn_wmma_i32_16x16x64_iu8 : AMDGPUBuiltin<"_ExtVector<8, int>(_
   let Documentation = [DocWMMA_i32_16x16x64_iu8_GFX1250];
   let ArgNames = ["a_sign", "a", "b_sign", "b", "c", "matrix_a_reuse", "matrix_b_reuse"];
 }
-def __builtin_amdgcn_wmma_f16_16x16x128_fp8_fp8 : AMDGPUBuiltin<"_ExtVector<8, _Float16>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, _Float16>, _Constant bool, _Constant bool)", [Const], "wmma-n16-insts,wavefrontsize32"> {
+def __builtin_amdgcn_wmma_f16_16x16x128_fp8_fp8 : AMDGPUBuiltin<"_ExtVector<8, _Float16>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, _Float16>, _Constant bool, _Constant bool)", [Const], "wmma-16x16x128fp8-insts,wavefrontsize32"> {
   let Documentation = [DocWMMA_fp8_16x16x128_GFX1250];
   let ArgNames = ["a", "b", "c_mod", "c", "matrix_a_reuse", "matrix_b_reuse"];
 }
-def __builtin_amdgcn_wmma_f16_16x16x128_fp8_bf8 : AMDGPUBuiltin<"_ExtVector<8, _Float16>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, _Float16>, _Constant bool, _Constant bool)", [Const], "wmma-n16-insts,wavefrontsize32"> {
+def __builtin_amdgcn_wmma_f16_16x16x128_fp8_bf8 : AMDGPUBuiltin<"_ExtVector<8, _Float16>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, _Float16>, _Constant bool, _Constant bool)", [Const], "wmma-16x16x128fp8-insts,wavefrontsize32"> {
   let Documentation = [DocWMMA_fp8_16x16x128_GFX1250];
   let ArgNames = ["a", "b", "c_mod", "c", "matrix_a_reuse", "matrix_b_reuse"];
 }
-def __builtin_amdgcn_wmma_f16_16x16x128_bf8_fp8 : AMDGPUBuiltin<"_ExtVector<8, _Float16>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, _Float16>, _Constant bool, _Constant bool)", [Const], "wmma-n16-insts,wavefrontsize32"> {
+def __builtin_amdgcn_wmma_f16_16x16x128_bf8_fp8 : AMDGPUBuiltin<"_ExtVector<8, _Float16>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, _Float16>, _Constant bool, _Constant bool)", [Const], "wmma-16x16x128fp8-insts,wavefrontsize32"> {
   let Documentation = [DocWMMA_fp8_16x16x128_GFX1250];
   let ArgNames = ["a", "b", "c_mod", "c", "matrix_a_reuse", "matrix_b_reuse"];
 }
-def __builtin_amdgcn_wmma_f16_16x16x128_bf8_bf8 : AMDGPUBuiltin<"_ExtVector<8, _Float16>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, _Float16>, _Constant bool, _Constant bool)", [Const], "wmma-n16-insts,wavefrontsize32"> {
+def __builtin_amdgcn_wmma_f16_16x16x128_bf8_bf8 : AMDGPUBuiltin<"_ExtVector<8, _Float16>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, _Float16>, _Constant bool, _Constant bool)", [Const], "wmma-16x16x128fp8-insts,wavefrontsize32"> {
   let Documentation = [DocWMMA_fp8_16x16x128_GFX1250];
   let ArgNames = ["a", "b", "c_mod", "c", "matrix_a_reuse", "matrix_b_reuse"];
 }
@@ -1256,19 +1256,19 @@ def __builtin_amdgcn_wmma_f32_16x16x128_f8f6f4 : AMDGPUBuiltin<"_ExtVector<8, fl
   let Documentation = [DocWMMA_f8f6f4_GFX1250];
   let ArgNames = ["matrix_a_fmt", "a", "matrix_b_fmt", "b", "c_mod", "c"];
 }
-def __builtin_amdgcn_wmma_f32_16x16x128_fp8_fp8 : AMDGPUBuiltin<"_ExtVector<8, float>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, float>, _Constant bool, _Constant bool)", [Const], "wmma-n16-insts,wavefrontsize32"> {
+def __builtin_amdgcn_wmma_f32_16x16x128_fp8_fp8 : AMDGPUBuiltin<"_ExtVector<8, float>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, float>, _Constant bool, _Constant bool)", [Const], "wmma-16x16x128fp8-insts,wavefrontsize32"> {
   let Documentation = [DocWMMA_fp8_16x16x128_GFX1250];
   let ArgNames = ["a", "b", "c_mod", "c", "matrix_a_reuse", "matrix_b_reuse"];
 }
-def __builtin_amdgcn_wmma_f32_16x16x128_fp8_bf8 : AMDGPUBuiltin<"_ExtVector<8, float>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, float>, _Constant bool, _Constant bool)", [Const], "wmma-n16-insts,wavefrontsize32"> {
+def __builtin_amdgcn_wmma_f32_16x16x128_fp8_bf8 : AMDGPUBuiltin<"_ExtVector<8, float>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, float>, _Constant bool, _Constant bool)", [Const], "wmma-16x16x128fp8-insts,wavefrontsize32"> {
   let Documentation = [DocWMMA_fp8_16x16x128_GFX1250];
   let ArgNames = ["a", "b", "c_mod", "c", "matrix_a_reuse", "matrix_b_reuse"];
 }
-def __builtin_amdgcn_wmma_f32_16x16x128_bf8_fp8 : AMDGPUBuiltin<"_ExtVector<8, float>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, float>, _Constant bool, _Constant bool)", [Const], "wmma-n16-insts,wavefrontsize32"> {
+def __builtin_amdgcn_wmma_f32_16x16x128_bf8_fp8 : AMDGPUBuiltin<"_ExtVector<8, float>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, float>, _Constant bool, _Constant bool)", [Const], "wmma-16x16x128fp8-insts,wavefrontsize32"> {
   let Documentation = [DocWMMA_fp8_16x16x128_GFX1250];
   let ArgNames = ["a", "b", "c_mod", "c", "matrix_a_reuse", "matrix_b_reuse"];
 }
-def __builtin_amdgcn_wmma_f32_16x16x128_bf8_bf8 : AMDGPUBuiltin<"_ExtVector<8, float>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, float>, _Constant bool, _Constant bool)", [Const], "wmma-n16-insts,wavefrontsize32"> {
+def __builtin_amdgcn_wmma_f32_16x16x128_bf8_bf8 : AMDGPUBuiltin<"_ExtVector<8, float>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, float>, _Constant bool, _Constant bool)", [Const], "wmma-16x16x128fp8-insts,wavefrontsize32"> {
   let Documentation = [DocWMMA_fp8_16x16x128_GFX1250];
   let ArgNames = ["a", "b", "c_mod", "c", "matrix_a_reuse", "matrix_b_reuse"];
 }
diff --git a/clang/test/SemaOpenCL/builtins-amdgcn-error-gfx1250-strict.cl b/clang/test/SemaOpenCL/builtins-amdgcn-error-gfx1250-strict.cl
index 2e031975f09c1..e80de1ab6dd34 100644
--- a/clang/test/SemaOpenCL/builtins-amdgcn-error-gfx1250-strict.cl
+++ b/clang/test/SemaOpenCL/builtins-amdgcn-error-gfx1250-strict.cl
@@ -6,12 +6,22 @@ typedef unsigned int __attribute__((ext_vector_type(2))) uint2;
 typedef unsigned int __attribute__((ext_vector_type(3))) uint3;
 typedef float  v16f  __attribute__((ext_vector_type(16)));
 typedef float  v8f   __attribute__((ext_vector_type(8)));
+typedef half   v8h   __attribute__((ext_vector_type(8)));
 typedef int    v16i   __attribute__((ext_vector_type(16)));
 typedef int    v8i   __attribute__((ext_vector_type(8)));
 
-void test(global v16f* out, v16i a, v8i b, v16f c, int scale_src0, int scale_src1, uint scale, uint src1, uint2 src2, uint3 src3)
+void test(global v16f* out, v16i a, v8i b, v16f c, int scale_src0, int scale_src1, uint scale, uint src1, uint2 src2, uint3 src3,
+          global v8h* out8h, global v8f* out8f, v16i a16i, v16i b16i, v8h c8h, v8f c8f)
 {
   *out = __builtin_amdgcn_wmma_f32_32x16x128_f4(a, b, false, c); // expected-error {{'__builtin_amdgcn_wmma_f32_32x16x128_f4' needs target feature wmma-f4-insts}}
   *out = __builtin_amdgcn_wmma_scale_f32_32x16x128_f4(a, b, false, c, 1, 0, scale_src0, 2, 0, scale_src1, 1, 0); // expected-error {{'__builtin_amdgcn_wmma_scale_f32_32x16x128_f4' needs target feature wmma-f4-insts}}
   *out = __builtin_amdgcn_wmma_scale16_f32_32x16x128_f4(a, b, false, c, 1, 0, scale_src0, 2, 0, scale_src1, 1, 0); // expected-error {{'__builtin_amdgcn_wmma_scale16_f32_32x16x128_f4' needs target feature wmma-f4-insts}}
+  *out8h = __builtin_amdgcn_wmma_f16_16x16x128_fp8_fp8(a16i, b16i, 0, c8h, false, true); // expected-error {{'__builtin_amdgcn_wmma_f16_16x16x128_fp8_fp8' needs target feature wmma-16x16x128fp8-insts}}
+  *out8h = __builtin_amdgcn_wmma_f16_16x16x128_fp8_bf8(a16i, b16i, 0, c8h, false, true); // expected-error {{'__builtin_amdgcn_wmma_f16_16x16x128_fp8_bf8' needs target feature wmma-16x16x128fp8-insts}}
+  *out8h = __builtin_amdgcn_wmma_f16_16x16x128_bf8_fp8(a16i, b16i, 0, c8h, false, true); // expected-error {{'__builtin_amdgcn_wmma_f16_16x16x128_bf8_fp8' needs target feature wmma-16x16x128fp8-insts}}
+  *out8h = __builtin_amdgcn_wmma_f16_16x16x128_bf8_bf8(a16i, b16i, 0, c8h, false, true); // expected-error {{'__builtin_amdgcn_wmma_f16_16x16x128_bf8_bf8' needs target feature wmma-16x16x128fp8-insts}}
+  *out8f = __builtin_amdgcn_wmma_f32_16x16x128_fp8_fp8(a16i, b16i, 0, c8f, false, true); // expected-error {{'__builtin_amdgcn_wmma_f32_16x16x128_fp8_fp8' needs target feature wmma-16x16x128fp8-insts}}
+  *out8f = __builtin_amdgcn_wmma_f32_16x16x128_fp8_bf8(a16i, b16i, 0, c8f, false, true); // expected-error {{'__builtin_amdgcn_wmma_f32_16x16x128_fp8_bf8' needs target feature wmma-16x16x128fp8-insts}}
+  *out8f = __builtin_amdgcn_wmma_f32_16x16x128_bf8_fp8(a16i, b16i, 0, c8f, false, true); // expected-error {{'__builtin_amdgcn_wmma_f32_16x16x128_bf8_fp8' needs target feature wmma-16x16x128fp8-insts}}
+  *out8f = __builtin_amdgcn_wmma_f32_16x16x128_bf8_bf8(a16i, b16i, 0, c8f, false, true); // expected-error {{'__builtin_amdgcn_wmma_f32_16x16x128_bf8_bf8' needs target feature wmma-16x16x128fp8-insts}}
 }
diff --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
index 623e8b7f0647c..fa29d08c91d7b 100644
--- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -4327,6 +4327,13 @@ let TargetFeatures = "wmma-n16-insts" in {
   def int_amdgcn_wmma_f16_16x16x64_fp8_bf8  : AMDGPUWmmaIntrinsicModsC<llvm_anyint_ty, llvm_anyfloat_ty>;
   def int_amdgcn_wmma_f16_16x16x64_bf8_fp8  : AMDGPUWmmaIntrinsicModsC<llvm_anyint_ty, llvm_anyfloat_ty>;
   def int_amdgcn_wmma_f16_16x16x64_bf8_bf8  : AMDGPUWmmaIntrinsicModsC<llvm_anyint_ty, llvm_anyfloat_ty>;
+  def int_amdgcn_wmma_i32_16x16x64_iu8      : AMDGPUWmmaIntrinsicModsABClamp<llvm_anyint_ty, llvm_anyint_ty>;
+  def int_amdgcn_wmma_f32_16x16x128_f8f6f4  : AMDGPUWmmaIntrinsicModsC_MatrixFMT;
+  def int_amdgcn_wmma_scale_f32_16x16x128_f8f6f4   : AMDGPUWmmaScaleIntrinsicModsC<llvm_i32_ty>;
+  def int_amdgcn_wmma_scale16_f32_16x16x128_f8f6f4 : AMDGPUWmmaScaleIntrinsicModsC<llvm_i64_ty>;
+} // End TargetFeatures = "wmma-n16-insts"
+
+let TargetFeatures = "wmma-16x16x128fp8-insts" in {
   def int_amdgcn_wmma_f16_16x16x128_fp8_fp8 : AMDGPUWmmaIntrinsicModsC<llvm_anyint_ty, llvm_anyfloat_ty>;
   def int_amdgcn_wmma_f16_16x16x128_fp8_bf8 : AMDGPUWmmaIntrinsicModsC<llvm_anyint_ty, llvm_anyfloat_ty>;
   def int_amdgcn_wmma_f16_16x16x128_bf8_fp8 : AMDGPUWmmaIntrinsicModsC<llvm_anyint_ty, llvm_anyfloat_ty>;
@@ -4335,11 +4342,7 @@ let TargetFeatures = "wmma-n16-insts" in {
   def int_amdgcn_wmma_f32_16x16x128_fp8_bf8 : AMDGPUWmmaIntrinsicModsC<llvm_anyint_ty, llvm_anyfloat_ty>;
   def int_amdgcn_wmma_f32_16x16x128_bf8_fp8 : AMDGPUWmmaIntrinsicModsC<llvm_anyint_ty, llvm_anyfloat_ty>;
   def int_amdgcn_wmma_f32_16x16x128_bf8_bf8 : AMDGPUWmmaIntrinsicModsC<llvm_anyint_ty, llvm_anyfloat_ty>;
-  def int_amdgcn_wmma_i32_16x16x64_iu8      : AMDGPUWmmaIntrinsicModsABClamp<llvm_anyint_ty, llvm_anyint_ty>;
-  def int_amdgcn_wmma_f32_16x16x128_f8f6f4  : AMDGPUWmmaIntrinsicModsC_MatrixFMT;
-  def int_amdgcn_wmma_scale_f32_16x16x128_f8f6f4   : AMDGPUWmmaScaleIntrinsicModsC<llvm_i32_ty>;
-  def int_amdgcn_wmma_scale16_f32_16x16x128_f8f6f4 : AMDGPUWmmaScaleIntrinsicModsC<llvm_i64_ty>;
-} // End TargetFeatures = "wmma-n16-insts"
+}
 
 let TargetFeatures = "wmma-f4-insts" in {
   def int_amdgcn_wmma_f32_32x16x128_f4       : AMDGPUWmmaIntrinsicF4ModsC<llvm_anyint_ty, llvm_anyint_ty, llvm_anyfloat_ty>;
diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.td b/llvm/lib/Target/AMDGPU/AMDGPU.td
index 90a0871ff3669..d552eae9c08d3 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.td
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.td
@@ -1003,6 +1003,10 @@ defm WMMAF4Insts : AMDGPUSubtargetFeature<"wmma-f4-insts",
   "Has WMMA_*_F4 instructions"
 >;
 
+defm WMMA16x16x128FP8Insts : AMDGPUSubtargetFeature<"wmma-16x16x128fp8-insts",
+  "Has 16x16x128 FP8/BF8 WMMA instructions"
+>;
+
 defm SWMMACGfx1200Insts : AMDGPUSubtargetFeature<"swmmac-gfx1200-insts",
   "Has GFX1200 SWMMAC instructions"
 >;
@@ -2598,6 +2602,7 @@ def FeatureISAVersion12_50 : FeatureSet<
    FeatureLDSBankCount64,
    FeatureWMMAN16Insts,
    FeatureWMMAF4Insts,
+   FeatureWMMA16x16x128FP8Insts,
    FeatureVOP3PX2IncrementsVaVdstTwice,
    FeatureSetregVGPRMSBFixup,
    FeatureCubeInsts,
@@ -2634,6 +2639,7 @@ def FeatureISAVersion12_51 : FeatureSet<
    FeatureLDSBankCount64,
    FeatureWMMAN16Insts,
    FeatureWMMAF4Insts,
+   FeatureWMMA16x16x128FP8Insts,
    FeatureFullRate64Ops,
    FeatureVOP3PX2IncrementsVaVdstTwice,
    FeatureDPALU_DPP,
@@ -3385,7 +3391,7 @@ def AMDGPUFrontendVisibleFeatures {
   FeatureTDMInsts, FeatureTanhInsts, FeatureTensorCvtLutInsts,
   FeatureTransposeLoadF4F6Insts, FeatureVMemToLDSLoad, FeatureVmemPrefInsts,
   FeatureWaveMatchInsts, FeatureWMMA128bInsts, FeatureWMMA256bInsts,
-  FeatureWMMAN16Insts, FeatureWMMAF4Insts, FeatureXF32Insts,
+  FeatureWMMAN16Insts, FeatureWMMAF4Insts, FeatureWMMA16x16x128FP8Insts, FeatureXF32Insts,
   FeatureWavefrontSize32, FeatureWavefrontSize64, FeatureSupportsWGP,
   FeatureSupportsWave32, FeatureFastFMAF32, FeatureFastDenormalF32,
   FeatureSupportsXNACK, FeatureSupportsSRAMECC, FeatureXNACKOnOffModes,
diff --git a/llvm/lib/Target/AMDGPU/VOP3PInstructions.td b/llvm/lib/Target/AMDGPU/VOP3PInstructions.td
index 7d73bb328c590..7a0f162242e1c 100644
--- a/llvm/lib/Target/AMDGPU/VOP3PInstructions.td
+++ b/llvm/lib/Target/AMDGPU/VOP3PInstructions.td
@@ -2243,6 +2243,13 @@ let WaveSizePredicate = isWave32 in {
       defm V_WMMA_I32_16X16X64_IU8_w32      : WMMAInstGFX12<"v_wmma_i32_16x16x64_iu8",      I32_IU8X64_WMMA_w32, "_w32">;
       defm V_WMMA_F32_16X16X32_F16_w32      : WMMAInstGFX12<"v_wmma_f32_16x16x32_f16",      F32_F16X32_WMMA_w32, "_w32">;
       defm V_WMMA_F16_16X16X32_F16_w32      : WMMAInstGFX12<"v_wmma_f16_16x16x32_f16",      F16_F16X32_WMMA_w32, "_w32">;
+
+      defm V_WMMA_F32_16X16X128_F8F6F4         : WMMAInst_SrcFormats_mc<"v_wmma_f32_16x16x128_f8f6f4", "F32_16X16X128_F8F6F4">;
+      defm V_WMMA_SCALE_F32_16X16X128_F8F6F4   : WMMAInst_SrcFormats_mc<"v_wmma_scale_f32_16x16x128_f8f6f4", "F32_16X16X128_F8F6F4_SCALE">;
+      defm V_WMMA_SCALE16_F32_16X16X128_F8F6F4 : WMMAInst_SrcFormats_mc<"v_wmma_scale16_f32_16x16x128_f8f6f4", "F32_16X16X128_F8F6F4_SCALE16">;
+    } // End SubtargetPredicate = HasWMMAN16Insts
+
+    let SubtargetPredicate = HasWMMA16x16x128FP8Insts in {
       defm V_WMMA_F16_16X16X128_FP8_FP8_w32 : WMMAInstGFX12<"v_wmma_f16_16x16x128_fp8_fp8", F16_FP8BF8X128_WMMA_w32, "_w32">;
       defm V_WMMA_F16_16X16X128_FP8_BF8_w32 : WMMAInstGFX12<"v_wmma_f16_16x16x128_fp8_bf8", F16_FP8BF8X128_WMMA_w32, "_w32">;
       defm V_WMMA_F16_16X16X128_BF8_FP8_w32 : WMMAInstGFX12<"v_wmma_f16_16x16x128_bf8_fp8", F16_FP8BF8X128_WMMA_w32, "_w32">;
@@ -2251,11 +2258,7 @@ let WaveSizePredicate = isWave32 in {
       defm V_WMMA_F32_16X16X128_FP8_BF8_w32 : WMMAInstGFX12<"v_wmma_f32_16x16x128_fp8_bf8", F32_FP8BF8X128_WMMA_w32, "_w32">;
       defm V_WMMA_F32_16X16X128_BF8_FP8_w32 : WMMAInstGFX12<"v_wmma_f32_16x16x128_bf8_fp8", F32_FP8BF8X128_WMMA_w32, "_w32">;
       defm V_WMMA_F32_16X16X128_BF8_BF8_w32 : WMMAInstGFX12<"v_wmma_f32_16x16x128_bf8_bf8", F32_FP8BF8X128_WMMA_w32, "_w32">;
-
-      defm V_WMMA_F32_16X16X128_F8F6F4         : WMMAInst_SrcFormats_mc<"v_wmma_f32_16x16x128_f8f6f4", "F32_16X16X128_F8F6F4">;
-      defm V_WMMA_SCALE_F32_16X16X128_F8F6F4   : WMMAInst_SrcFormats_mc<"v_wmma_scale_f32_16x16x128_f8f6f4", "F32_16X16X128_F8F6F4_SCALE">;
-      defm V_WMMA_SCALE16_F32_16X16X128_F8F6F4 : WMMAInst_SrcFormats_mc<"v_wmma_scale16_f32_16x16x128_f8f6f4", "F32_16X16X128_F8F6F4_SCALE16">;
-    } // End SubtargetPredicate = HasWMMAN16Insts
+    } // End SubtargetPredicate = HasWMMA16x16x128FP8Insts
 
     let SubtargetPredicate = HasWMMAF4Insts in {
       defm V_WMMA_F32_32X16X128_F4_w32      : WMMAInstGFX12<"v_wmma_f32_32x16x128_f4",      F32_32X16X128_F4_WMMA_w32, "_w32">;
@@ -2445,6 +2448,15 @@ let SubtargetPredicate = HasWMMAN16Insts in {
   defm : WMMAPat<"V_WMMA_I32_16X16X64_IU8_w32",         int_amdgcn_wmma_i32_16x16x64_iu8,         I32_IU8X64_WMMA_w32>;
   defm : WMMAPat<"V_WMMA_F32_16X16X32_F16_w32",         int_amdgcn_wmma_f32_16x16x32_f16,         F32_F16X32_WMMA_w32>;
   defm : WMMAPat<"V_WMMA_F16_16X16X32_F16_w32",         int_amdgcn_wmma_f16_16x16x32_f16,         F16_F16X32_WMMA_w32>;
+
+  foreach I = ["f8_f8", "f8_f6", "f8_f4", "f6_f8", "f6_f6", "f6_f4", "f4_f8", "f4_f6", "f4_f4"] in {
+    defm : WMMAPat<"V_WMMA_F32_16X16X128_F8F6F4_" # I # "_w32",         int_amdgcn_wmma_f32_16x16x128_f8f6f4,         !cast<VOP3PWMMA_Profile>("F32_16X16X128_F8F6F4_" # I # "_w32")>;
+    defm : WMMAPat<"V_WMMA_SCALE_F32_16X16X128_F8F6F4_" # I # "_w32",   int_amdgcn_wmma_scale_f32_16x16x128_f8f6f4,   !cast<VOP3PWMMA_Profile>("F32_16X16X128_F8F6F4_SCALE_" # I # "_w32")>;
+    defm : WMMAPat<"V_WMMA_SCALE16_F32_16X16X128_F8F6F4_" # I # "_w32", int_amdgcn_wmma_scale16_f32_16x16x128_f8f6f4, !cast<VOP3PWMMA_Profile>("F32_16X16X128_F8F6F4_SCALE16_" # I # "_w32")>;
+  }
+} // End SubtargetPredicate = HasWMMAN16Insts
+
+let SubtargetPredicate = HasWMMA16x16x128FP8Insts in {
   defm : WMMAPat<"V_WMMA_F16_16X16X128_FP8_FP8_w32",    int_amdgcn_wmma_f16_16x16x128_fp8_fp8,    F16_FP8BF8X128_WMMA_w32>;
   defm : WMMAPat<"V_WMMA_F16_16X16X128_FP8_BF8_w32",    int_amdgcn_wmma_f16_16x16x128_fp8_bf8,    F16_FP8BF8X128_WMMA_w32>;
   defm : WMMAPat<"V_WMMA_F16_16X16X128_BF8_FP8_w32",    int_amdgcn_wmma_f16_16x16x128_bf8_fp8,    F16_FP8BF8X128_WMMA_w32>;
@@ -2453,13 +2465,7 @@ let SubtargetPredicate = HasWMMAN16Insts in {
   defm : WMMAPat<"V_WMMA_F32_16X16X128_FP8_BF8_w32",    int_amdgcn_wmma_f32_16x16x128_fp8_bf8,    F32_FP8BF8X128_WMMA_w32>;
   defm : WMMAPat<"V_WMMA_F32_16X16X128_BF8_FP8_w32",    int_amdgcn_wmma_f32_16x16x128_bf8_fp8,    F32_FP8BF8X128_WMMA_w32>;
   defm : WMMAPat<"V_WMMA_F32_16X16X128_BF8_BF8_w32",    int_amdgcn_wmma_f32_16x16x128_bf8_bf8,    F32_FP8BF8X128_WMMA_w32>;
-
-  foreach I = ["f8_f8", "f8_f6", "f8_f4", "f6_f8", "f6_f6", "f6_f4", "f4_f8", "f4_f6", "f4_f4"] in {
-    defm : WMMAPat<"V_WMMA_F32_16X16X128_F8F6F4_" # I # "_w32",         int_amdgcn_wmma_f32_16x16x128_f8f6f4,         !cast<VOP3PWMMA_Profile>("F32_16X16X128_F8F6F4_" # I # "_w32")>;
-    defm : WMMAPat<"V_WMMA_SCALE_F32_16X16X128_F8F6F4_" # I # "_w32",   int_amdgcn_wmma_scale_f32_16x16x128_f8f6f4,   !cast<VOP3PWMMA_Profile>("F32_16X16X128_F8F6F4_SCALE_" # I # "_w32")>;
-    defm : WMMAPat<"V_WMMA_SCALE16_F32_16X16X128_F8F6F4_" # I # "_w32", int_amdgcn_wmma_scale16_f32_16x16x128_f8f6f4, !cast<VOP3PWMMA_Profile>("F32_16X16X128_F8F6F4_SCALE16_" # I # "_w32")>;
-  }
-} // End SubtargetPredicate = HasWMMAN16Insts
+} // End SubtargetPredicate = HasWMMA16x16x128FP8Insts
 
 let SubtargetPredicate = HasWMMAF4Insts in {
   defm : WMMAPat<"V_WMMA_F32_32X16X128_F4_w32",         int_amdgcn_wmma_f32_32x16x128_f4,         F32_32X16X128_F4_WMMA_w32>;
diff --git a/llvm/test/MC/AMDGPU/gfx1250-strict_err.s b/llvm/test/MC/AMDGPU/gfx1250-strict_err.s
index ab0f05818a5f3..17c7337c8cb25 100644
--- a/llvm/test/MC/AMDGPU/gfx1250-strict_err.s
+++ b/llvm/test/MC/AMDGPU/gfx1250-strict_err.s
@@ -11,6 +11,30 @@ v_wmma_scale_f32_32x16x128_f4 v[0:15], v[8:23], v[0:7], v[0:15], s0, s0
 v_wmma_scale16_f32_32x16x128_f4 v[0:15], v[8:23], v[0:7], v[0:15], s[0:1], s[0:1]
 // GFX1250S-ERR: :[[@LINE-1]]:1: error: instruction not supported on this GPU (gfx1250-strict): v_wmma_scale16_f32_32x16x128_f4
 
+v_wmma_f16_16x16x128_fp8_fp8 v[16:19], v[0:15], v[8:23], v[16:19]
+// GFX1250S-ERR: :[[@LINE-1]]:1: error: instruction not supported on this GPU (gfx1250-strict): v_wmma_f16_16x16x128_fp8_fp8
+
+v_wmma_f16_16x16x128_fp8_bf8 v[16:19], v[0:15], v[8:23], v[16:19]
+// GFX1250S-ERR: :[[@LINE-1]]:1: error: instruction not supported on this GPU (gfx1250-strict): v_wmma_f16_16x16x128_fp8_bf8
+
+v_wmma_f16_16x16x128_bf8_fp8 v[16:19], v[0:15], v[8:23], v[16:19]
+// GFX1250S-ERR: :[[@LINE-1]]:1: error: instruction not supported on this GPU (gfx1250-strict): v_wmma_f16_16x16x128_bf8_fp8
+
+v_wmma_f16_16x16x128_bf8_bf8 v[16:19], v[0:15], v[8:23], v[16:19]
+// GFX1250S-ERR: :[[@LINE-1]]:1: error: instruction not supported on this GPU (gfx1250-strict): v_wmma_f16_16x16x128_bf8_bf8
+
+v_wmma_f32_16...
[truncated]

@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-llvm-ir

Author: Stanislav Mekhanoshin (rampitec)

Changes

Fixes: LCOMPILER-2899


Patch is 20.96 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/228564.diff

6 Files Affected:

  • (modified) clang/include/clang/Basic/BuiltinsAMDGPU.td (+8-8)
  • (modified) clang/test/SemaOpenCL/builtins-amdgcn-error-gfx1250-strict.cl (+11-1)
  • (modified) llvm/include/llvm/IR/IntrinsicsAMDGPU.td (+8-5)
  • (modified) llvm/lib/Target/AMDGPU/AMDGPU.td (+7-1)
  • (modified) llvm/lib/Target/AMDGPU/VOP3PInstructions.td (+18-12)
  • (modified) llvm/test/MC/AMDGPU/gfx1250-strict_err.s (+24)
diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.td b/clang/include/clang/Basic/BuiltinsAMDGPU.td
index c66f8c10a84c7..483df0561fc20 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.td
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.td
@@ -1236,19 +1236,19 @@ def __builtin_amdgcn_wmma_i32_16x16x64_iu8 : AMDGPUBuiltin<"_ExtVector<8, int>(_
   let Documentation = [DocWMMA_i32_16x16x64_iu8_GFX1250];
   let ArgNames = ["a_sign", "a", "b_sign", "b", "c", "matrix_a_reuse", "matrix_b_reuse"];
 }
-def __builtin_amdgcn_wmma_f16_16x16x128_fp8_fp8 : AMDGPUBuiltin<"_ExtVector<8, _Float16>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, _Float16>, _Constant bool, _Constant bool)", [Const], "wmma-n16-insts,wavefrontsize32"> {
+def __builtin_amdgcn_wmma_f16_16x16x128_fp8_fp8 : AMDGPUBuiltin<"_ExtVector<8, _Float16>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, _Float16>, _Constant bool, _Constant bool)", [Const], "wmma-16x16x128fp8-insts,wavefrontsize32"> {
   let Documentation = [DocWMMA_fp8_16x16x128_GFX1250];
   let ArgNames = ["a", "b", "c_mod", "c", "matrix_a_reuse", "matrix_b_reuse"];
 }
-def __builtin_amdgcn_wmma_f16_16x16x128_fp8_bf8 : AMDGPUBuiltin<"_ExtVector<8, _Float16>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, _Float16>, _Constant bool, _Constant bool)", [Const], "wmma-n16-insts,wavefrontsize32"> {
+def __builtin_amdgcn_wmma_f16_16x16x128_fp8_bf8 : AMDGPUBuiltin<"_ExtVector<8, _Float16>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, _Float16>, _Constant bool, _Constant bool)", [Const], "wmma-16x16x128fp8-insts,wavefrontsize32"> {
   let Documentation = [DocWMMA_fp8_16x16x128_GFX1250];
   let ArgNames = ["a", "b", "c_mod", "c", "matrix_a_reuse", "matrix_b_reuse"];
 }
-def __builtin_amdgcn_wmma_f16_16x16x128_bf8_fp8 : AMDGPUBuiltin<"_ExtVector<8, _Float16>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, _Float16>, _Constant bool, _Constant bool)", [Const], "wmma-n16-insts,wavefrontsize32"> {
+def __builtin_amdgcn_wmma_f16_16x16x128_bf8_fp8 : AMDGPUBuiltin<"_ExtVector<8, _Float16>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, _Float16>, _Constant bool, _Constant bool)", [Const], "wmma-16x16x128fp8-insts,wavefrontsize32"> {
   let Documentation = [DocWMMA_fp8_16x16x128_GFX1250];
   let ArgNames = ["a", "b", "c_mod", "c", "matrix_a_reuse", "matrix_b_reuse"];
 }
-def __builtin_amdgcn_wmma_f16_16x16x128_bf8_bf8 : AMDGPUBuiltin<"_ExtVector<8, _Float16>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, _Float16>, _Constant bool, _Constant bool)", [Const], "wmma-n16-insts,wavefrontsize32"> {
+def __builtin_amdgcn_wmma_f16_16x16x128_bf8_bf8 : AMDGPUBuiltin<"_ExtVector<8, _Float16>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, _Float16>, _Constant bool, _Constant bool)", [Const], "wmma-16x16x128fp8-insts,wavefrontsize32"> {
   let Documentation = [DocWMMA_fp8_16x16x128_GFX1250];
   let ArgNames = ["a", "b", "c_mod", "c", "matrix_a_reuse", "matrix_b_reuse"];
 }
@@ -1256,19 +1256,19 @@ def __builtin_amdgcn_wmma_f32_16x16x128_f8f6f4 : AMDGPUBuiltin<"_ExtVector<8, fl
   let Documentation = [DocWMMA_f8f6f4_GFX1250];
   let ArgNames = ["matrix_a_fmt", "a", "matrix_b_fmt", "b", "c_mod", "c"];
 }
-def __builtin_amdgcn_wmma_f32_16x16x128_fp8_fp8 : AMDGPUBuiltin<"_ExtVector<8, float>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, float>, _Constant bool, _Constant bool)", [Const], "wmma-n16-insts,wavefrontsize32"> {
+def __builtin_amdgcn_wmma_f32_16x16x128_fp8_fp8 : AMDGPUBuiltin<"_ExtVector<8, float>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, float>, _Constant bool, _Constant bool)", [Const], "wmma-16x16x128fp8-insts,wavefrontsize32"> {
   let Documentation = [DocWMMA_fp8_16x16x128_GFX1250];
   let ArgNames = ["a", "b", "c_mod", "c", "matrix_a_reuse", "matrix_b_reuse"];
 }
-def __builtin_amdgcn_wmma_f32_16x16x128_fp8_bf8 : AMDGPUBuiltin<"_ExtVector<8, float>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, float>, _Constant bool, _Constant bool)", [Const], "wmma-n16-insts,wavefrontsize32"> {
+def __builtin_amdgcn_wmma_f32_16x16x128_fp8_bf8 : AMDGPUBuiltin<"_ExtVector<8, float>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, float>, _Constant bool, _Constant bool)", [Const], "wmma-16x16x128fp8-insts,wavefrontsize32"> {
   let Documentation = [DocWMMA_fp8_16x16x128_GFX1250];
   let ArgNames = ["a", "b", "c_mod", "c", "matrix_a_reuse", "matrix_b_reuse"];
 }
-def __builtin_amdgcn_wmma_f32_16x16x128_bf8_fp8 : AMDGPUBuiltin<"_ExtVector<8, float>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, float>, _Constant bool, _Constant bool)", [Const], "wmma-n16-insts,wavefrontsize32"> {
+def __builtin_amdgcn_wmma_f32_16x16x128_bf8_fp8 : AMDGPUBuiltin<"_ExtVector<8, float>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, float>, _Constant bool, _Constant bool)", [Const], "wmma-16x16x128fp8-insts,wavefrontsize32"> {
   let Documentation = [DocWMMA_fp8_16x16x128_GFX1250];
   let ArgNames = ["a", "b", "c_mod", "c", "matrix_a_reuse", "matrix_b_reuse"];
 }
-def __builtin_amdgcn_wmma_f32_16x16x128_bf8_bf8 : AMDGPUBuiltin<"_ExtVector<8, float>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, float>, _Constant bool, _Constant bool)", [Const], "wmma-n16-insts,wavefrontsize32"> {
+def __builtin_amdgcn_wmma_f32_16x16x128_bf8_bf8 : AMDGPUBuiltin<"_ExtVector<8, float>(_ExtVector<16, int>, _ExtVector<16, int>, _Constant short, _ExtVector<8, float>, _Constant bool, _Constant bool)", [Const], "wmma-16x16x128fp8-insts,wavefrontsize32"> {
   let Documentation = [DocWMMA_fp8_16x16x128_GFX1250];
   let ArgNames = ["a", "b", "c_mod", "c", "matrix_a_reuse", "matrix_b_reuse"];
 }
diff --git a/clang/test/SemaOpenCL/builtins-amdgcn-error-gfx1250-strict.cl b/clang/test/SemaOpenCL/builtins-amdgcn-error-gfx1250-strict.cl
index 2e031975f09c1..e80de1ab6dd34 100644
--- a/clang/test/SemaOpenCL/builtins-amdgcn-error-gfx1250-strict.cl
+++ b/clang/test/SemaOpenCL/builtins-amdgcn-error-gfx1250-strict.cl
@@ -6,12 +6,22 @@ typedef unsigned int __attribute__((ext_vector_type(2))) uint2;
 typedef unsigned int __attribute__((ext_vector_type(3))) uint3;
 typedef float  v16f  __attribute__((ext_vector_type(16)));
 typedef float  v8f   __attribute__((ext_vector_type(8)));
+typedef half   v8h   __attribute__((ext_vector_type(8)));
 typedef int    v16i   __attribute__((ext_vector_type(16)));
 typedef int    v8i   __attribute__((ext_vector_type(8)));
 
-void test(global v16f* out, v16i a, v8i b, v16f c, int scale_src0, int scale_src1, uint scale, uint src1, uint2 src2, uint3 src3)
+void test(global v16f* out, v16i a, v8i b, v16f c, int scale_src0, int scale_src1, uint scale, uint src1, uint2 src2, uint3 src3,
+          global v8h* out8h, global v8f* out8f, v16i a16i, v16i b16i, v8h c8h, v8f c8f)
 {
   *out = __builtin_amdgcn_wmma_f32_32x16x128_f4(a, b, false, c); // expected-error {{'__builtin_amdgcn_wmma_f32_32x16x128_f4' needs target feature wmma-f4-insts}}
   *out = __builtin_amdgcn_wmma_scale_f32_32x16x128_f4(a, b, false, c, 1, 0, scale_src0, 2, 0, scale_src1, 1, 0); // expected-error {{'__builtin_amdgcn_wmma_scale_f32_32x16x128_f4' needs target feature wmma-f4-insts}}
   *out = __builtin_amdgcn_wmma_scale16_f32_32x16x128_f4(a, b, false, c, 1, 0, scale_src0, 2, 0, scale_src1, 1, 0); // expected-error {{'__builtin_amdgcn_wmma_scale16_f32_32x16x128_f4' needs target feature wmma-f4-insts}}
+  *out8h = __builtin_amdgcn_wmma_f16_16x16x128_fp8_fp8(a16i, b16i, 0, c8h, false, true); // expected-error {{'__builtin_amdgcn_wmma_f16_16x16x128_fp8_fp8' needs target feature wmma-16x16x128fp8-insts}}
+  *out8h = __builtin_amdgcn_wmma_f16_16x16x128_fp8_bf8(a16i, b16i, 0, c8h, false, true); // expected-error {{'__builtin_amdgcn_wmma_f16_16x16x128_fp8_bf8' needs target feature wmma-16x16x128fp8-insts}}
+  *out8h = __builtin_amdgcn_wmma_f16_16x16x128_bf8_fp8(a16i, b16i, 0, c8h, false, true); // expected-error {{'__builtin_amdgcn_wmma_f16_16x16x128_bf8_fp8' needs target feature wmma-16x16x128fp8-insts}}
+  *out8h = __builtin_amdgcn_wmma_f16_16x16x128_bf8_bf8(a16i, b16i, 0, c8h, false, true); // expected-error {{'__builtin_amdgcn_wmma_f16_16x16x128_bf8_bf8' needs target feature wmma-16x16x128fp8-insts}}
+  *out8f = __builtin_amdgcn_wmma_f32_16x16x128_fp8_fp8(a16i, b16i, 0, c8f, false, true); // expected-error {{'__builtin_amdgcn_wmma_f32_16x16x128_fp8_fp8' needs target feature wmma-16x16x128fp8-insts}}
+  *out8f = __builtin_amdgcn_wmma_f32_16x16x128_fp8_bf8(a16i, b16i, 0, c8f, false, true); // expected-error {{'__builtin_amdgcn_wmma_f32_16x16x128_fp8_bf8' needs target feature wmma-16x16x128fp8-insts}}
+  *out8f = __builtin_amdgcn_wmma_f32_16x16x128_bf8_fp8(a16i, b16i, 0, c8f, false, true); // expected-error {{'__builtin_amdgcn_wmma_f32_16x16x128_bf8_fp8' needs target feature wmma-16x16x128fp8-insts}}
+  *out8f = __builtin_amdgcn_wmma_f32_16x16x128_bf8_bf8(a16i, b16i, 0, c8f, false, true); // expected-error {{'__builtin_amdgcn_wmma_f32_16x16x128_bf8_bf8' needs target feature wmma-16x16x128fp8-insts}}
 }
diff --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
index 623e8b7f0647c..fa29d08c91d7b 100644
--- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -4327,6 +4327,13 @@ let TargetFeatures = "wmma-n16-insts" in {
   def int_amdgcn_wmma_f16_16x16x64_fp8_bf8  : AMDGPUWmmaIntrinsicModsC<llvm_anyint_ty, llvm_anyfloat_ty>;
   def int_amdgcn_wmma_f16_16x16x64_bf8_fp8  : AMDGPUWmmaIntrinsicModsC<llvm_anyint_ty, llvm_anyfloat_ty>;
   def int_amdgcn_wmma_f16_16x16x64_bf8_bf8  : AMDGPUWmmaIntrinsicModsC<llvm_anyint_ty, llvm_anyfloat_ty>;
+  def int_amdgcn_wmma_i32_16x16x64_iu8      : AMDGPUWmmaIntrinsicModsABClamp<llvm_anyint_ty, llvm_anyint_ty>;
+  def int_amdgcn_wmma_f32_16x16x128_f8f6f4  : AMDGPUWmmaIntrinsicModsC_MatrixFMT;
+  def int_amdgcn_wmma_scale_f32_16x16x128_f8f6f4   : AMDGPUWmmaScaleIntrinsicModsC<llvm_i32_ty>;
+  def int_amdgcn_wmma_scale16_f32_16x16x128_f8f6f4 : AMDGPUWmmaScaleIntrinsicModsC<llvm_i64_ty>;
+} // End TargetFeatures = "wmma-n16-insts"
+
+let TargetFeatures = "wmma-16x16x128fp8-insts" in {
   def int_amdgcn_wmma_f16_16x16x128_fp8_fp8 : AMDGPUWmmaIntrinsicModsC<llvm_anyint_ty, llvm_anyfloat_ty>;
   def int_amdgcn_wmma_f16_16x16x128_fp8_bf8 : AMDGPUWmmaIntrinsicModsC<llvm_anyint_ty, llvm_anyfloat_ty>;
   def int_amdgcn_wmma_f16_16x16x128_bf8_fp8 : AMDGPUWmmaIntrinsicModsC<llvm_anyint_ty, llvm_anyfloat_ty>;
@@ -4335,11 +4342,7 @@ let TargetFeatures = "wmma-n16-insts" in {
   def int_amdgcn_wmma_f32_16x16x128_fp8_bf8 : AMDGPUWmmaIntrinsicModsC<llvm_anyint_ty, llvm_anyfloat_ty>;
   def int_amdgcn_wmma_f32_16x16x128_bf8_fp8 : AMDGPUWmmaIntrinsicModsC<llvm_anyint_ty, llvm_anyfloat_ty>;
   def int_amdgcn_wmma_f32_16x16x128_bf8_bf8 : AMDGPUWmmaIntrinsicModsC<llvm_anyint_ty, llvm_anyfloat_ty>;
-  def int_amdgcn_wmma_i32_16x16x64_iu8      : AMDGPUWmmaIntrinsicModsABClamp<llvm_anyint_ty, llvm_anyint_ty>;
-  def int_amdgcn_wmma_f32_16x16x128_f8f6f4  : AMDGPUWmmaIntrinsicModsC_MatrixFMT;
-  def int_amdgcn_wmma_scale_f32_16x16x128_f8f6f4   : AMDGPUWmmaScaleIntrinsicModsC<llvm_i32_ty>;
-  def int_amdgcn_wmma_scale16_f32_16x16x128_f8f6f4 : AMDGPUWmmaScaleIntrinsicModsC<llvm_i64_ty>;
-} // End TargetFeatures = "wmma-n16-insts"
+}
 
 let TargetFeatures = "wmma-f4-insts" in {
   def int_amdgcn_wmma_f32_32x16x128_f4       : AMDGPUWmmaIntrinsicF4ModsC<llvm_anyint_ty, llvm_anyint_ty, llvm_anyfloat_ty>;
diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.td b/llvm/lib/Target/AMDGPU/AMDGPU.td
index 90a0871ff3669..d552eae9c08d3 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.td
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.td
@@ -1003,6 +1003,10 @@ defm WMMAF4Insts : AMDGPUSubtargetFeature<"wmma-f4-insts",
   "Has WMMA_*_F4 instructions"
 >;
 
+defm WMMA16x16x128FP8Insts : AMDGPUSubtargetFeature<"wmma-16x16x128fp8-insts",
+  "Has 16x16x128 FP8/BF8 WMMA instructions"
+>;
+
 defm SWMMACGfx1200Insts : AMDGPUSubtargetFeature<"swmmac-gfx1200-insts",
   "Has GFX1200 SWMMAC instructions"
 >;
@@ -2598,6 +2602,7 @@ def FeatureISAVersion12_50 : FeatureSet<
    FeatureLDSBankCount64,
    FeatureWMMAN16Insts,
    FeatureWMMAF4Insts,
+   FeatureWMMA16x16x128FP8Insts,
    FeatureVOP3PX2IncrementsVaVdstTwice,
    FeatureSetregVGPRMSBFixup,
    FeatureCubeInsts,
@@ -2634,6 +2639,7 @@ def FeatureISAVersion12_51 : FeatureSet<
    FeatureLDSBankCount64,
    FeatureWMMAN16Insts,
    FeatureWMMAF4Insts,
+   FeatureWMMA16x16x128FP8Insts,
    FeatureFullRate64Ops,
    FeatureVOP3PX2IncrementsVaVdstTwice,
    FeatureDPALU_DPP,
@@ -3385,7 +3391,7 @@ def AMDGPUFrontendVisibleFeatures {
   FeatureTDMInsts, FeatureTanhInsts, FeatureTensorCvtLutInsts,
   FeatureTransposeLoadF4F6Insts, FeatureVMemToLDSLoad, FeatureVmemPrefInsts,
   FeatureWaveMatchInsts, FeatureWMMA128bInsts, FeatureWMMA256bInsts,
-  FeatureWMMAN16Insts, FeatureWMMAF4Insts, FeatureXF32Insts,
+  FeatureWMMAN16Insts, FeatureWMMAF4Insts, FeatureWMMA16x16x128FP8Insts, FeatureXF32Insts,
   FeatureWavefrontSize32, FeatureWavefrontSize64, FeatureSupportsWGP,
   FeatureSupportsWave32, FeatureFastFMAF32, FeatureFastDenormalF32,
   FeatureSupportsXNACK, FeatureSupportsSRAMECC, FeatureXNACKOnOffModes,
diff --git a/llvm/lib/Target/AMDGPU/VOP3PInstructions.td b/llvm/lib/Target/AMDGPU/VOP3PInstructions.td
index 7d73bb328c590..7a0f162242e1c 100644
--- a/llvm/lib/Target/AMDGPU/VOP3PInstructions.td
+++ b/llvm/lib/Target/AMDGPU/VOP3PInstructions.td
@@ -2243,6 +2243,13 @@ let WaveSizePredicate = isWave32 in {
       defm V_WMMA_I32_16X16X64_IU8_w32      : WMMAInstGFX12<"v_wmma_i32_16x16x64_iu8",      I32_IU8X64_WMMA_w32, "_w32">;
       defm V_WMMA_F32_16X16X32_F16_w32      : WMMAInstGFX12<"v_wmma_f32_16x16x32_f16",      F32_F16X32_WMMA_w32, "_w32">;
       defm V_WMMA_F16_16X16X32_F16_w32      : WMMAInstGFX12<"v_wmma_f16_16x16x32_f16",      F16_F16X32_WMMA_w32, "_w32">;
+
+      defm V_WMMA_F32_16X16X128_F8F6F4         : WMMAInst_SrcFormats_mc<"v_wmma_f32_16x16x128_f8f6f4", "F32_16X16X128_F8F6F4">;
+      defm V_WMMA_SCALE_F32_16X16X128_F8F6F4   : WMMAInst_SrcFormats_mc<"v_wmma_scale_f32_16x16x128_f8f6f4", "F32_16X16X128_F8F6F4_SCALE">;
+      defm V_WMMA_SCALE16_F32_16X16X128_F8F6F4 : WMMAInst_SrcFormats_mc<"v_wmma_scale16_f32_16x16x128_f8f6f4", "F32_16X16X128_F8F6F4_SCALE16">;
+    } // End SubtargetPredicate = HasWMMAN16Insts
+
+    let SubtargetPredicate = HasWMMA16x16x128FP8Insts in {
       defm V_WMMA_F16_16X16X128_FP8_FP8_w32 : WMMAInstGFX12<"v_wmma_f16_16x16x128_fp8_fp8", F16_FP8BF8X128_WMMA_w32, "_w32">;
       defm V_WMMA_F16_16X16X128_FP8_BF8_w32 : WMMAInstGFX12<"v_wmma_f16_16x16x128_fp8_bf8", F16_FP8BF8X128_WMMA_w32, "_w32">;
       defm V_WMMA_F16_16X16X128_BF8_FP8_w32 : WMMAInstGFX12<"v_wmma_f16_16x16x128_bf8_fp8", F16_FP8BF8X128_WMMA_w32, "_w32">;
@@ -2251,11 +2258,7 @@ let WaveSizePredicate = isWave32 in {
       defm V_WMMA_F32_16X16X128_FP8_BF8_w32 : WMMAInstGFX12<"v_wmma_f32_16x16x128_fp8_bf8", F32_FP8BF8X128_WMMA_w32, "_w32">;
       defm V_WMMA_F32_16X16X128_BF8_FP8_w32 : WMMAInstGFX12<"v_wmma_f32_16x16x128_bf8_fp8", F32_FP8BF8X128_WMMA_w32, "_w32">;
       defm V_WMMA_F32_16X16X128_BF8_BF8_w32 : WMMAInstGFX12<"v_wmma_f32_16x16x128_bf8_bf8", F32_FP8BF8X128_WMMA_w32, "_w32">;
-
-      defm V_WMMA_F32_16X16X128_F8F6F4         : WMMAInst_SrcFormats_mc<"v_wmma_f32_16x16x128_f8f6f4", "F32_16X16X128_F8F6F4">;
-      defm V_WMMA_SCALE_F32_16X16X128_F8F6F4   : WMMAInst_SrcFormats_mc<"v_wmma_scale_f32_16x16x128_f8f6f4", "F32_16X16X128_F8F6F4_SCALE">;
-      defm V_WMMA_SCALE16_F32_16X16X128_F8F6F4 : WMMAInst_SrcFormats_mc<"v_wmma_scale16_f32_16x16x128_f8f6f4", "F32_16X16X128_F8F6F4_SCALE16">;
-    } // End SubtargetPredicate = HasWMMAN16Insts
+    } // End SubtargetPredicate = HasWMMA16x16x128FP8Insts
 
     let SubtargetPredicate = HasWMMAF4Insts in {
       defm V_WMMA_F32_32X16X128_F4_w32      : WMMAInstGFX12<"v_wmma_f32_32x16x128_f4",      F32_32X16X128_F4_WMMA_w32, "_w32">;
@@ -2445,6 +2448,15 @@ let SubtargetPredicate = HasWMMAN16Insts in {
   defm : WMMAPat<"V_WMMA_I32_16X16X64_IU8_w32",         int_amdgcn_wmma_i32_16x16x64_iu8,         I32_IU8X64_WMMA_w32>;
   defm : WMMAPat<"V_WMMA_F32_16X16X32_F16_w32",         int_amdgcn_wmma_f32_16x16x32_f16,         F32_F16X32_WMMA_w32>;
   defm : WMMAPat<"V_WMMA_F16_16X16X32_F16_w32",         int_amdgcn_wmma_f16_16x16x32_f16,         F16_F16X32_WMMA_w32>;
+
+  foreach I = ["f8_f8", "f8_f6", "f8_f4", "f6_f8", "f6_f6", "f6_f4", "f4_f8", "f4_f6", "f4_f4"] in {
+    defm : WMMAPat<"V_WMMA_F32_16X16X128_F8F6F4_" # I # "_w32",         int_amdgcn_wmma_f32_16x16x128_f8f6f4,         !cast<VOP3PWMMA_Profile>("F32_16X16X128_F8F6F4_" # I # "_w32")>;
+    defm : WMMAPat<"V_WMMA_SCALE_F32_16X16X128_F8F6F4_" # I # "_w32",   int_amdgcn_wmma_scale_f32_16x16x128_f8f6f4,   !cast<VOP3PWMMA_Profile>("F32_16X16X128_F8F6F4_SCALE_" # I # "_w32")>;
+    defm : WMMAPat<"V_WMMA_SCALE16_F32_16X16X128_F8F6F4_" # I # "_w32", int_amdgcn_wmma_scale16_f32_16x16x128_f8f6f4, !cast<VOP3PWMMA_Profile>("F32_16X16X128_F8F6F4_SCALE16_" # I # "_w32")>;
+  }
+} // End SubtargetPredicate = HasWMMAN16Insts
+
+let SubtargetPredicate = HasWMMA16x16x128FP8Insts in {
   defm : WMMAPat<"V_WMMA_F16_16X16X128_FP8_FP8_w32",    int_amdgcn_wmma_f16_16x16x128_fp8_fp8,    F16_FP8BF8X128_WMMA_w32>;
   defm : WMMAPat<"V_WMMA_F16_16X16X128_FP8_BF8_w32",    int_amdgcn_wmma_f16_16x16x128_fp8_bf8,    F16_FP8BF8X128_WMMA_w32>;
   defm : WMMAPat<"V_WMMA_F16_16X16X128_BF8_FP8_w32",    int_amdgcn_wmma_f16_16x16x128_bf8_fp8,    F16_FP8BF8X128_WMMA_w32>;
@@ -2453,13 +2465,7 @@ let SubtargetPredicate = HasWMMAN16Insts in {
   defm : WMMAPat<"V_WMMA_F32_16X16X128_FP8_BF8_w32",    int_amdgcn_wmma_f32_16x16x128_fp8_bf8,    F32_FP8BF8X128_WMMA_w32>;
   defm : WMMAPat<"V_WMMA_F32_16X16X128_BF8_FP8_w32",    int_amdgcn_wmma_f32_16x16x128_bf8_fp8,    F32_FP8BF8X128_WMMA_w32>;
   defm : WMMAPat<"V_WMMA_F32_16X16X128_BF8_BF8_w32",    int_amdgcn_wmma_f32_16x16x128_bf8_bf8,    F32_FP8BF8X128_WMMA_w32>;
-
-  foreach I = ["f8_f8", "f8_f6", "f8_f4", "f6_f8", "f6_f6", "f6_f4", "f4_f8", "f4_f6", "f4_f4"] in {
-    defm : WMMAPat<"V_WMMA_F32_16X16X128_F8F6F4_" # I # "_w32",         int_amdgcn_wmma_f32_16x16x128_f8f6f4,         !cast<VOP3PWMMA_Profile>("F32_16X16X128_F8F6F4_" # I # "_w32")>;
-    defm : WMMAPat<"V_WMMA_SCALE_F32_16X16X128_F8F6F4_" # I # "_w32",   int_amdgcn_wmma_scale_f32_16x16x128_f8f6f4,   !cast<VOP3PWMMA_Profile>("F32_16X16X128_F8F6F4_SCALE_" # I # "_w32")>;
-    defm : WMMAPat<"V_WMMA_SCALE16_F32_16X16X128_F8F6F4_" # I # "_w32", int_amdgcn_wmma_scale16_f32_16x16x128_f8f6f4, !cast<VOP3PWMMA_Profile>("F32_16X16X128_F8F6F4_SCALE16_" # I # "_w32")>;
-  }
-} // End SubtargetPredicate = HasWMMAN16Insts
+} // End SubtargetPredicate = HasWMMA16x16x128FP8Insts
 
 let SubtargetPredicate = HasWMMAF4Insts in {
   defm : WMMAPat<"V_WMMA_F32_32X16X128_F4_w32",         int_amdgcn_wmma_f32_32x16x128_f4,         F32_32X16X128_F4_WMMA_w32>;
diff --git a/llvm/test/MC/AMDGPU/gfx1250-strict_err.s b/llvm/test/MC/AMDGPU/gfx1250-strict_err.s
index ab0f05818a5f3..17c7337c8cb25 100644
--- a/llvm/test/MC/AMDGPU/gfx1250-strict_err.s
+++ b/llvm/test/MC/AMDGPU/gfx1250-strict_err.s
@@ -11,6 +11,30 @@ v_wmma_scale_f32_32x16x128_f4 v[0:15], v[8:23], v[0:7], v[0:15], s0, s0
 v_wmma_scale16_f32_32x16x128_f4 v[0:15], v[8:23], v[0:7], v[0:15], s[0:1], s[0:1]
 // GFX1250S-ERR: :[[@LINE-1]]:1: error: instruction not supported on this GPU (gfx1250-strict): v_wmma_scale16_f32_32x16x128_f4
 
+v_wmma_f16_16x16x128_fp8_fp8 v[16:19], v[0:15], v[8:23], v[16:19]
+// GFX1250S-ERR: :[[@LINE-1]]:1: error: instruction not supported on this GPU (gfx1250-strict): v_wmma_f16_16x16x128_fp8_fp8
+
+v_wmma_f16_16x16x128_fp8_bf8 v[16:19], v[0:15], v[8:23], v[16:19]
+// GFX1250S-ERR: :[[@LINE-1]]:1: error: instruction not supported on this GPU (gfx1250-strict): v_wmma_f16_16x16x128_fp8_bf8
+
+v_wmma_f16_16x16x128_bf8_fp8 v[16:19], v[0:15], v[8:23], v[16:19]
+// GFX1250S-ERR: :[[@LINE-1]]:1: error: instruction not supported on this GPU (gfx1250-strict): v_wmma_f16_16x16x128_bf8_fp8
+
+v_wmma_f16_16x16x128_bf8_bf8 v[16:19], v[0:15], v[8:23], v[16:19]
+// GFX1250S-ERR: :[[@LINE-1]]:1: error: instruction not supported on this GPU (gfx1250-strict): v_wmma_f16_16x16x128_bf8_bf8
+
+v_wmma_f32_16...
[truncated]

@rampitec
rampitec merged commit 6fb8776 into main Oct 2, 2026
10 of 11 checks passed
@rampitec
rampitec deleted the users/rampitec/disable-16x16x128-fp8-on-strict branch October 2, 2026 21:24
Expertcoderz pushed a commit to Expertcoderz/llvm-project that referenced this pull request Oct 3, 2026
ronlieb added a commit that referenced this pull request Oct 4, 2026
…fx1250-strict" (#228932)

Reverts #228564

breaks build of hipCUB for gfx1250*   LCOMPILER-2911
llvm-sync Bot pushed a commit to arm/arm-toolchain that referenced this pull request Oct 4, 2026
…[BF]P8 on gfx1250-strict" (#228932)

Reverts llvm/llvm-project#228564

breaks build of hipCUB for gfx1250*   LCOMPILER-2911
llvm-upstreamsync Bot pushed a commit to qualcomm/cpullvm-toolchain that referenced this pull request Oct 4, 2026
…[BF]P8 on gfx1250-strict" (#228932)

Reverts llvm/llvm-project#228564

breaks build of hipCUB for gfx1250*   LCOMPILER-2911
gandhi56 pushed a commit that referenced this pull request Oct 7, 2026
gandhi56 pushed a commit that referenced this pull request Oct 7, 2026
…fx1250-strict" (#228932)

Reverts #228564

breaks build of hipCUB for gfx1250*   LCOMPILER-2911
afagaj added a commit to ROCm/rocm-libraries that referenced this pull request Dec 2, 2026
)

## Motivation

The CK build fails for `gfx1250-strict` with current compilers:

```
ck_tile/core/arch/mma/wmma/wmma_gfx12.hpp:1027:17: error: '__builtin_amdgcn_wmma_f32_16x16x128_fp8_fp8'
needs target feature wmma-16x16x128fp8-insts,wavefrontsize32
```

gfx1250-strict (A0) has no
`V_WMMA_F{16,32}_16X16X128_{FP8,BF8}_{FP8,BF8}`. LLVM now gates those 8
builtins on `wmma-16x16x128fp8-insts`, which only gfx1250 has:
llvm/llvm-project#228564, re-landed as llvm/llvm-project#229044
(LCOMPILER-2899). CK and CK Tile guard the 20 call sites with
`__gfx125__`, which also covers gfx1250-strict. Older compilers accepted
the builtins on strict and emitted instructions that A0 does not
support.

JIRA ID : ROCM-35020

## Technical Details

All 20 call sites now go through one helper per library:

| Library | Helper | Call sites |
|---|---|---|
| CK Tile | `wmma_{f32,f16}_16x16x128_f8` in
`ck_tile/core/arch/mma/wmma/wmma_gfx1250_f8_16x16x128.hpp` (new) |
`wmma_gfx12.hpp` (8), `warp_gemm_attribute_wmma_impl_8bit_traits.hpp`
(4) |
| CK | `wmma_{f32,f16}_16x16x128_f8_gfx125` in `ck/utility/amd_wmma.hpp`
| `amd_wmma.hpp` (8) |

- **gfx1250, gfx1251:** unchanged. The helpers emit the native builtins,
and the warp GEMM traits keep their `reuse_a` / `reuse_b` flags. gfx1250
ISA is identical before and after.
- **gfx1250-strict, f32 output:**
`__builtin_amdgcn_wmma_scale_f32_16x16x128_f8f6f4` with the FP8 (0) /
BF8 (1) format flags and an explicit E8M0 scale of 1.0 (`0x7F7F7F7F`)
for A and B, plus the reuse hints. It reads A and B in the same register
layout as the native instructions.
- Why not the unscaled `__builtin_amdgcn_wmma_f32_16x16x128_f8f6f4`: on
gfx1250-strict LLVM rewrites it to the scaled instruction with a scale
of 0 (llvm/llvm-project#230253). 0 means 1.0 only as an inline constant.
At -O0 it is placed in a VGPR, where E8M0 0 is 2^-127, and the result is
C instead of A*B + C. An explicit 1.0 is correct at every optimization
level.
- **gfx1250-strict, f16 output:** F8F6F4 has no f16-output form, so the
helper converts C to f32, runs the f32 path, and rounds once to f16.
Cost per f16 WMMA on strict: 8 `v_cvt_f32_f16` and 4 `v_cvt_pk_f16_f32`,
and C takes 8 VGPRs instead of 4.
- The op types (`amdgcn_mma` specializations, `WmmaTraits`) do not
change, so host and device passes still select the same MmaOp (see the
comment at the top of the GFX1250 section in `wmma_gfx12.hpp`). The
`instruction_name` strings of the eight CK Tile ops now name both
instructions.

**Tests** (CK and CK Tile tested separately; they do not depend on each
other):

| Test | Library | What |
|---|---|---|
| `test_ck_tile_wmma_f8_16x16x128_gfx125` | CK Tile | compile-only, 12
call sites, every gfx125 target the compiler supports, whatever
`GPU_TARGETS` is |
| `test_ck_wmma_f8_16x16x128_gfx125` | CK | compile-only, 8 call sites,
same |
| `test_wmma_op_f8_16x16x128_o0` | CK | the existing runtime check
against a CPU reference (`test_wmma_op`, 16x16x128 cases), built at -O0
|

CK CI's daily gfx1250-strict build only builds the MIOpen and hipTensor
instance libraries, not tests.

## Test Plan

1. Device-compile all 20 wrappers for gfx1250 and gfx1250-strict with
ROCm LLVM `d196b6e0be62` (TheRock Multi-Arch CI run
[45807908974](https://github.com/ROCm/TheRock/actions/runs/45807908974)),
with `develop` and with this PR, at -O0 and -O3.
2. CK CMake build with `-DGPU_TARGETS=gfx1250-strict` and the same
compiler: all three new tests plus `test_amdgcn_mma_layout_gfx1250`,
`test_tile_gemm_quant_pipelines_gfx1250` and `test_wmma_op`.
3. Runtime on the rocJITsu gfx1250 emulator (B0 model). The emulator
cannot run gfx1250-strict code objects, so the strict path was forced on
in a scratch copy of each helper and built for gfx1250:
- the strict path vs the native instruction, at -O0 and -O3, all 4 A/B
type pairs, on narrow-exponent data (every f32 sum exact) and on
full-range finite data; and, for comparison, the unscaled F8F6F4 builtin
as LLVM lowers it on strict (scale 0);
- `test_wmma_op_f8_16x16x128_o0` with the strict path forced on, using
the explicit 1.0 scale and using a scale of 0, to show that the -O0 test
detects a wrong scale.

## Test Result

1. With `develop`, gfx1250-strict fails with 20 errors (one per call
site) and gfx1250 passes. With this PR, both pass at -O0 and -O3.
gfx1250-strict emits only `v_wmma_scale_f32_16x16x128_f8f6f4`, always
with the 1.0 scale.
2. All targets build. Against the `develop` headers, the compile-only CK
Tile test fails with 12 errors and the CK test with 8.
3. Emulator:

   | Strict path, vs native | Narrow-exponent data | Full-range data |
   |---|---|---|
| explicit scale 1.0 (this PR), -O0 and -O3 | f32 and f16 bit-identical
| f16 bit-identical; f32 differs in 157-193 of 256 elements per pair,
max relative difference 4.8e-5 |
| unscaled builtin (LLVM promotes it with scale 0), -O3 | bit-identical
| same as explicit scale 1.0 |
| unscaled builtin (LLVM promotes it with scale 0), -O0 | all 256
outputs wrong, every output equals C | not measured |

The full-range f32 difference is far below FP8/BF8 input precision. The
emulator models B0, so this does not prove A0 behaviour.

`test_wmma_op_f8_16x16x128_o0` with the strict path forced on: 8/8 pass
with the explicit 1.0 scale; 8/8 fail with a scale of 0.

4. A0 hardware (gfx1250-strict): one scaled F8F6F4 WMMA with the scale 0
or 1.0, as a literal and as a runtime value, at -O0 and -O3. A scale of
0 gives C whenever it is in a register (literal at -O0, runtime value at
both levels); 1.0 is correct in every case. Reproducer and output in the
review thread.

Not covered: CK itself on A0 hardware, and the full CK test suite on
gfx1250-strict.

Separately, the LLVM rewrite in llvm/llvm-project#230253 should not
depend on the scale staying an inline constant; that is a compiler
issue, to be reported to LLVM separately.

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/TheRock/blob/main/GOVERNANCE.md#pull-requests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
assistant-librarian Bot pushed a commit to ROCm/composable_kernel that referenced this pull request Dec 2, 2026
fix(ck,ck_tile): build FP8/BF8 16x16x128 WMMA for
 gfx1250-strict (#16834)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

## Motivation

The CK build fails for `gfx1250-strict` with current compilers:

```
ck_tile/core/arch/mma/wmma/wmma_gfx12.hpp:1027:17: error: '__builtin_amdgcn_wmma_f32_16x16x128_fp8_fp8'
needs target feature wmma-16x16x128fp8-insts,wavefrontsize32
```

gfx1250-strict (A0) has no
`V_WMMA_F{16,32}_16X16X128_{FP8,BF8}_{FP8,BF8}`. LLVM now gates those 8
builtins on `wmma-16x16x128fp8-insts`, which only gfx1250 has:
llvm/llvm-project#228564, re-landed as llvm/llvm-project#229044
(LCOMPILER-2899). CK and CK Tile guard the 20 call sites with
`__gfx125__`, which also covers gfx1250-strict. Older compilers accepted
the builtins on strict and emitted instructions that A0 does not
support.

JIRA ID : ROCM-35020

## Technical Details

All 20 call sites now go through one helper per library:

| Library | Helper | Call sites |
|---|---|---|
| CK Tile | `wmma_{f32,f16}_16x16x128_f8` in
`ck_tile/core/arch/mma/wmma/wmma_gfx1250_f8_16x16x128.hpp` (new) |
`wmma_gfx12.hpp` (8), `warp_gemm_attribute_wmma_impl_8bit_traits.hpp`
(4) |
| CK | `wmma_{f32,f16}_16x16x128_f8_gfx125` in `ck/utility/amd_wmma.hpp`
| `amd_wmma.hpp` (8) |

- **gfx1250, gfx1251:** unchanged. The helpers emit the native builtins,
and the warp GEMM traits keep their `reuse_a` / `reuse_b` flags. gfx1250
ISA is identical before and after.
- **gfx1250-strict, f32 output:**
`__builtin_amdgcn_wmma_scale_f32_16x16x128_f8f6f4` with the FP8 (0) /
BF8 (1) format flags and an explicit E8M0 scale of 1.0 (`0x7F7F7F7F`)
for A and B, plus the reuse hints. It reads A and B in the same register
layout as the native instructions.
- Why not the unscaled `__builtin_amdgcn_wmma_f32_16x16x128_f8f6f4`: on
gfx1250-strict LLVM rewrites it to the scaled instruction with a scale
of 0 (llvm/llvm-project#230253). 0 means 1.0 only as an inline constant.
At -O0 it is placed in a VGPR, where E8M0 0 is 2^-127, and the result is
C instead of A*B + C. An explicit 1.0 is correct at every optimization
level.
- **gfx1250-strict, f16 output:** F8F6F4 has no f16-output form, so the
helper converts C to f32, runs the f32 path, and rounds once to f16.
Cost per f16 WMMA on strict: 8 `v_cvt_f32_f16` and 4 `v_cvt_pk_f16_f32`,
and C takes 8 VGPRs instead of 4.
- The op types (`amdgcn_mma` specializations, `WmmaTraits`) do not
change, so host and device passes still select the same MmaOp (see the
comment at the top of the GFX1250 section in `wmma_gfx12.hpp`). The
`instruction_name` strings of the eight CK Tile ops now name both
instructions.

**Tests** (CK and CK Tile tested separately; they do not depend on each
other):

| Test | Library | What |
|---|---|---|
| `test_ck_tile_wmma_f8_16x16x128_gfx125` | CK Tile | compile-only, 12
call sites, every gfx125 target the compiler supports, whatever
`GPU_TARGETS` is |
| `test_ck_wmma_f8_16x16x128_gfx125` | CK | compile-only, 8 call sites,
same |
| `test_wmma_op_f8_16x16x128_o0` | CK | the existing runtime check
against a CPU reference (`test_wmma_op`, 16x16x128 cases), built at -O0
|

CK CI's daily gfx1250-strict build only builds the MIOpen and hipTensor
instance libraries, not tests.

## Test Plan

1. Device-compile all 20 wrappers for gfx1250 and gfx1250-strict with
ROCm LLVM `d196b6e0be62` (TheRock Multi-Arch CI run
[45807908974](https://github.com/ROCm/TheRock/actions/runs/45807908974)),
with `develop` and with this PR, at -O0 and -O3.
2. CK CMake build with `-DGPU_TARGETS=gfx1250-strict` and the same
compiler: all three new tests plus `test_amdgcn_mma_layout_gfx1250`,
`test_tile_gemm_quant_pipelines_gfx1250` and `test_wmma_op`.
3. Runtime on the rocJITsu gfx1250 emulator (B0 model). The emulator
cannot run gfx1250-strict code objects, so the strict path was forced on
in a scratch copy of each helper and built for gfx1250:
- the strict path vs the native instruction, at -O0 and -O3, all 4 A/B
type pairs, on narrow-exponent data (every f32 sum exact) and on
full-range finite data; and, for comparison, the unscaled F8F6F4 builtin
as LLVM lowers it on strict (scale 0);
- `test_wmma_op_f8_16x16x128_o0` with the strict path forced on, using
the explicit 1.0 scale and using a scale of 0, to show that the -O0 test
detects a wrong scale.

## Test Result

1. With `develop`, gfx1250-strict fails with 20 errors (one per call
site) and gfx1250 passes. With this PR, both pass at -O0 and -O3.
gfx1250-strict emits only `v_wmma_scale_f32_16x16x128_f8f6f4`, always
with the 1.0 scale.
2. All targets build. Against the `develop` headers, the compile-only CK
Tile test fails with 12 errors and the CK test with 8.
3. Emulator:

   | Strict path, vs native | Narrow-exponent data | Full-range data |
   |---|---|---|
| explicit scale 1.0 (this PR), -O0 and -O3 | f32 and f16 bit-identical
| f16 bit-identical; f32 differs in 157-193 of 256 elements per pair,
max relative difference 4.8e-5 |
| unscaled builtin (LLVM promotes it with scale 0), -O3 | bit-identical
| same as explicit scale 1.0 |
| unscaled builtin (LLVM promotes it with scale 0), -O0 | all 256
outputs wrong, every output equals C | not measured |

The full-range f32 difference is far below FP8/BF8 input precision. The
emulator models B0, so this does not prove A0 behaviour.

`test_wmma_op_f8_16x16x128_o0` with the strict path forced on: 8/8 pass
with the explicit 1.0 scale; 8/8 fail with a scale of 0.

4. A0 hardware (gfx1250-strict): one scaled F8F6F4 WMMA with the scale 0
or 1.0, as a literal and as a runtime value, at -O0 and -O3. A scale of
0 gives C whenever it is in a register (literal at -O0, runtime value at
both levels); 1.0 is correct in every case. Reproducer and output in the
review thread.

Not covered: CK itself on A0 hardware, and the full CK test suite on
gfx1250-strict.

Separately, the LLVM rewrite in llvm/llvm-project#230253 should not
depend on the scale staying an inline constant; that is a compiler
issue, to be reported to LLVM separately.

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/TheRock/blob/main/GOVERNANCE.md#pull-requests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
JiaLuo-CAN pushed a commit to ROCm/rocm-libraries that referenced this pull request Dec 2, 2026
)

## Motivation

The CK build fails for `gfx1250-strict` with current compilers:

```
ck_tile/core/arch/mma/wmma/wmma_gfx12.hpp:1027:17: error: '__builtin_amdgcn_wmma_f32_16x16x128_fp8_fp8'
needs target feature wmma-16x16x128fp8-insts,wavefrontsize32
```

gfx1250-strict (A0) has no
`V_WMMA_F{16,32}_16X16X128_{FP8,BF8}_{FP8,BF8}`. LLVM now gates those 8
builtins on `wmma-16x16x128fp8-insts`, which only gfx1250 has:
llvm/llvm-project#228564, re-landed as llvm/llvm-project#229044
(LCOMPILER-2899). CK and CK Tile guard the 20 call sites with
`__gfx125__`, which also covers gfx1250-strict. Older compilers accepted
the builtins on strict and emitted instructions that A0 does not
support.

JIRA ID : ROCM-35020

## Technical Details

All 20 call sites now go through one helper per library:

| Library | Helper | Call sites |
|---|---|---|
| CK Tile | `wmma_{f32,f16}_16x16x128_f8` in
`ck_tile/core/arch/mma/wmma/wmma_gfx1250_f8_16x16x128.hpp` (new) |
`wmma_gfx12.hpp` (8), `warp_gemm_attribute_wmma_impl_8bit_traits.hpp`
(4) |
| CK | `wmma_{f32,f16}_16x16x128_f8_gfx125` in `ck/utility/amd_wmma.hpp`
| `amd_wmma.hpp` (8) |

- **gfx1250, gfx1251:** unchanged. The helpers emit the native builtins,
and the warp GEMM traits keep their `reuse_a` / `reuse_b` flags. gfx1250
ISA is identical before and after.
- **gfx1250-strict, f32 output:**
`__builtin_amdgcn_wmma_scale_f32_16x16x128_f8f6f4` with the FP8 (0) /
BF8 (1) format flags and an explicit E8M0 scale of 1.0 (`0x7F7F7F7F`)
for A and B, plus the reuse hints. It reads A and B in the same register
layout as the native instructions.
- Why not the unscaled `__builtin_amdgcn_wmma_f32_16x16x128_f8f6f4`: on
gfx1250-strict LLVM rewrites it to the scaled instruction with a scale
of 0 (llvm/llvm-project#230253). 0 means 1.0 only as an inline constant.
At -O0 it is placed in a VGPR, where E8M0 0 is 2^-127, and the result is
C instead of A*B + C. An explicit 1.0 is correct at every optimization
level.
- **gfx1250-strict, f16 output:** F8F6F4 has no f16-output form, so the
helper converts C to f32, runs the f32 path, and rounds once to f16.
Cost per f16 WMMA on strict: 8 `v_cvt_f32_f16` and 4 `v_cvt_pk_f16_f32`,
and C takes 8 VGPRs instead of 4.
- The op types (`amdgcn_mma` specializations, `WmmaTraits`) do not
change, so host and device passes still select the same MmaOp (see the
comment at the top of the GFX1250 section in `wmma_gfx12.hpp`). The
`instruction_name` strings of the eight CK Tile ops now name both
instructions.

**Tests** (CK and CK Tile tested separately; they do not depend on each
other):

| Test | Library | What |
|---|---|---|
| `test_ck_tile_wmma_f8_16x16x128_gfx125` | CK Tile | compile-only, 12
call sites, every gfx125 target the compiler supports, whatever
`GPU_TARGETS` is |
| `test_ck_wmma_f8_16x16x128_gfx125` | CK | compile-only, 8 call sites,
same |
| `test_wmma_op_f8_16x16x128_o0` | CK | the existing runtime check
against a CPU reference (`test_wmma_op`, 16x16x128 cases), built at -O0
|

CK CI's daily gfx1250-strict build only builds the MIOpen and hipTensor
instance libraries, not tests.

## Test Plan

1. Device-compile all 20 wrappers for gfx1250 and gfx1250-strict with
ROCm LLVM `d196b6e0be62` (TheRock Multi-Arch CI run
[45807908974](https://github.com/ROCm/TheRock/actions/runs/45807908974)),
with `develop` and with this PR, at -O0 and -O3.
2. CK CMake build with `-DGPU_TARGETS=gfx1250-strict` and the same
compiler: all three new tests plus `test_amdgcn_mma_layout_gfx1250`,
`test_tile_gemm_quant_pipelines_gfx1250` and `test_wmma_op`.
3. Runtime on the rocJITsu gfx1250 emulator (B0 model). The emulator
cannot run gfx1250-strict code objects, so the strict path was forced on
in a scratch copy of each helper and built for gfx1250:
- the strict path vs the native instruction, at -O0 and -O3, all 4 A/B
type pairs, on narrow-exponent data (every f32 sum exact) and on
full-range finite data; and, for comparison, the unscaled F8F6F4 builtin
as LLVM lowers it on strict (scale 0);
- `test_wmma_op_f8_16x16x128_o0` with the strict path forced on, using
the explicit 1.0 scale and using a scale of 0, to show that the -O0 test
detects a wrong scale.

## Test Result

1. With `develop`, gfx1250-strict fails with 20 errors (one per call
site) and gfx1250 passes. With this PR, both pass at -O0 and -O3.
gfx1250-strict emits only `v_wmma_scale_f32_16x16x128_f8f6f4`, always
with the 1.0 scale.
2. All targets build. Against the `develop` headers, the compile-only CK
Tile test fails with 12 errors and the CK test with 8.
3. Emulator:

   | Strict path, vs native | Narrow-exponent data | Full-range data |
   |---|---|---|
| explicit scale 1.0 (this PR), -O0 and -O3 | f32 and f16 bit-identical
| f16 bit-identical; f32 differs in 157-193 of 256 elements per pair,
max relative difference 4.8e-5 |
| unscaled builtin (LLVM promotes it with scale 0), -O3 | bit-identical
| same as explicit scale 1.0 |
| unscaled builtin (LLVM promotes it with scale 0), -O0 | all 256
outputs wrong, every output equals C | not measured |

The full-range f32 difference is far below FP8/BF8 input precision. The
emulator models B0, so this does not prove A0 behaviour.

`test_wmma_op_f8_16x16x128_o0` with the strict path forced on: 8/8 pass
with the explicit 1.0 scale; 8/8 fail with a scale of 0.

4. A0 hardware (gfx1250-strict): one scaled F8F6F4 WMMA with the scale 0
or 1.0, as a literal and as a runtime value, at -O0 and -O3. A scale of
0 gives C whenever it is in a register (literal at -O0, runtime value at
both levels); 1.0 is correct in every case. Reproducer and output in the
review thread.

Not covered: CK itself on A0 hardware, and the full CK test suite on
gfx1250-strict.

Separately, the LLVM rewrite in llvm/llvm-project#230253 should not
depend on the scale staying an inline constant; that is a compiler
issue, to be reported to LLVM separately.

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/TheRock/blob/main/GOVERNANCE.md#pull-requests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:AMDGPU clang:frontend Language frontend issues, e.g. anything involving "Sema" llvm:ir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants