[llvm] [AMDGPU] Add v2i32 and/or patterns for VOP3 AND_OR and OR3 operations (PR #188375)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 25 03:14:28 PDT 2026


================
@@ -142,3 +142,26 @@ define amdgpu_ps float @and_or_vgpr_inline_const_x2(i32 %a) {
   %bc = bitcast i32 %result to float
   ret float %bc
 }
+
+define <2 x i32> @and_or_v2i32(<2 x i32> %a, <2 x i32> %b, <2 x i32> %c) {
+; VI-LABEL: and_or_v2i32:
+; VI:         s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; VI-DAG:    v_and_b32_e32 v0, v0, v2
+; VI-DAG:    v_and_b32_e32 v1, v1, v3
+; VI-CHECK-NOT: {{.}}
+; VI-DAG:    v_or_b32_e32 v0, v0, v4
+; VI-DAG:    v_or_b32_e32 v1, v1, v5
+;
+; GFX9-LABEL: and_or_v2i32:
+; GFX9:         s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GFX9-DAG:     v_and_or_b32 v0, v0, v2, v4
+; GFX9-DAG:     v_and_or_b32 v1, v1, v3, v5
+;
+; GFX10-LABEL: and_or_v2i32:
+; GFX10:         s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GFX10-DAG:     v_and_or_b32 v0, v0, v2, v4
+; GFX10-DAG:     v_and_or_b32 v1, v1, v3, v5
+  %x = and <2 x i32> %a, %b
+  %result = or <2 x i32> %x, %c
+  ret <2 x i32> %result
+}
----------------
arsenm wrote:

Can you also test the SALU case, and cases with 2 SGPR inputs in the VALU case to make sure there are no constant bus violations? Also test 3x case, and 4x cases 

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


More information about the llvm-commits mailing list