skia2/tests/sksl/runtime/ConversionConstructors.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

25 lines
533 B
Plaintext

8 registers, 22 instructions:
0 r0 = uniform32 ptr0 4
1 r1 = uniform32 ptr0 8
2 r2 = uniform32 ptr0 C
3 r3 = splat 0 (0)
4 r4 = splat FFFFFFFF (nan)
5 r5 = neq_f32 r0 r3
6 r6 = splat 3F800000 (1)
7 r6 = bit_and r2 r6
8 r7 = to_f32 r1
9 r7 = select r5 r6 r7
10 r3 = eq_i32 r1 r3
11 r3 = bit_xor r4 r3
12 r4 = splat 1 (1.4012985e-45)
13 r4 = bit_and r2 r4
14 r0 = trunc r0
15 r0 = select r3 r4 r0
16 r0 = to_f32 r0
17 r0 = mul_f32 r7 r0
loop:
18 store32 ptr1 r0
19 store32 ptr2 r0
20 store32 ptr3 r0
21 store32 ptr4 r0