[llvm] [AMDGPU] Prevent folding of FMAC into FMAAK with two literals (PR #217438)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 19 12:53:19 PDT 2026
================
@@ -0,0 +1,20 @@
+# RUN: llc -mtriple=amdgcn -mcpu=gfx1201 -run-pass peephole-opt -verify-machineinstrs -o - %s | FileCheck %s
+
+# An FMAC whose src1 is already a literal must not be folded into FMAAK as VOP2/VOP3
+# instruction cannot uses more than one literal.
+
+---
+name: fold_fmac_to_fmaak
+tracksRegLiveness: true
+body: |
+ bb.0:
+ liveins: $vgpr0
+ ; CHECK: V_MOV_B16_t16_e64 0, 8478
+ ; CHECK: V_FMAC_F16_t16_e64 {{.*}}10526
+ ; CHECK-NOT: V_FMAAK
+ %0:vgpr_16 = COPY $vgpr0
+ %1:vgpr_16 = V_MOV_B16_t16_e64 0, 8478, 0, implicit $exec
+ %2:vgpr_16 = contract nofpexcept V_FMAC_F16_t16_e64 0, %0, 0, 10526, 0, %1, 0, 0, 0, implicit $mode, implicit $exec
+ $vgpr0 = COPY %2
+ SI_RETURN implicit $vgpr0
+...
----------------
arsenm wrote:
Also test the f32 case? Are there existing tests for when each source is an inline imm and still foldable?
https://github.com/llvm/llvm-project/pull/217438
More information about the llvm-commits
mailing list