[Mesa-dev] [PATCH 2/6] glsl: Implement any(v) as any_nequal(v, false).

Ilia Mirkin imirkin at alum.mit.edu
Tue Dec 1 13:31:31 PST 2015


On Tue, Dec 1, 2015 at 4:24 PM, Ian Romanick <idr at freedesktop.org> wrote:
>> which ends up in:
>>
>> EMIT: mov u32 $r4 0x00000000 (8)
>> EMIT: set u32 $r1 ne $r1 $r4 (8)
>> EMIT: set u32 $r2 ne $r2 $r4 (8)
>> EMIT: set u32 $r3 ne $r3 $r4 (8)
>> EMIT: set u32 $r0 ne $r0 $r4 (8)
>> EMIT: or u32 $r1 $r1 $r2 (8)
>> EMIT: or u32 $r1 $r1 $r3 (8)
>> EMIT: or u32 $r3 $r1 $r0 (8)
>
> It seems like the rotation of (x != 0) || (y != 0) || (z != 0) || (w !=
> 0) to (x | y | z | w) != 0 would really help here... and should be safe?
>  You'd end up with:
>
> EMIT: mov u32 $r4 0x00000000 (8)
> EMIT: or u32 $r1 $r1 $r2 (8)
> EMIT: or u32 $r1 $r1 $r3 (8)
> EMIT: or u32 $r3 $r1 $r0 (8)
> EMIT: set u32 $r3 ne $r3 $r4 (8)

I like it! I never thought of that... obviously this only works when
all of the comparisons are to 0 (and only ==/!=), but that's a fairly
frequent occurrence. A bit of a pain to match, but should be possible.


More information about the mesa-dev mailing list