|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 |
| 2 | +; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 %s -o - | FileCheck %s --check-prefix=ISEL |
| 3 | +; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -global-isel %s -o - | FileCheck %s --check-prefix=GI |
| 4 | + |
| 5 | +declare void @bar(ptr) |
| 6 | + |
| 7 | +define i32 @static_alloca() { |
| 8 | +; ISEL-LABEL: static_alloca: |
| 9 | +; ISEL: ; %bb.0: |
| 10 | +; ISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) |
| 11 | +; ISEL-NEXT: s_mov_b32 s16, s33 |
| 12 | +; ISEL-NEXT: s_mov_b32 s33, s32 |
| 13 | +; ISEL-NEXT: s_or_saveexec_b64 s[18:19], -1 |
| 14 | +; ISEL-NEXT: buffer_store_dword v40, off, s[0:3], s33 offset:4 ; 4-byte Folded Spill |
| 15 | +; ISEL-NEXT: s_mov_b64 exec, s[18:19] |
| 16 | +; ISEL-NEXT: s_addk_i32 s32, 0x400 |
| 17 | +; ISEL-NEXT: v_writelane_b32 v40, s16, 4 |
| 18 | +; ISEL-NEXT: s_getpc_b64 s[16:17] |
| 19 | +; ISEL-NEXT: s_add_u32 s16, s16, bar@gotpcrel32@lo+4 |
| 20 | +; ISEL-NEXT: s_addc_u32 s17, s17, bar@gotpcrel32@hi+12 |
| 21 | +; ISEL-NEXT: v_writelane_b32 v40, s30, 0 |
| 22 | +; ISEL-NEXT: s_load_dwordx2 s[16:17], s[16:17], 0x0 |
| 23 | +; ISEL-NEXT: s_lshr_b32 s18, s33, 6 |
| 24 | +; ISEL-NEXT: v_lshrrev_b32_e64 v0, 6, s33 |
| 25 | +; ISEL-NEXT: v_writelane_b32 v40, s31, 1 |
| 26 | +; ISEL-NEXT: s_cmp_lg_u32 s18, -1 |
| 27 | +; ISEL-NEXT: v_readfirstlane_b32 s18, v0 |
| 28 | +; ISEL-NEXT: v_writelane_b32 v40, s34, 2 |
| 29 | +; ISEL-NEXT: s_cselect_b32 s34, s18, 0 |
| 30 | +; ISEL-NEXT: s_mov_b64 s[18:19], src_private_base |
| 31 | +; ISEL-NEXT: v_writelane_b32 v40, s35, 3 |
| 32 | +; ISEL-NEXT: s_cselect_b32 s35, s19, 0 |
| 33 | +; ISEL-NEXT: v_mov_b32_e32 v0, s34 |
| 34 | +; ISEL-NEXT: v_mov_b32_e32 v1, s35 |
| 35 | +; ISEL-NEXT: s_waitcnt lgkmcnt(0) |
| 36 | +; ISEL-NEXT: s_swappc_b64 s[30:31], s[16:17] |
| 37 | +; ISEL-NEXT: v_mov_b32_e32 v0, s34 |
| 38 | +; ISEL-NEXT: v_mov_b32_e32 v1, s35 |
| 39 | +; ISEL-NEXT: flat_load_dword v0, v[0:1] |
| 40 | +; ISEL-NEXT: v_readlane_b32 s35, v40, 3 |
| 41 | +; ISEL-NEXT: v_readlane_b32 s34, v40, 2 |
| 42 | +; ISEL-NEXT: v_readlane_b32 s31, v40, 1 |
| 43 | +; ISEL-NEXT: v_readlane_b32 s30, v40, 0 |
| 44 | +; ISEL-NEXT: s_mov_b32 s32, s33 |
| 45 | +; ISEL-NEXT: v_readlane_b32 s4, v40, 4 |
| 46 | +; ISEL-NEXT: s_or_saveexec_b64 s[6:7], -1 |
| 47 | +; ISEL-NEXT: buffer_load_dword v40, off, s[0:3], s33 offset:4 ; 4-byte Folded Reload |
| 48 | +; ISEL-NEXT: s_mov_b64 exec, s[6:7] |
| 49 | +; ISEL-NEXT: s_mov_b32 s33, s4 |
| 50 | +; ISEL-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0) |
| 51 | +; ISEL-NEXT: s_setpc_b64 s[30:31] |
| 52 | +; |
| 53 | +; GI-LABEL: static_alloca: |
| 54 | +; GI: ; %bb.0: |
| 55 | +; GI-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) |
| 56 | +; GI-NEXT: s_mov_b32 s16, s33 |
| 57 | +; GI-NEXT: s_mov_b32 s33, s32 |
| 58 | +; GI-NEXT: s_or_saveexec_b64 s[18:19], -1 |
| 59 | +; GI-NEXT: buffer_store_dword v40, off, s[0:3], s33 offset:4 ; 4-byte Folded Spill |
| 60 | +; GI-NEXT: s_mov_b64 exec, s[18:19] |
| 61 | +; GI-NEXT: v_writelane_b32 v40, s16, 4 |
| 62 | +; GI-NEXT: v_writelane_b32 v40, s30, 0 |
| 63 | +; GI-NEXT: v_writelane_b32 v40, s31, 1 |
| 64 | +; GI-NEXT: s_addk_i32 s32, 0x400 |
| 65 | +; GI-NEXT: v_writelane_b32 v40, s34, 2 |
| 66 | +; GI-NEXT: s_lshr_b32 s34, s33, 6 |
| 67 | +; GI-NEXT: s_getpc_b64 s[18:19] |
| 68 | +; GI-NEXT: s_add_u32 s18, s18, bar@gotpcrel32@lo+4 |
| 69 | +; GI-NEXT: s_addc_u32 s19, s19, bar@gotpcrel32@hi+12 |
| 70 | +; GI-NEXT: s_load_dwordx2 s[18:19], s[18:19], 0x0 |
| 71 | +; GI-NEXT: s_mov_b64 s[16:17], src_private_base |
| 72 | +; GI-NEXT: v_lshrrev_b32_e64 v0, 6, s33 |
| 73 | +; GI-NEXT: v_mov_b32_e32 v1, s17 |
| 74 | +; GI-NEXT: v_writelane_b32 v40, s35, 3 |
| 75 | +; GI-NEXT: s_mov_b32 s35, s17 |
| 76 | +; GI-NEXT: s_waitcnt lgkmcnt(0) |
| 77 | +; GI-NEXT: s_swappc_b64 s[30:31], s[18:19] |
| 78 | +; GI-NEXT: v_mov_b32_e32 v0, s34 |
| 79 | +; GI-NEXT: v_mov_b32_e32 v1, s35 |
| 80 | +; GI-NEXT: flat_load_dword v0, v[0:1] |
| 81 | +; GI-NEXT: v_readlane_b32 s35, v40, 3 |
| 82 | +; GI-NEXT: v_readlane_b32 s34, v40, 2 |
| 83 | +; GI-NEXT: v_readlane_b32 s31, v40, 1 |
| 84 | +; GI-NEXT: v_readlane_b32 s30, v40, 0 |
| 85 | +; GI-NEXT: s_mov_b32 s32, s33 |
| 86 | +; GI-NEXT: v_readlane_b32 s4, v40, 4 |
| 87 | +; GI-NEXT: s_or_saveexec_b64 s[6:7], -1 |
| 88 | +; GI-NEXT: buffer_load_dword v40, off, s[0:3], s33 offset:4 ; 4-byte Folded Reload |
| 89 | +; GI-NEXT: s_mov_b64 exec, s[6:7] |
| 90 | +; GI-NEXT: s_mov_b32 s33, s4 |
| 91 | +; GI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0) |
| 92 | +; GI-NEXT: s_setpc_b64 s[30:31] |
| 93 | + %alloca = alloca i32, align 4 |
| 94 | + call void @bar(ptr %alloca) |
| 95 | + %load = load i32, ptr %alloca |
| 96 | + ret i32 %load |
| 97 | +} |
| 98 | + |
| 99 | +define i32 @dynamic_alloca(i32 %n) { |
| 100 | +; ISEL-LABEL: dynamic_alloca: |
| 101 | +; ISEL: ; %bb.0: |
| 102 | +; ISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) |
| 103 | +; ISEL-NEXT: s_mov_b32 s16, s33 |
| 104 | +; ISEL-NEXT: s_mov_b32 s33, s32 |
| 105 | +; ISEL-NEXT: s_or_saveexec_b64 s[18:19], -1 |
| 106 | +; ISEL-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill |
| 107 | +; ISEL-NEXT: s_mov_b64 exec, s[18:19] |
| 108 | +; ISEL-NEXT: v_writelane_b32 v40, s16, 2 |
| 109 | +; ISEL-NEXT: v_mad_u64_u32 v[0:1], s[16:17], v0, 4, 15 |
| 110 | +; ISEL-NEXT: v_writelane_b32 v40, s30, 0 |
| 111 | +; ISEL-NEXT: s_mov_b32 s18, 0 |
| 112 | +; ISEL-NEXT: v_and_b32_e32 v0, -16, v0 |
| 113 | +; ISEL-NEXT: s_mov_b64 s[16:17], exec |
| 114 | +; ISEL-NEXT: s_addk_i32 s32, 0x400 |
| 115 | +; ISEL-NEXT: v_writelane_b32 v40, s31, 1 |
| 116 | +; ISEL-NEXT: .LBB1_1: ; =>This Inner Loop Header: Depth=1 |
| 117 | +; ISEL-NEXT: s_ff1_i32_b64 s19, s[16:17] |
| 118 | +; ISEL-NEXT: v_readlane_b32 s20, v0, s19 |
| 119 | +; ISEL-NEXT: s_bitset0_b64 s[16:17], s19 |
| 120 | +; ISEL-NEXT: s_max_u32 s18, s18, s20 |
| 121 | +; ISEL-NEXT: s_cmp_lg_u64 s[16:17], 0 |
| 122 | +; ISEL-NEXT: s_cbranch_scc1 .LBB1_1 |
| 123 | +; ISEL-NEXT: ; %bb.2: |
| 124 | +; ISEL-NEXT: s_cmp_lg_u32 s32, -1 |
| 125 | +; ISEL-NEXT: s_mov_b64 s[16:17], src_private_base |
| 126 | +; ISEL-NEXT: s_cselect_b32 s19, s32, 0 |
| 127 | +; ISEL-NEXT: s_cselect_b32 s20, s17, 0 |
| 128 | +; ISEL-NEXT: s_getpc_b64 s[16:17] |
| 129 | +; ISEL-NEXT: s_add_u32 s16, s16, bar@gotpcrel32@lo+4 |
| 130 | +; ISEL-NEXT: s_addc_u32 s17, s17, bar@gotpcrel32@hi+12 |
| 131 | +; ISEL-NEXT: s_load_dwordx2 s[16:17], s[16:17], 0x0 |
| 132 | +; ISEL-NEXT: v_mov_b32_e32 v0, s32 |
| 133 | +; ISEL-NEXT: v_lshl_add_u32 v0, s18, 6, v0 |
| 134 | +; ISEL-NEXT: v_readfirstlane_b32 s18, v0 |
| 135 | +; ISEL-NEXT: v_mov_b32_e32 v0, s19 |
| 136 | +; ISEL-NEXT: v_mov_b32_e32 v1, s20 |
| 137 | +; ISEL-NEXT: s_mov_b32 s32, s18 |
| 138 | +; ISEL-NEXT: s_waitcnt lgkmcnt(0) |
| 139 | +; ISEL-NEXT: s_swappc_b64 s[30:31], s[16:17] |
| 140 | +; ISEL-NEXT: v_mov_b32_e32 v0, 0 |
| 141 | +; ISEL-NEXT: v_readlane_b32 s31, v40, 1 |
| 142 | +; ISEL-NEXT: v_readlane_b32 s30, v40, 0 |
| 143 | +; ISEL-NEXT: s_mov_b32 s32, s33 |
| 144 | +; ISEL-NEXT: v_readlane_b32 s4, v40, 2 |
| 145 | +; ISEL-NEXT: s_or_saveexec_b64 s[6:7], -1 |
| 146 | +; ISEL-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload |
| 147 | +; ISEL-NEXT: s_mov_b64 exec, s[6:7] |
| 148 | +; ISEL-NEXT: s_mov_b32 s33, s4 |
| 149 | +; ISEL-NEXT: s_waitcnt vmcnt(0) |
| 150 | +; ISEL-NEXT: s_setpc_b64 s[30:31] |
| 151 | +; |
| 152 | +; GI-LABEL: dynamic_alloca: |
| 153 | +; GI: ; %bb.0: |
| 154 | +; GI-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) |
| 155 | +; GI-NEXT: s_mov_b32 s16, s33 |
| 156 | +; GI-NEXT: s_mov_b32 s33, s32 |
| 157 | +; GI-NEXT: s_or_saveexec_b64 s[18:19], -1 |
| 158 | +; GI-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill |
| 159 | +; GI-NEXT: s_mov_b64 exec, s[18:19] |
| 160 | +; GI-NEXT: v_mov_b32_e32 v1, 0 |
| 161 | +; GI-NEXT: v_lshlrev_b64 v[0:1], 2, v[0:1] |
| 162 | +; GI-NEXT: v_writelane_b32 v40, s16, 2 |
| 163 | +; GI-NEXT: v_add_co_u32_e32 v0, vcc, 15, v0 |
| 164 | +; GI-NEXT: v_writelane_b32 v40, s30, 0 |
| 165 | +; GI-NEXT: s_mov_b32 s18, 0 |
| 166 | +; GI-NEXT: v_and_b32_e32 v0, -16, v0 |
| 167 | +; GI-NEXT: s_mov_b64 s[16:17], exec |
| 168 | +; GI-NEXT: s_addk_i32 s32, 0x400 |
| 169 | +; GI-NEXT: v_writelane_b32 v40, s31, 1 |
| 170 | +; GI-NEXT: .LBB1_1: ; =>This Inner Loop Header: Depth=1 |
| 171 | +; GI-NEXT: s_ff1_i32_b64 s19, s[16:17] |
| 172 | +; GI-NEXT: v_readlane_b32 s20, v0, s19 |
| 173 | +; GI-NEXT: s_bitset0_b64 s[16:17], s19 |
| 174 | +; GI-NEXT: s_max_u32 s18, s18, s20 |
| 175 | +; GI-NEXT: s_cmp_lg_u64 s[16:17], 0 |
| 176 | +; GI-NEXT: s_cbranch_scc1 .LBB1_1 |
| 177 | +; GI-NEXT: ; %bb.2: |
| 178 | +; GI-NEXT: s_mov_b32 s16, s32 |
| 179 | +; GI-NEXT: s_lshl_b32 s17, s18, 6 |
| 180 | +; GI-NEXT: s_add_u32 s32, s16, s17 |
| 181 | +; GI-NEXT: s_mov_b64 s[18:19], src_private_base |
| 182 | +; GI-NEXT: s_mov_b32 s17, s19 |
| 183 | +; GI-NEXT: s_cmp_lg_u32 s16, -1 |
| 184 | +; GI-NEXT: s_cselect_b64 s[16:17], s[16:17], 0 |
| 185 | +; GI-NEXT: s_getpc_b64 s[18:19] |
| 186 | +; GI-NEXT: s_add_u32 s18, s18, bar@gotpcrel32@lo+4 |
| 187 | +; GI-NEXT: s_addc_u32 s19, s19, bar@gotpcrel32@hi+12 |
| 188 | +; GI-NEXT: s_load_dwordx2 s[18:19], s[18:19], 0x0 |
| 189 | +; GI-NEXT: v_mov_b32_e32 v0, s16 |
| 190 | +; GI-NEXT: v_mov_b32_e32 v1, s17 |
| 191 | +; GI-NEXT: s_waitcnt lgkmcnt(0) |
| 192 | +; GI-NEXT: s_swappc_b64 s[30:31], s[18:19] |
| 193 | +; GI-NEXT: v_mov_b32_e32 v0, 0 |
| 194 | +; GI-NEXT: v_readlane_b32 s31, v40, 1 |
| 195 | +; GI-NEXT: v_readlane_b32 s30, v40, 0 |
| 196 | +; GI-NEXT: s_mov_b32 s32, s33 |
| 197 | +; GI-NEXT: v_readlane_b32 s4, v40, 2 |
| 198 | +; GI-NEXT: s_or_saveexec_b64 s[6:7], -1 |
| 199 | +; GI-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload |
| 200 | +; GI-NEXT: s_mov_b64 exec, s[6:7] |
| 201 | +; GI-NEXT: s_mov_b32 s33, s4 |
| 202 | +; GI-NEXT: s_waitcnt vmcnt(0) |
| 203 | +; GI-NEXT: s_setpc_b64 s[30:31] |
| 204 | + %alloca = alloca i32, i32 %n, align 4 |
| 205 | + call void @bar(ptr %alloca) |
| 206 | + %load = load i32, ptr %alloca |
| 207 | + ret i32 0 |
| 208 | +} |
0 commit comments