[llvm] [AMDGPU] Add baseline tests for RewriteMFMAFormSchedStage (PR #193429)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon May 4 06:58:54 PDT 2026


================
@@ -0,0 +1,373 @@
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx950 \
+; RUN:     -amdgpu-disable-rewrite-mfma-form-sched-stage=false \
+; RUN:     < %s | FileCheck %s
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx950 \
+; RUN:     -amdgpu-disable-rewrite-mfma-form-sched-stage=false \
+; RUN:     -stop-after=machine-scheduler \
+; RUN:     < %s | FileCheck %s --check-prefix=AFTER
+;
+; Test: RewriteMFMAFormStage — v7_slice pattern (gfx950, mfma.f32.16x16x32.f16)
+;
+; Distilled from v7_slice.llir (Triton matmul kernel, gfx950).
+;
+; Key structural features preserved from v7_slice:
+;   (1) Loop body (%loop) accumulates via loop-carried SCALAR float phis,
+;       NOT <4 x float> phis. Each MFMA acc is built by insertelement from
+;       4 individual float phis then used as src2/dst in MFMAs within the loop.
+;   (2) Epilogue (%epilogue) ALSO contains MFMAs: the final K-tile iteration
+;       is peeled. Epilogue MFMAs take scalar float phis from %loop as acc,
+;       then produce results consumed by fptrunc+store — Case 2.
+;   (3) Scalar float phis initialized to 0.0 in entry (non-MAI def) — Case 3.
+;
+; CFG: entry -> loop (back-edge) -> epilogue -> ret
+;
+; Pressure design (gfx950, 256 ArchVGPR limit):
+;   64 loop-carried scalar float phis = 64 VGPRs (non-MFMA pressure carriers).
+;   4 MFMA chains of 2, each acc = 4 float phis = 16 VGPRs in loop.
+;   Plus <8 x half> src0/src1 operands reused across chains = 8 VGPRs.
----------------
arsenm wrote:

8 x half should use 4 VGPRs?

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


More information about the llvm-commits mailing list