1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -mtriple=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GFX6-NOHSA %s
3 ; RUN: llc -mtriple=amdgcn-amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefix=GFX7-HSA %s
4 ; RUN: llc -mtriple=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=GFX8-NOHSA %s
6 ; FUNC-LABEL: {{^}}constant_load_f64:
7 define amdgpu_kernel void @constant_load_f64(ptr addrspace(1) %out, ptr addrspace(4) %in) #0 {
8 ; GFX6-NOHSA-LABEL: constant_load_f64:
10 ; GFX6-NOHSA-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
11 ; GFX6-NOHSA-NEXT: s_waitcnt lgkmcnt(0)
12 ; GFX6-NOHSA-NEXT: s_load_dwordx2 s[4:5], s[2:3], 0x0
13 ; GFX6-NOHSA-NEXT: s_mov_b32 s3, 0xf000
14 ; GFX6-NOHSA-NEXT: s_mov_b32 s2, -1
15 ; GFX6-NOHSA-NEXT: s_waitcnt lgkmcnt(0)
16 ; GFX6-NOHSA-NEXT: v_mov_b32_e32 v0, s4
17 ; GFX6-NOHSA-NEXT: v_mov_b32_e32 v1, s5
18 ; GFX6-NOHSA-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
19 ; GFX6-NOHSA-NEXT: s_endpgm
21 ; GFX7-HSA-LABEL: constant_load_f64:
23 ; GFX7-HSA-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
24 ; GFX7-HSA-NEXT: s_waitcnt lgkmcnt(0)
25 ; GFX7-HSA-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x0
26 ; GFX7-HSA-NEXT: v_mov_b32_e32 v0, s0
27 ; GFX7-HSA-NEXT: v_mov_b32_e32 v1, s1
28 ; GFX7-HSA-NEXT: s_waitcnt lgkmcnt(0)
29 ; GFX7-HSA-NEXT: v_mov_b32_e32 v2, s2
30 ; GFX7-HSA-NEXT: v_mov_b32_e32 v3, s3
31 ; GFX7-HSA-NEXT: flat_store_dwordx2 v[0:1], v[2:3]
32 ; GFX7-HSA-NEXT: s_endpgm
34 ; GFX8-NOHSA-LABEL: constant_load_f64:
35 ; GFX8-NOHSA: ; %bb.0:
36 ; GFX8-NOHSA-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
37 ; GFX8-NOHSA-NEXT: s_waitcnt lgkmcnt(0)
38 ; GFX8-NOHSA-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x0
39 ; GFX8-NOHSA-NEXT: v_mov_b32_e32 v0, s0
40 ; GFX8-NOHSA-NEXT: v_mov_b32_e32 v1, s1
41 ; GFX8-NOHSA-NEXT: s_waitcnt lgkmcnt(0)
42 ; GFX8-NOHSA-NEXT: v_mov_b32_e32 v2, s2
43 ; GFX8-NOHSA-NEXT: v_mov_b32_e32 v3, s3
44 ; GFX8-NOHSA-NEXT: flat_store_dwordx2 v[0:1], v[2:3]
45 ; GFX8-NOHSA-NEXT: s_endpgm
46 %ld = load double, ptr addrspace(4) %in
47 store double %ld, ptr addrspace(1) %out
51 attributes #0 = { nounwind }
53 ; Tests whether a load-chain of 8 constants of 64bit each gets vectorized into a wider load.
54 define amdgpu_kernel void @constant_load_2v4f64(ptr addrspace(4) noalias nocapture readonly %weights, ptr addrspace(1) noalias nocapture %out_ptr) {
55 ; GFX6-NOHSA-LABEL: constant_load_2v4f64:
56 ; GFX6-NOHSA: ; %bb.0: ; %entry
57 ; GFX6-NOHSA-NEXT: s_load_dwordx4 s[16:19], s[0:1], 0x9
58 ; GFX6-NOHSA-NEXT: s_waitcnt lgkmcnt(0)
59 ; GFX6-NOHSA-NEXT: s_load_dwordx2 s[24:25], s[18:19], 0x0
60 ; GFX6-NOHSA-NEXT: s_load_dwordx16 s[0:15], s[16:17], 0x0
61 ; GFX6-NOHSA-NEXT: s_mov_b32 s23, 0xf000
62 ; GFX6-NOHSA-NEXT: s_mov_b32 s22, -1
63 ; GFX6-NOHSA-NEXT: s_mov_b32 s20, s18
64 ; GFX6-NOHSA-NEXT: s_mov_b32 s21, s19
65 ; GFX6-NOHSA-NEXT: s_waitcnt lgkmcnt(0)
66 ; GFX6-NOHSA-NEXT: v_mov_b32_e32 v0, s24
67 ; GFX6-NOHSA-NEXT: v_mov_b32_e32 v1, s25
68 ; GFX6-NOHSA-NEXT: v_add_f64 v[0:1], s[0:1], v[0:1]
69 ; GFX6-NOHSA-NEXT: v_add_f64 v[0:1], s[2:3], v[0:1]
70 ; GFX6-NOHSA-NEXT: v_add_f64 v[0:1], s[4:5], v[0:1]
71 ; GFX6-NOHSA-NEXT: v_add_f64 v[0:1], s[6:7], v[0:1]
72 ; GFX6-NOHSA-NEXT: v_add_f64 v[0:1], s[8:9], v[0:1]
73 ; GFX6-NOHSA-NEXT: v_add_f64 v[0:1], s[10:11], v[0:1]
74 ; GFX6-NOHSA-NEXT: v_add_f64 v[0:1], s[12:13], v[0:1]
75 ; GFX6-NOHSA-NEXT: v_add_f64 v[0:1], s[14:15], v[0:1]
76 ; GFX6-NOHSA-NEXT: buffer_store_dwordx2 v[0:1], off, s[20:23], 0
77 ; GFX6-NOHSA-NEXT: s_endpgm
79 ; GFX7-HSA-LABEL: constant_load_2v4f64:
80 ; GFX7-HSA: ; %bb.0: ; %entry
81 ; GFX7-HSA-NEXT: s_load_dwordx4 s[16:19], s[4:5], 0x0
82 ; GFX7-HSA-NEXT: s_waitcnt lgkmcnt(0)
83 ; GFX7-HSA-NEXT: s_load_dwordx2 s[20:21], s[18:19], 0x0
84 ; GFX7-HSA-NEXT: s_load_dwordx16 s[0:15], s[16:17], 0x0
85 ; GFX7-HSA-NEXT: v_mov_b32_e32 v2, s18
86 ; GFX7-HSA-NEXT: v_mov_b32_e32 v3, s19
87 ; GFX7-HSA-NEXT: s_waitcnt lgkmcnt(0)
88 ; GFX7-HSA-NEXT: v_mov_b32_e32 v0, s20
89 ; GFX7-HSA-NEXT: v_mov_b32_e32 v1, s21
90 ; GFX7-HSA-NEXT: v_add_f64 v[0:1], s[0:1], v[0:1]
91 ; GFX7-HSA-NEXT: v_add_f64 v[0:1], s[2:3], v[0:1]
92 ; GFX7-HSA-NEXT: v_add_f64 v[0:1], s[4:5], v[0:1]
93 ; GFX7-HSA-NEXT: v_add_f64 v[0:1], s[6:7], v[0:1]
94 ; GFX7-HSA-NEXT: v_add_f64 v[0:1], s[8:9], v[0:1]
95 ; GFX7-HSA-NEXT: v_add_f64 v[0:1], s[10:11], v[0:1]
96 ; GFX7-HSA-NEXT: v_add_f64 v[0:1], s[12:13], v[0:1]
97 ; GFX7-HSA-NEXT: v_add_f64 v[0:1], s[14:15], v[0:1]
98 ; GFX7-HSA-NEXT: flat_store_dwordx2 v[2:3], v[0:1]
99 ; GFX7-HSA-NEXT: s_endpgm
101 ; GFX8-NOHSA-LABEL: constant_load_2v4f64:
102 ; GFX8-NOHSA: ; %bb.0: ; %entry
103 ; GFX8-NOHSA-NEXT: s_load_dwordx4 s[16:19], s[0:1], 0x24
104 ; GFX8-NOHSA-NEXT: s_waitcnt lgkmcnt(0)
105 ; GFX8-NOHSA-NEXT: s_load_dwordx2 s[20:21], s[18:19], 0x0
106 ; GFX8-NOHSA-NEXT: s_load_dwordx16 s[0:15], s[16:17], 0x0
107 ; GFX8-NOHSA-NEXT: v_mov_b32_e32 v2, s18
108 ; GFX8-NOHSA-NEXT: v_mov_b32_e32 v3, s19
109 ; GFX8-NOHSA-NEXT: s_waitcnt lgkmcnt(0)
110 ; GFX8-NOHSA-NEXT: v_mov_b32_e32 v0, s20
111 ; GFX8-NOHSA-NEXT: v_mov_b32_e32 v1, s21
112 ; GFX8-NOHSA-NEXT: v_add_f64 v[0:1], s[0:1], v[0:1]
113 ; GFX8-NOHSA-NEXT: v_add_f64 v[0:1], s[2:3], v[0:1]
114 ; GFX8-NOHSA-NEXT: v_add_f64 v[0:1], s[4:5], v[0:1]
115 ; GFX8-NOHSA-NEXT: v_add_f64 v[0:1], s[6:7], v[0:1]
116 ; GFX8-NOHSA-NEXT: v_add_f64 v[0:1], s[8:9], v[0:1]
117 ; GFX8-NOHSA-NEXT: v_add_f64 v[0:1], s[10:11], v[0:1]
118 ; GFX8-NOHSA-NEXT: v_add_f64 v[0:1], s[12:13], v[0:1]
119 ; GFX8-NOHSA-NEXT: v_add_f64 v[0:1], s[14:15], v[0:1]
120 ; GFX8-NOHSA-NEXT: flat_store_dwordx2 v[2:3], v[0:1]
121 ; GFX8-NOHSA-NEXT: s_endpgm
123 %out_ptr.promoted = load double, ptr addrspace(1) %out_ptr, align 4
124 %tmp = load double, ptr addrspace(4) %weights, align 4
125 %add = fadd double %tmp, %out_ptr.promoted
126 %arrayidx.1 = getelementptr inbounds double, ptr addrspace(4) %weights, i64 1
127 %tmp1 = load double, ptr addrspace(4) %arrayidx.1, align 4
128 %add.1 = fadd double %tmp1, %add
129 %arrayidx.2 = getelementptr inbounds double, ptr addrspace(4) %weights, i64 2
130 %tmp2 = load double, ptr addrspace(4) %arrayidx.2, align 4
131 %add.2 = fadd double %tmp2, %add.1
132 %arrayidx.3 = getelementptr inbounds double, ptr addrspace(4) %weights, i64 3
133 %tmp3 = load double, ptr addrspace(4) %arrayidx.3, align 4
134 %add.3 = fadd double %tmp3, %add.2
135 %arrayidx.4 = getelementptr inbounds double, ptr addrspace(4) %weights, i64 4
136 %tmp4 = load double, ptr addrspace(4) %arrayidx.4, align 4
137 %add.4 = fadd double %tmp4, %add.3
138 %arrayidx.5 = getelementptr inbounds double, ptr addrspace(4) %weights, i64 5
139 %tmp5 = load double, ptr addrspace(4) %arrayidx.5, align 4
140 %add.5 = fadd double %tmp5, %add.4
141 %arrayidx.6 = getelementptr inbounds double, ptr addrspace(4) %weights, i64 6
142 %tmp6 = load double, ptr addrspace(4) %arrayidx.6, align 4
143 %add.6 = fadd double %tmp6, %add.5
144 %arrayidx.7 = getelementptr inbounds double, ptr addrspace(4) %weights, i64 7
145 %tmp7 = load double, ptr addrspace(4) %arrayidx.7, align 4
146 %add.7 = fadd double %tmp7, %add.6
147 store double %add.7, ptr addrspace(1) %out_ptr, align 4