• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 Collabora, Ltd.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21  * SOFTWARE.
22  */
23 
24 #include "compiler.h"
25 #include "bi_test.h"
26 #include "bi_builder.h"
27 
28 #include <gtest/gtest.h>
29 
30 static void
bi_optimizer(bi_context * ctx)31 bi_optimizer(bi_context *ctx)
32 {
33    bi_opt_mod_prop_forward(ctx);
34    bi_opt_mod_prop_backward(ctx);
35    bi_opt_dead_code_eliminate(ctx);
36 }
37 
38 #define CASE(instr, expected) INSTRUCTION_CASE(instr, expected, bi_optimizer)
39 #define NEGCASE(instr) CASE(instr, instr)
40 
41 class Optimizer : public testing::Test {
42 protected:
Optimizer()43    Optimizer() {
44       mem_ctx = ralloc_context(NULL);
45 
46       reg     = bi_register(0);
47       x       = bi_register(1);
48       y       = bi_register(2);
49       negabsx = bi_neg(bi_abs(x));
50    }
51 
~Optimizer()52    ~Optimizer() {
53       ralloc_free(mem_ctx);
54    }
55 
56    void *mem_ctx;
57 
58    bi_index reg;
59    bi_index x;
60    bi_index y;
61    bi_index negabsx;
62 };
63 
TEST_F(Optimizer,FusedFABSNEG)64 TEST_F(Optimizer, FusedFABSNEG)
65 {
66    CASE(bi_fadd_f32_to(b, reg, bi_fabsneg_f32(b, bi_abs(x)), y),
67         bi_fadd_f32_to(b, reg, bi_abs(x), y));
68 
69    CASE(bi_fadd_f32_to(b, reg, bi_fabsneg_f32(b, bi_neg(x)), y),
70         bi_fadd_f32_to(b, reg, bi_neg(x), y));
71 
72    CASE(bi_fadd_f32_to(b, reg, bi_fabsneg_f32(b, negabsx), y),
73         bi_fadd_f32_to(b, reg, negabsx, y));
74 
75    CASE(bi_fadd_f32_to(b, reg, bi_fabsneg_f32(b, x), y),
76         bi_fadd_f32_to(b, reg, x, y));
77 
78    CASE(bi_fmin_f32_to(b, reg, bi_fabsneg_f32(b, negabsx), bi_neg(y)),
79         bi_fmin_f32_to(b, reg, negabsx, bi_neg(y)));
80 }
81 
TEST_F(Optimizer,FusedFABSNEGForFP16)82 TEST_F(Optimizer, FusedFABSNEGForFP16)
83 {
84    CASE(bi_fadd_v2f16_to(b, reg, bi_fabsneg_v2f16(b, negabsx), y),
85         bi_fadd_v2f16_to(b, reg, negabsx, y));
86 
87    CASE(bi_fmin_v2f16_to(b, reg, bi_fabsneg_v2f16(b, negabsx), bi_neg(y)),
88         bi_fmin_v2f16_to(b, reg, negabsx, bi_neg(y)));
89 }
90 
TEST_F(Optimizer,FuseFADD_F32WithEqualSourcesAbsAbsAndClamp)91 TEST_F(Optimizer, FuseFADD_F32WithEqualSourcesAbsAbsAndClamp)
92 {
93    CASE({
94          bi_instr *I = bi_fadd_f32_to(b, reg, bi_fabsneg_f32(b, bi_abs(x)), bi_abs(x));
95          I->clamp = BI_CLAMP_CLAMP_0_1;
96    }, {
97          bi_instr *I = bi_fadd_f32_to(b, reg, bi_abs(x), bi_abs(x));
98          I->clamp = BI_CLAMP_CLAMP_0_1;
99    });
100 
101    CASE({
102          bi_instr *I = bi_fadd_f32_to(b, reg, bi_abs(x), bi_fabsneg_f32(b, bi_abs(x)));
103          I->clamp = BI_CLAMP_CLAMP_0_1;
104    }, {
105          bi_instr *I = bi_fadd_f32_to(b, reg, bi_abs(x), bi_abs(x));
106          I->clamp = BI_CLAMP_CLAMP_0_1;
107    });
108 
109    CASE({
110          bi_instr *I = bi_fclamp_f32_to(b, reg, bi_fadd_f32(b, bi_abs(x), bi_abs(x)));
111          I->clamp = BI_CLAMP_CLAMP_0_INF;
112    }, {
113          bi_instr *I = bi_fadd_f32_to(b, reg, bi_abs(x), bi_abs(x));
114          I->clamp = BI_CLAMP_CLAMP_0_INF;
115    });
116 }
117 
TEST_F(Optimizer,FuseFADD_V2F16WithDifferentSourcesAbsAbsAndClamp)118 TEST_F(Optimizer, FuseFADD_V2F16WithDifferentSourcesAbsAbsAndClamp)
119 {
120    CASE({
121          bi_instr *I = bi_fadd_v2f16_to(b, reg, bi_fabsneg_v2f16(b, bi_abs(x)), bi_abs(y));
122          I->clamp = BI_CLAMP_CLAMP_0_1;
123    }, {
124          bi_instr *I = bi_fadd_v2f16_to(b, reg, bi_abs(x), bi_abs(y));
125          I->clamp = BI_CLAMP_CLAMP_0_1;
126    });
127 
128    CASE({
129          bi_instr *I = bi_fadd_v2f16_to(b, reg, bi_abs(x), bi_fabsneg_v2f16(b, bi_abs(y)));
130          I->clamp = BI_CLAMP_CLAMP_0_1;
131    }, {
132          bi_instr *I = bi_fadd_v2f16_to(b, reg, bi_abs(x), bi_abs(y));
133          I->clamp = BI_CLAMP_CLAMP_0_1;
134    });
135 
136    CASE({
137          bi_instr *I = bi_fclamp_v2f16_to(b, reg, bi_fadd_v2f16(b, bi_abs(x), bi_abs(y)));
138          I->clamp = BI_CLAMP_CLAMP_0_INF;
139    }, {
140          bi_instr *I = bi_fadd_v2f16_to(b, reg, bi_abs(x), bi_abs(y));
141          I->clamp = BI_CLAMP_CLAMP_0_INF;
142    });
143 }
144 
TEST_F(Optimizer,AvoidFADD_V2F16WithEqualSourcesAbsAbsAndClamp)145 TEST_F(Optimizer, AvoidFADD_V2F16WithEqualSourcesAbsAbsAndClamp)
146 {
147    NEGCASE({
148          bi_instr *I = bi_fadd_v2f16_to(b, reg, bi_fabsneg_v2f16(b, bi_abs(x)), bi_abs(x));
149          I->clamp = BI_CLAMP_CLAMP_0_1;
150    });
151 
152    NEGCASE({
153          bi_instr *I = bi_fadd_v2f16_to(b, reg, bi_abs(x), bi_fabsneg_v2f16(b, bi_abs(x)));
154          I->clamp = BI_CLAMP_CLAMP_0_1;
155    });
156 
157    NEGCASE({
158       bi_instr *I = bi_fclamp_v2f16_to(b, reg, bi_fadd_v2f16(b, bi_abs(x), bi_abs(x)));
159       I->clamp = BI_CLAMP_CLAMP_0_INF;
160    });
161 }
162 
TEST_F(Optimizer,SwizzlesComposedForFP16)163 TEST_F(Optimizer, SwizzlesComposedForFP16)
164 {
165    CASE(bi_fadd_v2f16_to(b, reg, bi_fabsneg_v2f16(b, bi_swz_16(negabsx, true, false)), y),
166         bi_fadd_v2f16_to(b, reg, bi_swz_16(negabsx, true, false), y));
167 
168    CASE(bi_fadd_v2f16_to(b, reg, bi_swz_16(bi_fabsneg_v2f16(b, negabsx), true, false), y),
169         bi_fadd_v2f16_to(b, reg, bi_swz_16(negabsx, true, false), y));
170 
171    CASE(bi_fadd_v2f16_to(b, reg, bi_swz_16(bi_fabsneg_v2f16(b, bi_swz_16(negabsx, true, false)), true, false), y),
172         bi_fadd_v2f16_to(b, reg, negabsx, y));
173 
174    CASE(bi_fadd_v2f16_to(b, reg, bi_swz_16(bi_fabsneg_v2f16(b, bi_half(negabsx, false)), true, false), y),
175         bi_fadd_v2f16_to(b, reg, bi_half(negabsx, false), y));
176 
177    CASE(bi_fadd_v2f16_to(b, reg, bi_swz_16(bi_fabsneg_v2f16(b, bi_half(negabsx, true)), true, false), y),
178         bi_fadd_v2f16_to(b, reg, bi_half(negabsx, true), y));
179 }
180 
TEST_F(Optimizer,PreserveWidens)181 TEST_F(Optimizer, PreserveWidens)
182 {
183    /* Check that widens are passed through */
184    CASE(bi_fadd_f32_to(b, reg, bi_fabsneg_f32(b, bi_half(negabsx, false)), y),
185         bi_fadd_f32_to(b, reg, bi_half(negabsx, false), y));
186 
187    CASE(bi_fadd_f32_to(b, reg, bi_fabsneg_f32(b, bi_half(negabsx, true)), y),
188         bi_fadd_f32_to(b, reg, bi_half(negabsx, true), y));
189 
190    CASE(bi_fadd_f32_to(b, reg, bi_fabsneg_f32(b, bi_half(x, true)), bi_fabsneg_f32(b, bi_half(x, false))),
191         bi_fadd_f32_to(b, reg, bi_half(x, true), bi_half(x, false)));
192 }
193 
TEST_F(Optimizer,DoNotMixSizesForFABSNEG)194 TEST_F(Optimizer, DoNotMixSizesForFABSNEG)
195 {
196    /* Refuse to mix sizes for fabsneg, that's wrong */
197    NEGCASE(bi_fadd_f32_to(b, reg, bi_fabsneg_v2f16(b, negabsx), y));
198    NEGCASE(bi_fadd_v2f16_to(b, reg, bi_fabsneg_f32(b, negabsx), y));
199 }
200 
TEST_F(Optimizer,AvoidZeroAndFABSNEGFootguns)201 TEST_F(Optimizer, AvoidZeroAndFABSNEGFootguns)
202 {
203    /* It's tempting to use addition by 0.0 as the absneg primitive, but that
204     * has footguns around signed zero and round modes. Check we don't
205     * incorrectly fuse these rules. */
206 
207    bi_index zero = bi_zero();
208 
209    NEGCASE(bi_fadd_f32_to(b, reg, bi_fadd_f32(b, bi_abs(x), zero), y));
210    NEGCASE(bi_fadd_f32_to(b, reg, bi_fadd_f32(b, bi_neg(x), zero), y));
211    NEGCASE(bi_fadd_f32_to(b, reg, bi_fadd_f32(b, bi_neg(bi_abs(x)), zero), y));
212    NEGCASE(bi_fadd_f32_to(b, reg, bi_fadd_f32(b, x, zero), y));
213 }
214 
TEST_F(Optimizer,ClampsPropagated)215 TEST_F(Optimizer, ClampsPropagated)
216 {
217    CASE({
218       bi_instr *I = bi_fclamp_f32_to(b, reg, bi_fadd_f32(b, x, y));
219       I->clamp = BI_CLAMP_CLAMP_0_INF;
220    }, {
221       bi_instr *I = bi_fadd_f32_to(b, reg, x, y);
222       I->clamp = BI_CLAMP_CLAMP_0_INF;
223    });
224 
225    CASE({
226       bi_instr *I = bi_fclamp_v2f16_to(b, reg, bi_fadd_v2f16(b, x, y));
227       I->clamp = BI_CLAMP_CLAMP_0_1;
228    }, {
229       bi_instr *I = bi_fadd_v2f16_to(b, reg, x, y);
230       I->clamp = BI_CLAMP_CLAMP_0_1;
231    });
232 }
233 
234 
TEST_F(Optimizer,ClampsComposed)235 TEST_F(Optimizer, ClampsComposed)
236 {
237    CASE({
238       bi_instr *I = bi_fadd_f32_to(b, bi_temp(b->shader), x, y);
239       bi_instr *J = bi_fclamp_f32_to(b, reg, I->dest[0]);
240       I->clamp = BI_CLAMP_CLAMP_M1_1;
241       J->clamp = BI_CLAMP_CLAMP_0_INF;
242    }, {
243       bi_instr *I = bi_fadd_f32_to(b, reg, x, y);
244       I->clamp = BI_CLAMP_CLAMP_0_1;
245    });
246 
247    CASE({
248       bi_instr *I = bi_fadd_f32_to(b, bi_temp(b->shader), x, y);
249       bi_instr *J = bi_fclamp_f32_to(b, reg, I->dest[0]);
250       I->clamp = BI_CLAMP_CLAMP_0_1;
251       J->clamp = BI_CLAMP_CLAMP_0_INF;
252    }, {
253       bi_instr *I = bi_fadd_f32_to(b, reg, x, y);
254       I->clamp = BI_CLAMP_CLAMP_0_1;
255    });
256 
257    CASE({
258       bi_instr *I = bi_fadd_f32_to(b, bi_temp(b->shader), x, y);
259       bi_instr *J = bi_fclamp_f32_to(b, reg, I->dest[0]);
260       I->clamp = BI_CLAMP_CLAMP_0_INF;
261       J->clamp = BI_CLAMP_CLAMP_0_INF;
262    }, {
263       bi_instr *I = bi_fadd_f32_to(b, reg, x, y);
264       I->clamp = BI_CLAMP_CLAMP_0_INF;
265    });
266 
267    CASE({
268       bi_instr *I = bi_fadd_v2f16_to(b, bi_temp(b->shader), x, y);
269       bi_instr *J = bi_fclamp_v2f16_to(b, reg, I->dest[0]);
270       I->clamp = BI_CLAMP_CLAMP_M1_1;
271       J->clamp = BI_CLAMP_CLAMP_0_INF;
272    }, {
273       bi_instr *I = bi_fadd_v2f16_to(b, reg, x, y);
274       I->clamp = BI_CLAMP_CLAMP_0_1;
275    });
276 
277    CASE({
278       bi_instr *I = bi_fadd_v2f16_to(b, bi_temp(b->shader), x, y);
279       bi_instr *J = bi_fclamp_v2f16_to(b, reg, I->dest[0]);
280       I->clamp = BI_CLAMP_CLAMP_0_1;
281       J->clamp = BI_CLAMP_CLAMP_0_INF;
282    }, {
283       bi_instr *I = bi_fadd_v2f16_to(b, reg, x, y);
284       I->clamp = BI_CLAMP_CLAMP_0_1;
285    });
286 
287    CASE({
288       bi_instr *I = bi_fadd_v2f16_to(b, bi_temp(b->shader), x, y);
289       bi_instr *J = bi_fclamp_v2f16_to(b, reg, I->dest[0]);
290       I->clamp = BI_CLAMP_CLAMP_0_INF;
291       J->clamp = BI_CLAMP_CLAMP_0_INF;
292    }, {
293       bi_instr *I = bi_fadd_v2f16_to(b, reg, x, y);
294       I->clamp = BI_CLAMP_CLAMP_0_INF;
295    });
296 }
297 
TEST_F(Optimizer,DoNotMixSizesWhenClamping)298 TEST_F(Optimizer, DoNotMixSizesWhenClamping)
299 {
300    NEGCASE({
301       bi_instr *I = bi_fclamp_f32_to(b, reg, bi_fadd_v2f16(b, x, y));
302       I->clamp = BI_CLAMP_CLAMP_0_1;
303    });
304 
305    NEGCASE({
306       bi_instr *I = bi_fclamp_v2f16_to(b, reg, bi_fadd_f32(b, x, y));
307       I->clamp = BI_CLAMP_CLAMP_0_1;
308    });
309 }
310 
TEST_F(Optimizer,DoNotUseAdditionByZeroForClamps)311 TEST_F(Optimizer, DoNotUseAdditionByZeroForClamps)
312 {
313    bi_index zero = bi_zero();
314 
315    /* We can't use addition by 0.0 for clamps due to signed zeros. */
316    NEGCASE({
317       bi_instr *I = bi_fadd_f32_to(b, reg, bi_fadd_f32(b, x, y), zero);
318       I->clamp = BI_CLAMP_CLAMP_M1_1;
319    });
320 
321    NEGCASE({
322       bi_instr *I = bi_fadd_v2f16_to(b, reg, bi_fadd_v2f16(b, x, y), zero);
323       I->clamp = BI_CLAMP_CLAMP_0_1;
324    });
325 }
326 
TEST_F(Optimizer,FuseComparisonsWithDISCARD)327 TEST_F(Optimizer, FuseComparisonsWithDISCARD)
328 {
329    CASE(bi_discard_b32(b, bi_fcmp_f32(b, x, y, BI_CMPF_LE, BI_RESULT_TYPE_F1)),
330         bi_discard_f32(b, x, y, BI_CMPF_LE));
331 
332    CASE(bi_discard_b32(b, bi_fcmp_f32(b, x, y, BI_CMPF_NE, BI_RESULT_TYPE_I1)),
333         bi_discard_f32(b, x, y, BI_CMPF_NE));
334 
335    CASE(bi_discard_b32(b, bi_fcmp_f32(b, x, y, BI_CMPF_EQ, BI_RESULT_TYPE_M1)),
336         bi_discard_f32(b, x, y, BI_CMPF_EQ));
337 
338    for (unsigned h = 0; h < 2; ++h) {
339       CASE(bi_discard_b32(b, bi_half(bi_fcmp_v2f16(b, x, y, BI_CMPF_LE, BI_RESULT_TYPE_F1), h)),
340            bi_discard_f32(b, bi_half(x, h), bi_half(y, h), BI_CMPF_LE));
341 
342       CASE(bi_discard_b32(b, bi_half(bi_fcmp_v2f16(b, x, y, BI_CMPF_NE, BI_RESULT_TYPE_I1), h)),
343            bi_discard_f32(b, bi_half(x, h), bi_half(y, h), BI_CMPF_NE));
344 
345       CASE(bi_discard_b32(b, bi_half(bi_fcmp_v2f16(b, x, y, BI_CMPF_EQ, BI_RESULT_TYPE_M1), h)),
346            bi_discard_f32(b, bi_half(x, h), bi_half(y, h), BI_CMPF_EQ));
347    }
348 }
349 
TEST_F(Optimizer,DoNotFuseSpecialComparisons)350 TEST_F(Optimizer, DoNotFuseSpecialComparisons)
351 {
352    NEGCASE(bi_discard_b32(b, bi_fcmp_f32(b, x, y, BI_CMPF_GTLT, BI_RESULT_TYPE_F1)));
353    NEGCASE(bi_discard_b32(b, bi_fcmp_f32(b, x, y, BI_CMPF_TOTAL, BI_RESULT_TYPE_F1)));
354 }
355 
TEST_F(Optimizer,FuseResultType)356 TEST_F(Optimizer, FuseResultType)
357 {
358    CASE(bi_mux_i32_to(b, reg, bi_imm_f32(0.0), bi_imm_f32(1.0),
359                       bi_fcmp_f32(b, x, y, BI_CMPF_LE, BI_RESULT_TYPE_M1),
360                       BI_MUX_INT_ZERO),
361         bi_fcmp_f32_to(b, reg, x, y, BI_CMPF_LE, BI_RESULT_TYPE_F1));
362 
363    CASE(bi_mux_i32_to(b, reg, bi_imm_f32(0.0), bi_imm_f32(1.0),
364                       bi_fcmp_f32(b, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_M1),
365                       BI_MUX_INT_ZERO),
366         bi_fcmp_f32_to(b, reg, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_F1));
367 
368    CASE(bi_mux_i32_to(b, reg, bi_imm_u32(0), bi_imm_u32(1),
369                       bi_fcmp_f32(b, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_M1),
370                       BI_MUX_INT_ZERO),
371         bi_fcmp_f32_to(b, reg, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_I1));
372 
373    CASE(bi_mux_v2i16_to(b, reg, bi_imm_f16(0.0), bi_imm_f16(1.0),
374                       bi_fcmp_v2f16(b, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_M1),
375                       BI_MUX_INT_ZERO),
376         bi_fcmp_v2f16_to(b, reg, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_F1));
377 
378    CASE(bi_mux_v2i16_to(b, reg, bi_imm_u16(0), bi_imm_u16(1),
379                       bi_fcmp_v2f16(b, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_M1),
380                       BI_MUX_INT_ZERO),
381         bi_fcmp_v2f16_to(b, reg, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_I1));
382 
383    CASE(bi_mux_i32_to(b, reg, bi_imm_u32(0), bi_imm_u32(1),
384                       bi_icmp_u32(b, x, y, BI_CMPF_LE, BI_RESULT_TYPE_M1),
385                       BI_MUX_INT_ZERO),
386         bi_icmp_u32_to(b, reg, x, y, BI_CMPF_LE, BI_RESULT_TYPE_I1));
387 
388    CASE(bi_mux_v2i16_to(b, reg, bi_imm_u16(0), bi_imm_u16(1),
389                       bi_icmp_v2u16(b, x, y, BI_CMPF_LE, BI_RESULT_TYPE_M1),
390                       BI_MUX_INT_ZERO),
391         bi_icmp_v2u16_to(b, reg, x, y, BI_CMPF_LE, BI_RESULT_TYPE_I1));
392 
393    CASE(bi_mux_v4i8_to(b, reg, bi_imm_u8(0), bi_imm_u8(1),
394                       bi_icmp_v4u8(b, x, y, BI_CMPF_LE, BI_RESULT_TYPE_M1),
395                       BI_MUX_INT_ZERO),
396         bi_icmp_v4u8_to(b, reg, x, y, BI_CMPF_LE, BI_RESULT_TYPE_I1));
397 
398    CASE(bi_mux_i32_to(b, reg, bi_imm_u32(0), bi_imm_u32(1),
399                       bi_icmp_s32(b, x, y, BI_CMPF_LE, BI_RESULT_TYPE_M1),
400                       BI_MUX_INT_ZERO),
401         bi_icmp_s32_to(b, reg, x, y, BI_CMPF_LE, BI_RESULT_TYPE_I1));
402 
403    CASE(bi_mux_v2i16_to(b, reg, bi_imm_u16(0), bi_imm_u16(1),
404                       bi_icmp_v2s16(b, x, y, BI_CMPF_LE, BI_RESULT_TYPE_M1),
405                       BI_MUX_INT_ZERO),
406         bi_icmp_v2s16_to(b, reg, x, y, BI_CMPF_LE, BI_RESULT_TYPE_I1));
407 
408    CASE(bi_mux_v4i8_to(b, reg, bi_imm_u8(0), bi_imm_u8(1),
409                       bi_icmp_v4s8(b, x, y, BI_CMPF_LE, BI_RESULT_TYPE_M1),
410                       BI_MUX_INT_ZERO),
411         bi_icmp_v4s8_to(b, reg, x, y, BI_CMPF_LE, BI_RESULT_TYPE_I1));
412 }
413 
TEST_F(Optimizer,DoNotFuseMixedSizeResultType)414 TEST_F(Optimizer, DoNotFuseMixedSizeResultType)
415 {
416    NEGCASE(bi_mux_i32_to(b, reg, bi_imm_f32(0.0), bi_imm_f32(1.0),
417                       bi_fcmp_v2f16(b, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_M1),
418                       BI_MUX_INT_ZERO));
419 
420    NEGCASE(bi_mux_v2i16_to(b, reg, bi_imm_f16(0.0), bi_imm_f16(1.0),
421                       bi_fcmp_f32(b, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_M1),
422                       BI_MUX_INT_ZERO));
423 }
424 
TEST_F(Optimizer,VarTexCoord32)425 TEST_F(Optimizer, VarTexCoord32)
426 {
427    CASE({
428          bi_index ld = bi_ld_var_imm(b, bi_null(), BI_REGISTER_FORMAT_F32, BI_SAMPLE_CENTER, BI_UPDATE_STORE, BI_VECSIZE_V2, 0);
429 
430          bi_index x = bi_temp(b->shader);
431          bi_index y = bi_temp(b->shader);
432          bi_instr *split = bi_split_i32_to(b, x, ld);
433          split->nr_dests = 2;
434          split->dest[1] = y;
435 
436          bi_texs_2d_f32_to(b, reg, x, y, false, 0, 0);
437    }, {
438          bi_var_tex_f32_to(b, reg, false, BI_SAMPLE_CENTER, BI_UPDATE_STORE, 0, 0);
439    });
440 }
441