Skip to content

[Codegen][CPU] Lower RISC-V V f16 vfmacc, vfwmacc, and Zvfhmin inner_tiled MMA. - #25000

Merged
devtbi merged 4 commits into
iree-org:mainfrom
TMahlatini:users/tmahlatini/inner-tiled-rvv-f16
Oct 21, 2026
Merged

devtbi merged 4 commits into
iree-org:mainfrom
TMahlatini:users/tmahlatini/inner-tiled-rvv-f16

Conversation

@TMahlatini

Copy link
Copy Markdown
Contributor

Lowers the RISC-V V f16 inner_tiled MMA paths. Native f16 enums are already on main from #24858. This adds lowering, the widening vfwmacc.vf pair, and the +zvfhmin-only fallbacks. All of them reuse lowerRiscvVFmaccLike and the hoisted accumulator legalization from #24933. Tile N is vlen/8.

Encoding +zvfh +zvfhmin only
f16×f16→f16 llvm.riscv.vfmacc (MMA_RISCV_V_VFMACC_*_F16_F16) extf the accumulator to f32, f32 vfmacc, truncf back (*_F16_F16_WIDENF32)
f16×f16→f32 llvm.riscv.vfwmacc (MMA_RISCV_V_VFWMACC_*_F32_F16) extf both panels, then f32 vfmacc (*_F32_F16_CASTF32)

+zvfh implies +zvfhmin. When both are legal, the earlier enum wins: native vfmacc for an f16 accumulator, vfwmacc for an f32 accumulator. At VLEN=256 the cost model picks intrinsics_m 14 (native), 7 (vfwmacc), and 6 (both +zvfhmin paths). CASTF32 and WIDENF32 bill the widened f32 vector operand as f32.

Performance is tracked on #24932. On the X60 (VLEN=256), 1-thread inner_tiled is faster than the mmt4d ukernel for native f16 and vfwmacc. The 4-thread and 8-thread large shapes are still slower. Native f16 is non-widening vfmacc; the f16 ukernel widens with vfwmacc, so that ratio is not the same instruction sequence. vfwmacc is the closer comparison.

Assisted-by: Cursor

Towards #24311

TMahlatini and others added 4 commits October 15, 2026 17:28
…tiled MMA.

Native Zvfh f16×f16→f16 lowers to llvm.riscv.vfmacc. f16×f16→f32 with
+zvfh lowers to llvm.riscv.vfwmacc. +zvfhmin widens to f32 vfmacc:
CASTF32 for an f32 accumulator, and extf/truncf around the accumulator
for an f16 accumulator. +zvfh implies +zvfhmin, and the native
paths win when both are legal.

Towards iree-org#24311

Signed-off-by: Terence <[email protected]>
Co-authored-by: Cursor <[email protected]>
The WIDENF32 extf/truncf around the accumulator is lossy, so hoisting it
across K skips per-K f16 rounding. Honoring
--iree-llvmcpu-skip-intermediate-roundings=false is tracked in iree-org#25058.

Signed-off-by: Terence <[email protected]>
Co-authored-by: Cursor <[email protected]>
…sts.

Write the RVV f16 inner_tiled test ops with the `<...>` inherent-attribute
syntax from iree-org#24983 so they parse.

Signed-off-by: Terence <[email protected]>
Co-authored-by: Cursor <[email protected]>
@TMahlatini
TMahlatini force-pushed the users/tmahlatini/inner-tiled-rvv-f16 branch from 675a4ed to 904d457 Compare October 15, 2026 17:39
@devtbi
devtbi enabled auto-merge (squash) October 21, 2026 08:35
@devtbi
devtbi merged commit e7490c3 into iree-org:main Oct 21, 2026
82 of 84 checks passed
@devtbi devtbi mentioned this pull request Nov 16, 2026
8 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants