1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -global-isel -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -mattr=-xnack -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX9 %s
3 ; RUN: llc -global-isel -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx1200 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX12 %s
5 ; Check lowering of some large extractelement that use the stack
6 ; instead of register indexing.
8 define i32 @v_extract_v64i32_varidx(ptr addrspace(1) %ptr, i32 %idx) {
9 ; GFX9-LABEL: v_extract_v64i32_varidx:
11 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
12 ; GFX9-NEXT: v_and_b32_e32 v2, 63, v2
13 ; GFX9-NEXT: v_lshlrev_b32_e32 v2, 2, v2
14 ; GFX9-NEXT: v_ashrrev_i32_e32 v3, 31, v2
15 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, v0, v2
16 ; GFX9-NEXT: v_addc_co_u32_e32 v1, vcc, v1, v3, vcc
17 ; GFX9-NEXT: global_load_dword v0, v[0:1], off
18 ; GFX9-NEXT: s_waitcnt vmcnt(0)
19 ; GFX9-NEXT: s_setpc_b64 s[30:31]
21 ; GFX12-LABEL: v_extract_v64i32_varidx:
23 ; GFX12-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
24 ; GFX12-NEXT: v_and_b32_e32 v2, 63, v2
25 ; GFX12-NEXT: s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
26 ; GFX12-NEXT: v_lshlrev_b32_e32 v2, 2, v2
27 ; GFX12-NEXT: v_ashrrev_i32_e32 v3, 31, v2
28 ; GFX12-NEXT: v_add_co_u32 v0, vcc_lo, v0, v2
29 ; GFX12-NEXT: s_delay_alu instid0(VALU_DEP_2)
30 ; GFX12-NEXT: v_add_co_ci_u32_e32 v1, vcc_lo, v1, v3, vcc_lo
31 ; GFX12-NEXT: global_load_b32 v0, v[0:1], off
32 ; GFX12-NEXT: s_waitcnt vmcnt(0)
33 ; GFX12-NEXT: s_setpc_b64 s[30:31]
34 %vec = load <64 x i32>, ptr addrspace(1) %ptr
35 %elt = extractelement <64 x i32> %vec, i32 %idx
39 define i16 @v_extract_v128i16_varidx(ptr addrspace(1) %ptr, i32 %idx) {
40 ; GFX9-LABEL: v_extract_v128i16_varidx:
42 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
43 ; GFX9-NEXT: v_and_b32_e32 v2, 0x7f, v2
44 ; GFX9-NEXT: v_lshlrev_b32_e32 v2, 1, v2
45 ; GFX9-NEXT: v_ashrrev_i32_e32 v3, 31, v2
46 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, v0, v2
47 ; GFX9-NEXT: v_addc_co_u32_e32 v1, vcc, v1, v3, vcc
48 ; GFX9-NEXT: global_load_ushort v0, v[0:1], off
49 ; GFX9-NEXT: s_waitcnt vmcnt(0)
50 ; GFX9-NEXT: s_setpc_b64 s[30:31]
52 ; GFX12-LABEL: v_extract_v128i16_varidx:
54 ; GFX12-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
55 ; GFX12-NEXT: v_and_b32_e32 v2, 0x7f, v2
56 ; GFX12-NEXT: s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
57 ; GFX12-NEXT: v_lshlrev_b32_e32 v2, 1, v2
58 ; GFX12-NEXT: v_ashrrev_i32_e32 v3, 31, v2
59 ; GFX12-NEXT: v_add_co_u32 v0, vcc_lo, v0, v2
60 ; GFX12-NEXT: s_delay_alu instid0(VALU_DEP_2)
61 ; GFX12-NEXT: v_add_co_ci_u32_e32 v1, vcc_lo, v1, v3, vcc_lo
62 ; GFX12-NEXT: global_load_u16 v0, v[0:1], off
63 ; GFX12-NEXT: s_waitcnt vmcnt(0)
64 ; GFX12-NEXT: s_setpc_b64 s[30:31]
65 %vec = load <128 x i16>, ptr addrspace(1) %ptr
66 %elt = extractelement <128 x i16> %vec, i32 %idx
70 define i64 @v_extract_v32i64_varidx(ptr addrspace(1) %ptr, i32 %idx) {
71 ; GFX9-LABEL: v_extract_v32i64_varidx:
73 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
74 ; GFX9-NEXT: v_and_b32_e32 v2, 31, v2
75 ; GFX9-NEXT: v_lshlrev_b32_e32 v2, 3, v2
76 ; GFX9-NEXT: v_ashrrev_i32_e32 v3, 31, v2
77 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, v0, v2
78 ; GFX9-NEXT: v_addc_co_u32_e32 v1, vcc, v1, v3, vcc
79 ; GFX9-NEXT: global_load_dwordx2 v[0:1], v[0:1], off
80 ; GFX9-NEXT: s_waitcnt vmcnt(0)
81 ; GFX9-NEXT: s_setpc_b64 s[30:31]
83 ; GFX12-LABEL: v_extract_v32i64_varidx:
85 ; GFX12-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
86 ; GFX12-NEXT: v_and_b32_e32 v2, 31, v2
87 ; GFX12-NEXT: s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
88 ; GFX12-NEXT: v_lshlrev_b32_e32 v2, 3, v2
89 ; GFX12-NEXT: v_ashrrev_i32_e32 v3, 31, v2
90 ; GFX12-NEXT: v_add_co_u32 v0, vcc_lo, v0, v2
91 ; GFX12-NEXT: s_delay_alu instid0(VALU_DEP_2)
92 ; GFX12-NEXT: v_add_co_ci_u32_e32 v1, vcc_lo, v1, v3, vcc_lo
93 ; GFX12-NEXT: global_load_b64 v[0:1], v[0:1], off
94 ; GFX12-NEXT: s_waitcnt vmcnt(0)
95 ; GFX12-NEXT: s_setpc_b64 s[30:31]
96 %vec = load <32 x i64>, ptr addrspace(1) %ptr
97 %elt = extractelement <32 x i64> %vec, i32 %idx