skia2/tests/sksl/runtime/SwitchWithLoops.skvm
John Stiles c809e5ba9f Optimize commutative operations in SkVM.
We now canonicalize commutative operations by ordering their value IDs.
The lower-numbered value ID is always placed first into a commutative
instruction. In other words, this instruction:
   bit_and result, v7, v5

Would be silently converted to this:
   bit_and result, v5, v7

This will allow these two logically-equivalent instructions to be
deduplicated:
   bit_and result, v7, v5
   bit_and result, v5, v7

Of course, deduplicating these ops can unlock additional free CSE/DCE.
The affected instructions are listed in http://review.skia.org/473238

Change-Id: Ib9beb79d6b72d7903184aaa9a53e8e5a02ae126d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/473239
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2021-11-18 21:27:17 +00:00

298 lines
7.5 KiB
Plaintext

18 registers, 295 instructions:
0 r0 = uniform32 ptr0 4
1 r1 = uniform32 ptr0 8
2 r2 = uniform32 ptr0 C
3 r3 = uniform32 ptr0 10
4 r4 = uniform32 ptr0 14
5 r5 = uniform32 ptr0 18
6 r6 = uniform32 ptr0 1C
7 r7 = uniform32 ptr0 20
8 r8 = splat FFFFFFFF (nan)
9 r9 = trunc r1
10 r10 = splat 1 (1.4012985e-45)
11 r9 = eq_i32 r9 r10
12 r11 = bit_and r10 r9
13 r12 = bit_xor r8 r9
14 r13 = add_i32 r10 r11
15 r14 = bit_and r9 r12
16 r11 = select r14 r13 r11
17 r13 = add_i32 r10 r11
18 r11 = select r14 r13 r11
19 r14 = bit_xor r8 r14
20 r14 = bit_and r12 r14
21 r12 = add_i32 r10 r11
22 r13 = bit_and r9 r14
23 r11 = select r13 r12 r11
24 r12 = splat 2 (2.8025969e-45)
25 r15 = add_i32 r10 r11
26 r11 = select r13 r15 r11
27 r13 = bit_xor r8 r13
28 r13 = bit_and r14 r13
29 r14 = add_i32 r10 r11
30 r15 = bit_and r9 r13
31 r11 = select r15 r14 r11
32 r14 = add_i32 r10 r11
33 r11 = select r15 r14 r11
34 r15 = bit_xor r8 r15
35 r15 = bit_and r13 r15
36 r13 = add_i32 r10 r11
37 r14 = bit_and r9 r15
38 r11 = select r14 r13 r11
39 r13 = add_i32 r10 r11
40 r11 = select r14 r13 r11
41 r14 = bit_xor r8 r14
42 r14 = bit_and r15 r14
43 r15 = add_i32 r10 r11
44 r13 = bit_and r9 r14
45 r11 = select r13 r15 r11
46 r15 = add_i32 r10 r11
47 r11 = select r13 r15 r11
48 r13 = bit_xor r8 r13
49 r13 = bit_and r14 r13
50 r14 = add_i32 r10 r11
51 r15 = bit_and r9 r13
52 r11 = select r15 r14 r11
53 r14 = add_i32 r10 r11
54 r11 = select r15 r14 r11
55 r15 = bit_xor r8 r15
56 r15 = bit_and r13 r15
57 r13 = add_i32 r10 r11
58 r14 = bit_and r9 r15
59 r11 = select r14 r13 r11
60 r13 = add_i32 r10 r11
61 r11 = select r14 r13 r11
62 r14 = bit_xor r8 r14
63 r14 = bit_and r15 r14
64 r15 = add_i32 r10 r11
65 r13 = bit_and r9 r14
66 r11 = select r13 r15 r11
67 r15 = add_i32 r10 r11
68 r11 = select r13 r15 r11
69 r13 = bit_xor r8 r13
70 r13 = bit_and r14 r13
71 r14 = add_i32 r10 r11
72 r15 = bit_and r9 r13
73 r11 = select r15 r14 r11
74 r14 = add_i32 r10 r11
75 r11 = select r15 r14 r11
76 r15 = bit_xor r8 r15
77 r15 = bit_and r13 r15
78 r13 = add_i32 r10 r11
79 r15 = bit_and r9 r15
80 r11 = select r15 r13 r11
81 r11 = add_i32 r10 r11
82 r11 = eq_i32 r12 r11
83 r12 = bit_and r9 r11
84 r13 = bit_and r10 r12
85 r15 = bit_xor r8 r12
86 r14 = add_i32 r10 r13
87 r16 = bit_and r12 r15
88 r13 = select r16 r14 r13
89 r15 = bit_or r12 r15
90 r14 = add_i32 r10 r13
91 r16 = bit_and r12 r15
92 r13 = select r16 r14 r13
93 r14 = bit_xor r8 r16
94 r14 = bit_and r15 r14
95 r15 = add_i32 r10 r13
96 r17 = bit_and r12 r14
97 r13 = select r17 r15 r13
98 r14 = bit_or r16 r14
99 r16 = add_i32 r10 r13
100 r15 = bit_and r12 r14
101 r13 = select r15 r16 r13
102 r16 = bit_xor r8 r15
103 r16 = bit_and r14 r16
104 r14 = add_i32 r10 r13
105 r17 = bit_and r12 r16
106 r13 = select r17 r14 r13
107 r16 = bit_or r15 r16
108 r15 = add_i32 r10 r13
109 r14 = bit_and r12 r16
110 r13 = select r14 r15 r13
111 r15 = bit_xor r8 r14
112 r15 = bit_and r16 r15
113 r16 = add_i32 r10 r13
114 r17 = bit_and r12 r15
115 r13 = select r17 r16 r13
116 r15 = bit_or r14 r15
117 r14 = add_i32 r10 r13
118 r16 = bit_and r12 r15
119 r13 = select r16 r14 r13
120 r14 = bit_xor r8 r16
121 r14 = bit_and r15 r14
122 r15 = add_i32 r10 r13
123 r17 = bit_and r12 r14
124 r13 = select r17 r15 r13
125 r14 = bit_or r16 r14
126 r16 = add_i32 r10 r13
127 r15 = bit_and r12 r14
128 r13 = select r15 r16 r13
129 r16 = bit_xor r8 r15
130 r16 = bit_and r14 r16
131 r14 = add_i32 r10 r13
132 r17 = bit_and r12 r16
133 r13 = select r17 r14 r13
134 r16 = bit_or r15 r16
135 r15 = add_i32 r10 r13
136 r14 = bit_and r12 r16
137 r13 = select r14 r15 r13
138 r15 = bit_xor r8 r14
139 r15 = bit_and r16 r15
140 r16 = add_i32 r10 r13
141 r17 = bit_and r12 r15
142 r13 = select r17 r16 r13
143 r15 = bit_or r14 r15
144 r14 = add_i32 r10 r13
145 r16 = bit_and r12 r15
146 r13 = select r16 r14 r13
147 r14 = bit_xor r8 r16
148 r14 = bit_and r15 r14
149 r15 = add_i32 r10 r13
150 r17 = bit_and r12 r14
151 r13 = select r17 r15 r13
152 r14 = bit_or r16 r14
153 r16 = add_i32 r10 r13
154 r15 = bit_and r12 r14
155 r13 = select r15 r16 r13
156 r16 = bit_xor r8 r15
157 r16 = bit_and r14 r16
158 r14 = add_i32 r10 r13
159 r17 = bit_and r12 r16
160 r13 = select r17 r14 r13
161 r16 = bit_or r15 r16
162 r15 = add_i32 r10 r13
163 r14 = bit_and r12 r16
164 r13 = select r14 r15 r13
165 r14 = bit_xor r8 r14
166 r14 = bit_and r16 r14
167 r16 = add_i32 r10 r13
168 r14 = bit_and r12 r14
169 r13 = select r14 r16 r13
170 r16 = add_i32 r10 r13
171 r13 = select r11 r16 r13
172 r16 = splat B (1.5414283e-44)
173 r16 = eq_i32 r13 r16
174 r16 = bit_and r11 r16
175 r16 = bit_and r11 r16
176 r9 = bit_and r9 r16
177 r11 = bit_and r10 r9
178 r13 = bit_xor r8 r9
179 r13 = bit_and r16 r13
180 r14 = add_i32 r10 r11
181 r12 = bit_xor r8 r13
182 r15 = bit_and r16 r12
183 r11 = select r15 r14 r11
184 r14 = add_i32 r10 r11
185 r15 = bit_and r9 r12
186 r11 = select r15 r14 r11
187 r15 = bit_xor r8 r15
188 r15 = bit_and r16 r15
189 r15 = bit_and r12 r15
190 r15 = bit_or r13 r15
191 r13 = add_i32 r10 r11
192 r12 = bit_xor r8 r15
193 r14 = bit_and r16 r12
194 r11 = select r14 r13 r11
195 r13 = add_i32 r10 r11
196 r14 = bit_and r9 r12
197 r11 = select r14 r13 r11
198 r14 = bit_xor r8 r14
199 r14 = bit_and r16 r14
200 r14 = bit_and r12 r14
201 r14 = bit_or r15 r14
202 r15 = add_i32 r10 r11
203 r12 = bit_xor r8 r14
204 r13 = bit_and r16 r12
205 r11 = select r13 r15 r11
206 r15 = add_i32 r10 r11
207 r13 = bit_and r9 r12
208 r11 = select r13 r15 r11
209 r13 = bit_xor r8 r13
210 r13 = bit_and r16 r13
211 r13 = bit_and r12 r13
212 r13 = bit_or r14 r13
213 r14 = add_i32 r10 r11
214 r12 = bit_xor r8 r13
215 r15 = bit_and r16 r12
216 r11 = select r15 r14 r11
217 r14 = add_i32 r10 r11
218 r15 = bit_and r9 r12
219 r11 = select r15 r14 r11
220 r15 = bit_xor r8 r15
221 r15 = bit_and r16 r15
222 r15 = bit_and r12 r15
223 r15 = bit_or r13 r15
224 r13 = add_i32 r10 r11
225 r12 = bit_xor r8 r15
226 r14 = bit_and r16 r12
227 r11 = select r14 r13 r11
228 r13 = add_i32 r10 r11
229 r14 = bit_and r9 r12
230 r11 = select r14 r13 r11
231 r14 = bit_xor r8 r14
232 r14 = bit_and r16 r14
233 r14 = bit_and r12 r14
234 r14 = bit_or r15 r14
235 r15 = add_i32 r10 r11
236 r12 = bit_xor r8 r14
237 r13 = bit_and r16 r12
238 r11 = select r13 r15 r11
239 r15 = add_i32 r10 r11
240 r13 = bit_and r9 r12
241 r11 = select r13 r15 r11
242 r13 = bit_xor r8 r13
243 r13 = bit_and r16 r13
244 r13 = bit_and r12 r13
245 r13 = bit_or r14 r13
246 r14 = add_i32 r10 r11
247 r12 = bit_xor r8 r13
248 r15 = bit_and r16 r12
249 r11 = select r15 r14 r11
250 r14 = add_i32 r10 r11
251 r15 = bit_and r9 r12
252 r11 = select r15 r14 r11
253 r15 = bit_xor r8 r15
254 r15 = bit_and r16 r15
255 r15 = bit_and r12 r15
256 r15 = bit_or r13 r15
257 r13 = add_i32 r10 r11
258 r12 = bit_xor r8 r15
259 r14 = bit_and r16 r12
260 r11 = select r14 r13 r11
261 r13 = add_i32 r10 r11
262 r14 = bit_and r9 r12
263 r11 = select r14 r13 r11
264 r14 = bit_xor r8 r14
265 r14 = bit_and r16 r14
266 r14 = bit_and r12 r14
267 r14 = bit_or r15 r14
268 r15 = add_i32 r10 r11
269 r12 = bit_xor r8 r14
270 r13 = bit_and r16 r12
271 r11 = select r13 r15 r11
272 r15 = add_i32 r10 r11
273 r9 = bit_and r9 r12
274 r11 = select r9 r15 r11
275 r9 = bit_xor r8 r9
276 r9 = bit_and r16 r9
277 r9 = bit_and r12 r9
278 r9 = bit_or r14 r9
279 r10 = add_i32 r10 r11
280 r9 = bit_xor r8 r9
281 r9 = bit_and r16 r9
282 r11 = select r9 r10 r11
283 r10 = splat 14 (2.8025969e-44)
284 r10 = eq_i32 r11 r10
285 r10 = bit_and r9 r10
286 r10 = bit_and r16 r10
287 r4 = select r10 r0 r4
288 r5 = select r10 r1 r5
289 r6 = select r10 r2 r6
290 r7 = select r10 r3 r7
loop:
291 store32 ptr1 r4
292 store32 ptr2 r5
293 store32 ptr3 r6
294 store32 ptr4 r7