[llvm] [AMDGPU] Waterfall loop codegen improvement in SIInstrInfo (PR #192415)
via llvm-commits
llvm-commits at lists.llvm.org
Wed May 20 06:51:10 PDT 2026
================
@@ -15,50 +15,47 @@ define void @issue92561(ptr addrspace(1) %arg) {
; SDAG-NEXT: global_load_b128 v[4:7], v[0:1], off offset:16
; SDAG-NEXT: global_load_b128 v[0:3], v[0:1], off
; SDAG-NEXT: v_mov_b32_e32 v8, 0
-; SDAG-NEXT: s_mov_b32 s12, 0
-; SDAG-NEXT: s_mov_b32 s3, exec_lo
+; SDAG-NEXT: s_mov_b32 s8, 0
+; SDAG-NEXT: s_mov_b32 s12, exec_lo
+; SDAG-NEXT: s_mov_b32 s9, s8
+; SDAG-NEXT: s_mov_b32 s10, s8
+; SDAG-NEXT: s_mov_b32 s11, s8
; SDAG-NEXT: s_mov_b32 s13, s12
-; SDAG-NEXT: s_mov_b32 s14, s12
-; SDAG-NEXT: s_mov_b32 s15, s12
; SDAG-NEXT: s_waitcnt vmcnt(0)
; SDAG-NEXT: .LBB0_1: ; =>This Inner Loop Header: Depth=1
-; SDAG-NEXT: v_readfirstlane_b32 s4, v0
-; SDAG-NEXT: v_readfirstlane_b32 s5, v1
-; SDAG-NEXT: v_readfirstlane_b32 s6, v2
-; SDAG-NEXT: v_readfirstlane_b32 s7, v3
-; SDAG-NEXT: v_readfirstlane_b32 s8, v4
-; SDAG-NEXT: v_readfirstlane_b32 s9, v5
-; SDAG-NEXT: v_readfirstlane_b32 s10, v6
-; SDAG-NEXT: v_readfirstlane_b32 s11, v7
-; SDAG-NEXT: v_cmp_eq_u64_e32 vcc_lo, s[4:5], v[0:1]
-; SDAG-NEXT: v_cmp_eq_u64_e64 s0, s[6:7], v[2:3]
-; SDAG-NEXT: v_cmp_eq_u64_e64 s1, s[8:9], v[4:5]
-; SDAG-NEXT: s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
-; SDAG-NEXT: v_cmp_eq_u64_e64 s2, s[10:11], v[6:7]
-; SDAG-NEXT: s_and_b32 s0, vcc_lo, s0
-; SDAG-NEXT: s_and_b32 s0, s0, s1
-; SDAG-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
-; SDAG-NEXT: s_and_b32 s0, s0, s2
-; SDAG-NEXT: s_and_saveexec_b32 s0, s0
-; SDAG-NEXT: image_sample_c_lz v9, [v8, v8, v8, v8], s[4:11], s[12:15] dmask:0x1 dim:SQ_RSRC_IMG_2D_ARRAY
+; SDAG-NEXT: v_readfirstlane_b32 s0, v0
+; SDAG-NEXT: v_readfirstlane_b32 s1, v1
+; SDAG-NEXT: s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
+; SDAG-NEXT: v_cmpx_eq_u64_e32 s[0:1], v[0:1]
----------------
gretay-amd wrote:
I see, thanks for explaining. I added a comment about the tradeoff and changed the implementation to defer all cmpx after readfirstlane. Reordering cmpx seems to fit better in one of the later passes that already have registee pressure information (e.g., `SIOptimizeVGPRLiveRange`) . It doesn't fit well with instruction scheduling now that cmpx is a terminator because reordering would require block splitting. Alternatively, we could add a new compilation flag to control placement of cmpx.
https://github.com/llvm/llvm-project/pull/192415
More information about the llvm-commits
mailing list