1 ; RUN: llc -amdgpu-scalarize-global-loads=false -mtriple=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s
2 ; RUN: llc -amdgpu-scalarize-global-loads=false -mtriple=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s
4 ; SI-LABEL: {{^}}s_movk_i32_k0:
5 ; SI-DAG: buffer_load_dwordx2 v[[[LO_VREG:[0-9]+]]:[[HI_VREG:[0-9]+]]],
6 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0xffff, v[[LO_VREG]]
7 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 1, v[[HI_VREG]]
9 define amdgpu_kernel void @s_movk_i32_k0(ptr addrspace(1) %out, ptr addrspace(1) %a, ptr addrspace(1) %b) {
10 %loada = load i64, ptr addrspace(1) %a, align 4
11 %or = or i64 %loada, 4295032831 ; ((1 << 16) - 1) | (1 << 32)
12 store i64 %or, ptr addrspace(1) %out
13 call void asm sideeffect "; use $0", "s"(i64 4295032831)
17 ; SI-LABEL: {{^}}s_movk_i32_k1:
18 ; SI-DAG: buffer_load_dwordx2 v[[[LO_VREG:[0-9]+]]:[[HI_VREG:[0-9]+]]],
19 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0x7fff, v[[LO_VREG]]
20 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 1, v[[HI_VREG]]
22 define amdgpu_kernel void @s_movk_i32_k1(ptr addrspace(1) %out, ptr addrspace(1) %a, ptr addrspace(1) %b) {
23 %loada = load i64, ptr addrspace(1) %a, align 4
24 %or = or i64 %loada, 4295000063 ; ((1 << 15) - 1) | (1 << 32)
25 store i64 %or, ptr addrspace(1) %out
26 call void asm sideeffect "; use $0", "s"(i64 4295000063)
30 ; SI-LABEL: {{^}}s_movk_i32_k2:
31 ; SI-DAG: s_movk_i32 [[LO_S_IMM:s[0-9]+]], 0x7fff{{$}}
32 ; SI-DAG: buffer_load_dwordx2 v[[[LO_VREG:[0-9]+]]:[[HI_VREG:[0-9]+]]],
33 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0x7fff, v[[LO_VREG]]
34 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 64, v[[HI_VREG]]
36 define amdgpu_kernel void @s_movk_i32_k2(ptr addrspace(1) %out, ptr addrspace(1) %a, ptr addrspace(1) %b) {
37 %loada = load i64, ptr addrspace(1) %a, align 4
38 %or = or i64 %loada, 274877939711 ; ((1 << 15) - 1) | (64 << 32)
39 store i64 %or, ptr addrspace(1) %out
40 call void asm sideeffect "; use $0", "s"(i64 274877939711)
44 ; SI-LABEL: {{^}}s_movk_i32_k3:
45 ; SI-DAG: buffer_load_dwordx2 v[[[LO_VREG:[0-9]+]]:[[HI_VREG:[0-9]+]]],
46 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0x8000, v[[LO_VREG]]
47 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 1, v[[HI_VREG]]
49 define amdgpu_kernel void @s_movk_i32_k3(ptr addrspace(1) %out, ptr addrspace(1) %a, ptr addrspace(1) %b) {
50 %loada = load i64, ptr addrspace(1) %a, align 4
51 %or = or i64 %loada, 4295000064 ; (1 << 15) | (1 << 32)
52 store i64 %or, ptr addrspace(1) %out
53 call void asm sideeffect "; use $0", "s"(i64 4295000064)
57 ; SI-LABEL: {{^}}s_movk_i32_k4:
58 ; SI-DAG: buffer_load_dwordx2 v[[[LO_VREG:[0-9]+]]:[[HI_VREG:[0-9]+]]],
59 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0x20000, v[[LO_VREG]]
60 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 1, v[[HI_VREG]]
62 define amdgpu_kernel void @s_movk_i32_k4(ptr addrspace(1) %out, ptr addrspace(1) %a, ptr addrspace(1) %b) {
63 %loada = load i64, ptr addrspace(1) %a, align 4
64 %or = or i64 %loada, 4295098368 ; (1 << 17) | (1 << 32)
65 store i64 %or, ptr addrspace(1) %out
66 call void asm sideeffect "; use $0", "s"(i64 4295098368)
70 ; SI-LABEL: {{^}}s_movk_i32_k5:
71 ; SI-DAG: buffer_load_dwordx2 v[[[LO_VREG:[0-9]+]]:[[HI_VREG:[0-9]+]]],
72 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0xffffffef, v[[LO_VREG]]
73 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0xff00ffff, v[[HI_VREG]]
75 define amdgpu_kernel void @s_movk_i32_k5(ptr addrspace(1) %out, ptr addrspace(1) %a, ptr addrspace(1) %b) {
76 %loada = load i64, ptr addrspace(1) %a, align 4
77 %or = or i64 %loada, 18374967954648334319 ; -17 & 0xff00ffffffffffff
78 store i64 %or, ptr addrspace(1) %out
79 call void asm sideeffect "; use $0", "s"(i64 18374967954648334319)
83 ; SI-LABEL: {{^}}s_movk_i32_k6:
84 ; SI-DAG: buffer_load_dwordx2 v[[[LO_VREG:[0-9]+]]:[[HI_VREG:[0-9]+]]],
85 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0x41, v[[LO_VREG]]
86 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 63, v[[HI_VREG]]
88 define amdgpu_kernel void @s_movk_i32_k6(ptr addrspace(1) %out, ptr addrspace(1) %a, ptr addrspace(1) %b) {
89 %loada = load i64, ptr addrspace(1) %a, align 4
90 %or = or i64 %loada, 270582939713 ; 65 | (63 << 32)
91 store i64 %or, ptr addrspace(1) %out
92 call void asm sideeffect "; use $0", "s"(i64 270582939713)
96 ; SI-LABEL: {{^}}s_movk_i32_k7:
97 ; SI-DAG: buffer_load_dwordx2 v[[[LO_VREG:[0-9]+]]:[[HI_VREG:[0-9]+]]],
98 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0x2000, v[[LO_VREG]]
99 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0x4000, v[[HI_VREG]]
101 define amdgpu_kernel void @s_movk_i32_k7(ptr addrspace(1) %out, ptr addrspace(1) %a, ptr addrspace(1) %b) {
102 %loada = load i64, ptr addrspace(1) %a, align 4
103 %or = or i64 %loada, 70368744185856; ((1 << 13)) | ((1 << 14) << 32)
104 store i64 %or, ptr addrspace(1) %out
105 call void asm sideeffect "; use $0", "s"(i64 70368744185856)
109 ; SI-LABEL: {{^}}s_movk_i32_k8:
110 ; SI-DAG: buffer_load_dwordx2 v[[[LO_VREG:[0-9]+]]:[[HI_VREG:[0-9]+]]],
111 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0xffff8000, v[[LO_VREG]]
112 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0x11111111, v[[HI_VREG]]
114 define amdgpu_kernel void @s_movk_i32_k8(ptr addrspace(1) %out, ptr addrspace(1) %a, ptr addrspace(1) %b) {
115 %loada = load i64, ptr addrspace(1) %a, align 4
116 %or = or i64 %loada, 1229782942255906816 ; 0x11111111ffff8000
117 store i64 %or, ptr addrspace(1) %out
118 call void asm sideeffect "; use $0", "s"(i64 1229782942255906816)
122 ; SI-LABEL: {{^}}s_movk_i32_k9:
123 ; SI-DAG: buffer_load_dwordx2 v[[[LO_VREG:[0-9]+]]:[[HI_VREG:[0-9]+]]],
124 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0xffff8001, v[[LO_VREG]]
125 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0x11111111, v[[HI_VREG]]
127 define amdgpu_kernel void @s_movk_i32_k9(ptr addrspace(1) %out, ptr addrspace(1) %a, ptr addrspace(1) %b) {
128 %loada = load i64, ptr addrspace(1) %a, align 4
129 %or = or i64 %loada, 1229782942255906817 ; 0x11111111ffff8001
130 store i64 %or, ptr addrspace(1) %out
131 call void asm sideeffect "; use $0", "s"(i64 1229782942255906817)
135 ; SI-LABEL: {{^}}s_movk_i32_k10:
136 ; SI-DAG: buffer_load_dwordx2 v[[[LO_VREG:[0-9]+]]:[[HI_VREG:[0-9]+]]],
137 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0xffff8888, v[[LO_VREG]]
138 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0x11111111, v[[HI_VREG]]
140 define amdgpu_kernel void @s_movk_i32_k10(ptr addrspace(1) %out, ptr addrspace(1) %a, ptr addrspace(1) %b) {
141 %loada = load i64, ptr addrspace(1) %a, align 4
142 %or = or i64 %loada, 1229782942255909000 ; 0x11111111ffff8888
143 store i64 %or, ptr addrspace(1) %out
144 call void asm sideeffect "; use $0", "s"(i64 1229782942255909000)
148 ; SI-LABEL: {{^}}s_movk_i32_k11:
149 ; SI-DAG: buffer_load_dwordx2 v[[[LO_VREG:[0-9]+]]:[[HI_VREG:[0-9]+]]],
150 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0xffff8fff, v[[LO_VREG]]
151 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0x11111111, v[[HI_VREG]]
153 define amdgpu_kernel void @s_movk_i32_k11(ptr addrspace(1) %out, ptr addrspace(1) %a, ptr addrspace(1) %b) {
154 %loada = load i64, ptr addrspace(1) %a, align 4
155 %or = or i64 %loada, 1229782942255910911 ; 0x11111111ffff8fff
156 store i64 %or, ptr addrspace(1) %out
157 call void asm sideeffect "; use $0", "s"(i64 1229782942255910911)
161 ; SI-LABEL: {{^}}s_movk_i32_k12:
162 ; SI-DAG: buffer_load_dwordx2 v[[[LO_VREG:[0-9]+]]:[[HI_VREG:[0-9]+]]],
163 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0xffff7001, v[[LO_VREG]]
164 ; SI-DAG: v_or_b32_e32 {{v[0-9]+}}, 0x11111111, v[[HI_VREG]]
166 define amdgpu_kernel void @s_movk_i32_k12(ptr addrspace(1) %out, ptr addrspace(1) %a, ptr addrspace(1) %b) {
167 %loada = load i64, ptr addrspace(1) %a, align 4
168 %or = or i64 %loada, 1229782942255902721 ; 0x11111111ffff7001
169 store i64 %or, ptr addrspace(1) %out
170 call void asm sideeffect "; use $0", "s"(i64 1229782942255902721)