[Mesa-dev] [PATCH] nir: Optimize useless comparisons against true/false.
Matt Turner
mattst88 at gmail.com
Wed Dec 2 14:10:23 PST 2015
On Wed, Dec 2, 2015 at 1:34 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> On Tue, Dec 1, 2015 at 4:16 PM, Matt Turner <mattst88 at gmail.com> wrote:
>> ---
>> I add the true/false variables for clarity since there are some existing
>> optimizations using ~0 where it actually has nothing to do with true.
>>
>> I could take it or leave it. We obviously can't use them for feq and
>> friends. Maybe itrue/ifalse and ftrue/ffalse?
>>
>> src/glsl/nir/nir_opt_algebraic.py | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py
>> index 6aa8b1f..04261e7 100644
>> --- a/src/glsl/nir/nir_opt_algebraic.py
>> +++ b/src/glsl/nir/nir_opt_algebraic.py
>> @@ -32,6 +32,9 @@ b = 'b'
>> c = 'c'
>> d = 'd'
>>
>> +true = ~0
>> +false = 0
>
> I think you can just use the python True and False and it works fine.
> With that changed,
With that change, I see this diff in the generated nir_opt_algebraic.c:
- { 0x0 /* 0 */ },
+ { NIR_FALSE /* False */ },
...
- { 0xffffffff /* -1 */ },
+ { NIR_TRUE /* True */ },
I had no idea it would handle that. Cool.
More information about the mesa-dev
mailing list