skia2/tests/sksl/runtime/Switch.skvm
John Stiles 059d34594e Optimize SkVM bit-clears.
SkVM has a `bit_clear` opcode dedicated to the operation `x & ~y`, but
the optimizer was not smart enough to combine a bit-and with a bit-not
and replace it with a bit-clear. Now, it can.

Change-Id: Ida5345c3def0a4bf7afa08bb7f7835e1e2e37677
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/524225
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Arman Uguray <armansito@google.com>
2022-03-24 21:04:23 +00:00

36 lines
851 B
Plaintext

16 registers, 33 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 0 (0)
9 r9 = splat FFFFFFFF (nan)
10 r10 = trunc r1
11 r8 = eq_i32 r10 r8
12 r11 = bit_and r4 r8
13 r12 = bit_and r5 r8
14 r13 = bit_and r6 r8
15 r14 = bit_and r7 r8
16 r15 = splat 1 (1.4012985e-45)
17 r15 = eq_i32 r10 r15
18 r15 = bit_clear r15 r8
19 r11 = select r15 r0 r11
20 r12 = select r15 r1 r12
21 r13 = select r15 r2 r13
22 r14 = select r15 r3 r14
23 r9 = bit_xor r15 r9
24 r8 = bit_clear r9 r8
25 r11 = select r8 r4 r11
26 r12 = select r8 r5 r12
27 r13 = select r8 r6 r13
28 r14 = select r8 r7 r14
loop:
29 store32 ptr1 r11
30 store32 ptr2 r12
31 store32 ptr3 r13
32 store32 ptr4 r14