[llvm] [AMDGPU] Port Atomic-Optimizer to use Wave Reduction Intrinsics (PR #211757)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 29 01:31:04 PDT 2026


================
@@ -79,15 +78,16 @@ define amdgpu_cs void @atomic_add_and_format(<4 x i32> inreg %arg) {
 ;
 ; GCN-LABEL: atomic_add_and_format:
 ; GCN:       ; %bb.0: ; %.entry
-; GCN-NEXT:    s_mov_b64 s[6:7], exec
-; GCN-NEXT:    v_mbcnt_lo_u32_b32_e64 v0, s6, 0
-; GCN-NEXT:    v_mbcnt_hi_u32_b32_e32 v0, s7, v0
+; GCN-NEXT:    v_mbcnt_lo_u32_b32_e64 v0, exec_lo, 0
+; GCN-NEXT:    v_mbcnt_hi_u32_b32_e32 v0, exec_hi, v0
+; GCN-NEXT:    s_mov_b64 s[4:5], exec
+; GCN-NEXT:    s_bcnt1_i32_b64 s6, s[4:5]
 ; GCN-NEXT:    v_cmp_eq_u32_e32 vcc, 0, v0
 ; GCN-NEXT:    ; implicit-def: $vgpr1
 ; GCN-NEXT:    s_and_saveexec_b64 s[4:5], vcc
 ; GCN-NEXT:    s_cbranch_execz .LBB1_2
 ; GCN-NEXT:  ; %bb.1:
-; GCN-NEXT:    s_bcnt1_i32_b64 s6, s[6:7]
+; GCN-NEXT:    s_mul_i32 s6, s6, 1
----------------
easyonaadit wrote:

This was a missed optimization opportunity, fixed it now.

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


More information about the llvm-commits mailing list