File: scalarized-load.ll

package info (click to toggle)
intel-graphics-compiler2 2.22.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 107,676 kB
  • sloc: cpp: 809,645; lisp: 288,070; ansic: 16,397; python: 4,010; yacc: 2,588; lex: 1,666; pascal: 314; sh: 186; makefile: 38
file content (278 lines) | stat: -rw-r--r-- 12,803 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
;=========================== begin_copyright_notice ============================
;
; Copyright (C) 2025 Intel Corporation
;
; SPDX-License-Identifier: MIT
;
;============================ end_copyright_notice =============================

; RUN: igc_opt --typed-pointers --enable-debugify --igc-promote-to-predicated-memory-access --platformbmg -S < %s 2>&1 | FileCheck %s

; Debug-info related check
; 11 warnings are related to 11 deleted phi instructions
; CHECK-COUNT-11: WARNING
; CHECK: CheckModuleDebugify: PASS

; Test basic logic
; CHECK-LABEL: @test1(
define <4 x float> @test1(<4 x float> addrspace(1)* %src, i1 %pred) {
entry:
; CHECK: br label %st
  br i1 %pred, label %st, label %exit

st:
; CHECK: %load = call <4 x float> @llvm.genx.GenISA.PredicatedLoad.v4f32.p1v4f32.v4f32(<4 x float> addrspace(1)* %src, i64 16, i1 %pred, <4 x float> zeroinitializer)
  %load = load <4 x float>, <4 x float> addrspace(1)* %src, align 16
  %.scalar = extractelement <4 x float> %load, i64 0
  %.scalar15 = extractelement <4 x float> %load, i64 1
  %.scalar16 = extractelement <4 x float> %load, i64 2
  %.scalar17 = extractelement <4 x float> %load, i64 3
  br label %exit

exit:
; CHECK-NOT: phi
; CHECK: %res0 = insertelement <4 x float> undef, float %.scalar, i64 0
; CHECK: %res1 = insertelement <4 x float> %res0, float %.scalar15, i64 1
; CHECK: %res2 = insertelement <4 x float> %res1, float %.scalar16, i64 2
; CHECK: %res3 = insertelement <4 x float> %res2, float %.scalar17, i64 3
  %bc311 = phi float [ %.scalar, %st ], [ 0.000000e+00, %entry ]
  %bc312 = phi float [ %.scalar15, %st ], [ 0.000000e+00, %entry ]
  %bc313 = phi float [ %.scalar16, %st ], [ 0.000000e+00, %entry ]
  %bc314 = phi float [ %.scalar17, %st ], [ 0.000000e+00, %entry ]
  %res0 = insertelement <4 x float> undef, float %bc311, i64 0
  %res1 = insertelement <4 x float> %res0, float %bc312, i64 1
  %res2 = insertelement <4 x float> %res1, float %bc313, i64 2
  %res3 = insertelement <4 x float> %res2, float %bc314, i64 3
  ret <4 x float> %res3
}

; Test non-constant merge values
; CHECK-LABEL: @test2(
define <4 x float> @test2(<4 x float> addrspace(1)* %src, i1 %pred, float %d1, float %d2, float %d3, float %d4) {
entry:
; CHECK: br label %st
  br i1 %pred, label %st, label %exit

st:
; CHECK: [[TMP0:%[0-9]+]] = insertelement <4 x float> poison, float %d1, i64 0
; CHECK: [[TMP1:%[0-9]+]] = insertelement <4 x float> [[TMP0]], float %d3, i64 1
; CHECK: [[TMP2:%[0-9]+]] = insertelement <4 x float> [[TMP1]], float %d2, i64 2
; CHECK: [[TMP3:%[0-9]+]] = insertelement <4 x float> [[TMP2]], float %d4, i64 3
; CHECK: %load = call <4 x float> @llvm.genx.GenISA.PredicatedLoad.v4f32.p1v4f32.v4f32(<4 x float> addrspace(1)* %src, i64 16, i1 %pred, <4 x float> [[TMP3]])
  %load = load <4 x float>, <4 x float> addrspace(1)* %src, align 16
  %.scalar = extractelement <4 x float> %load, i64 0
  %.scalar15 = extractelement <4 x float> %load, i64 1
  %.scalar16 = extractelement <4 x float> %load, i64 2
  %.scalar17 = extractelement <4 x float> %load, i64 3
  br label %exit

exit:
; CHECK-NOT: phi
; CHECK: %res0 = insertelement <4 x float> undef, float %.scalar, i64 0
; CHECK: %res1 = insertelement <4 x float> %res0, float %.scalar15, i64 1
; CHECK: %res2 = insertelement <4 x float> %res1, float %.scalar16, i64 2
; CHECK: %res3 = insertelement <4 x float> %res2, float %.scalar17, i64 3
  %bc311 = phi float [ %.scalar, %st ], [ %d1, %entry ]
  %bc312 = phi float [ %.scalar15, %st ], [ %d3, %entry ]
  %bc313 = phi float [ %.scalar16, %st ], [ %d2, %entry ]
  %bc314 = phi float [ %.scalar17, %st ], [ %d4, %entry ]
  %res0 = insertelement <4 x float> undef, float %bc311, i64 0
  %res1 = insertelement <4 x float> %res0, float %bc312, i64 1
  %res2 = insertelement <4 x float> %res1, float %bc313, i64 2
  %res3 = insertelement <4 x float> %res2, float %bc314, i64 3
  ret <4 x float> %res3
}

; skip case with non-constant indexes
; CHECK-LABEL: @test3(
define <4 x float> @test3(<4 x float> addrspace(1)* %src, i1 %pred, i64 %id0, i64 %id1, i64 %id2, i64 %id3) {
entry:
; CHECK: br i1 %pred, label %st, label %exit
  br i1 %pred, label %st, label %exit

st:
; CHECK: %load = load <4 x float>, <4 x float> addrspace(1)* %src, align 16
  %load = load <4 x float>, <4 x float> addrspace(1)* %src, align 16
  %.scalar = extractelement <4 x float> %load, i64 %id0
  %.scalar15 = extractelement <4 x float> %load, i64 %id1
  %.scalar16 = extractelement <4 x float> %load, i64 %id2
  %.scalar17 = extractelement <4 x float> %load, i64 %id3
  br label %exit

exit:
; CHECK: %bc311 = phi float [ %.scalar, %st ], [ 0.000000e+00, %entry ]
; CHECK: %bc312 = phi float [ %.scalar15, %st ], [ 0.000000e+00, %entry ]
; CHECK: %bc313 = phi float [ %.scalar16, %st ], [ 0.000000e+00, %entry ]
; CHECK: %bc314 = phi float [ %.scalar17, %st ], [ 0.000000e+00, %entry ]
  %bc311 = phi float [ %.scalar, %st ], [ 0.000000e+00, %entry ]
  %bc312 = phi float [ %.scalar15, %st ], [ 0.000000e+00, %entry ]
  %bc313 = phi float [ %.scalar16, %st ], [ 0.000000e+00, %entry ]
  %bc314 = phi float [ %.scalar17, %st ], [ 0.000000e+00, %entry ]
  %res0 = insertelement <4 x float> undef, float %bc311, i64 0
  %res1 = insertelement <4 x float> %res0, float %bc312, i64 1
  %res2 = insertelement <4 x float> %res1, float %bc313, i64 2
  %res3 = insertelement <4 x float> %res2, float %bc314, i64 3
  ret <4 x float> %res3
}

; Test load is not in the same BB
; CHECK-LABEL: @test4(
define <4 x float> @test4(<4 x float> addrspace(1)* %src, i1 %pred) {
entry:
; CHECK: %load = load <4 x float>, <4 x float> addrspace(1)* %src, align 16
; CHECK: br i1 %pred, label %st, label %exit
  %load = load <4 x float>, <4 x float> addrspace(1)* %src, align 16
  br i1 %pred, label %st, label %exit

st:
  %.scalar = extractelement <4 x float> %load, i64 0
  %.scalar15 = extractelement <4 x float> %load, i64 1
  %.scalar16 = extractelement <4 x float> %load, i64 2
  %.scalar17 = extractelement <4 x float> %load, i64 3
  br label %exit

exit:
; CHECK: %bc311 = phi float [ %.scalar, %st ], [ 0.000000e+00, %entry ]
; CHECK: %bc312 = phi float [ %.scalar15, %st ], [ 0.000000e+00, %entry ]
; CHECK: %bc313 = phi float [ %.scalar16, %st ], [ 0.000000e+00, %entry ]
; CHECK: %bc314 = phi float [ %.scalar17, %st ], [ 0.000000e+00, %entry ]
  %bc311 = phi float [ %.scalar, %st ], [ 0.000000e+00, %entry ]
  %bc312 = phi float [ %.scalar15, %st ], [ 0.000000e+00, %entry ]
  %bc313 = phi float [ %.scalar16, %st ], [ 0.000000e+00, %entry ]
  %bc314 = phi float [ %.scalar17, %st ], [ 0.000000e+00, %entry ]
  %res0 = insertelement <4 x float> undef, float %bc311, i64 0
  %res1 = insertelement <4 x float> %res0, float %bc312, i64 1
  %res2 = insertelement <4 x float> %res1, float %bc313, i64 2
  %res3 = insertelement <4 x float> %res2, float %bc314, i64 3
  ret <4 x float> %res3
}

; not all values are used
; CHECK-LABEL: @test5(
define <4 x float> @test5(<4 x float> addrspace(1)* %src, i1 %pred, float %d1, float %d2, float %d3) {
entry:
; CHECK: br label %st
  br i1 %pred, label %st, label %exit

st:
; CHECK: [[TMP0:%[0-9]+]] = insertelement <4 x float> poison, float %d1, i64 0
; CHECK: [[TMP1:%[0-9]+]] = insertelement <4 x float> [[TMP0]], float %d2, i64 1
; CHECK: [[TMP2:%[0-9]+]] = insertelement <4 x float> [[TMP1]], float 0.000000e+00, i64 2
; CHECK: [[TMP3:%[0-9]+]] = insertelement <4 x float> [[TMP2]], float %d3, i64 3
; CHECK: %load = call <4 x float> @llvm.genx.GenISA.PredicatedLoad.v4f32.p1v4f32.v4f32(<4 x float> addrspace(1)* %src, i64 16, i1 %pred, <4 x float> [[TMP3]])
  %load = load <4 x float>, <4 x float> addrspace(1)* %src, align 16
  %.scalar = extractelement <4 x float> %load, i64 0
  %.scalar15 = extractelement <4 x float> %load, i64 1
  %.scalar16 = extractelement <4 x float> %load, i64 2
  %.scalar17 = extractelement <4 x float> %load, i64 3
  br label %exit

exit:
; CHECK-NOT: phi
; CHECK: %res0 = insertelement <4 x float> undef, float %.scalar, i64 0
; CHECK: %res1 = insertelement <4 x float> %res0, float %.scalar15, i64 1
; CHECK: %res3 = insertelement <4 x float> %res1, float %.scalar17, i64 3
  %bc311 = phi float [ %.scalar, %st ], [ %d1, %entry ]
  %bc312 = phi float [ %.scalar15, %st ], [ %d2, %entry ]
  %bc314 = phi float [ %.scalar17, %st ], [ %d3, %entry ]
  %res0 = insertelement <4 x float> undef, float %bc311, i64 0
  %res1 = insertelement <4 x float> %res0, float %bc312, i64 1
  %res3 = insertelement <4 x float> %res1, float %bc314, i64 3
  ret <4 x float> %res3
}

; Test extractelement is not from load
; CHECK-LABEL: @test6(
define <4 x float> @test6(<4 x float> addrspace(1)* %src, i1 %pred, <4 x float> %data) {
entry:
; CHECK: br i1 %pred, label %st, label %exit
  br i1 %pred, label %st, label %exit

st:
  %.scalar = extractelement <4 x float> %data, i64 0
  %.scalar15 = extractelement <4 x float> %data, i64 1
  %.scalar16 = extractelement <4 x float> %data, i64 2
  %.scalar17 = extractelement <4 x float> %data, i64 3
  br label %exit

exit:
; CHECK: %bc311 = phi float [ %.scalar, %st ], [ 0.000000e+00, %entry ]
; CHECK: %bc312 = phi float [ %.scalar15, %st ], [ 0.000000e+00, %entry ]
; CHECK: %bc313 = phi float [ %.scalar16, %st ], [ 0.000000e+00, %entry ]
; CHECK: %bc314 = phi float [ %.scalar17, %st ], [ 0.000000e+00, %entry ]
  %bc311 = phi float [ %.scalar, %st ], [ 0.000000e+00, %entry ]
  %bc312 = phi float [ %.scalar15, %st ], [ 0.000000e+00, %entry ]
  %bc313 = phi float [ %.scalar16, %st ], [ 0.000000e+00, %entry ]
  %bc314 = phi float [ %.scalar17, %st ], [ 0.000000e+00, %entry ]
  %res0 = insertelement <4 x float> undef, float %bc311, i64 0
  %res1 = insertelement <4 x float> %res0, float %bc312, i64 1
  %res2 = insertelement <4 x float> %res1, float %bc313, i64 2
  %res3 = insertelement <4 x float> %res2, float %bc314, i64 3
  ret <4 x float> %res3
}

; Test load can not be converted to predicated load
; CHECK-LABEL: @test7(
define <4 x float> @test7(<4 x float> addrspace(1)* %src, i1 %pred) {
entry:
; CHECK: br i1 %pred, label %st, label %exit
  br i1 %pred, label %st, label %exit

st:
; CHECK: %load = load volatile <4 x float>, <4 x float> addrspace(1)* %src, align 16
  %load = load volatile <4 x float>, <4 x float> addrspace(1)* %src, align 16
  %.scalar = extractelement <4 x float> %load, i64 0
  %.scalar15 = extractelement <4 x float> %load, i64 1
  %.scalar16 = extractelement <4 x float> %load, i64 2
  %.scalar17 = extractelement <4 x float> %load, i64 3
  br label %exit

exit:
; CHECK: %bc311 = phi float [ %.scalar, %st ], [ 0.000000e+00, %entry ]
; CHECK: %bc312 = phi float [ %.scalar15, %st ], [ 0.000000e+00, %entry ]
; CHECK: %bc313 = phi float [ %.scalar16, %st ], [ 0.000000e+00, %entry ]
; CHECK: %bc314 = phi float [ %.scalar17, %st ], [ 0.000000e+00, %entry ]
  %bc311 = phi float [ %.scalar, %st ], [ 0.000000e+00, %entry ]
  %bc312 = phi float [ %.scalar15, %st ], [ 0.000000e+00, %entry ]
  %bc313 = phi float [ %.scalar16, %st ], [ 0.000000e+00, %entry ]
  %bc314 = phi float [ %.scalar17, %st ], [ 0.000000e+00, %entry ]
  %res0 = insertelement <4 x float> undef, float %bc311, i64 0
  %res1 = insertelement <4 x float> %res0, float %bc312, i64 1
  %res2 = insertelement <4 x float> %res1, float %bc313, i64 2
  %res3 = insertelement <4 x float> %res2, float %bc314, i64 3
  ret <4 x float> %res3
}

; Test index is outside of vector size
; CHECK-LABEL: @test8(
define <4 x float> @test8(<4 x float> addrspace(1)* %src, i1 %pred) {
entry:
; CHECK: br i1 %pred, label %st, label %exit
  br i1 %pred, label %st, label %exit

st:
; CHECK: %load = load <4 x float>, <4 x float> addrspace(1)* %src, align 16
  %load = load <4 x float>, <4 x float> addrspace(1)* %src, align 16
  %.scalar = extractelement <4 x float> %load, i64 0
  %.scalar15 = extractelement <4 x float> %load, i64 1
  %.scalar16 = extractelement <4 x float> %load, i64 2
  %.scalar17 = extractelement <4 x float> %load, i64 4
  br label %exit

exit:
; CHECK: %bc311 = phi float [ %.scalar, %st ], [ 0.000000e+00, %entry ]
; CHECK: %bc312 = phi float [ %.scalar15, %st ], [ 0.000000e+00, %entry ]
; CHECK: %bc313 = phi float [ %.scalar16, %st ], [ 0.000000e+00, %entry ]
; CHECK: %bc314 = phi float [ %.scalar17, %st ], [ 0.000000e+00, %entry ]
  %bc311 = phi float [ %.scalar, %st ], [ 0.000000e+00, %entry ]
  %bc312 = phi float [ %.scalar15, %st ], [ 0.000000e+00, %entry ]
  %bc313 = phi float [ %.scalar16, %st ], [ 0.000000e+00, %entry ]
  %bc314 = phi float [ %.scalar17, %st ], [ 0.000000e+00, %entry ]
  %res0 = insertelement <4 x float> undef, float %bc311, i64 0
  %res1 = insertelement <4 x float> %res0, float %bc312, i64 1
  %res2 = insertelement <4 x float> %res1, float %bc313, i64 2
  %res3 = insertelement <4 x float> %res2, float %bc314, i64 3
  ret <4 x float> %res3
}

; CHECK: warning: Index 4 is >= vector size 4