[Mesa-dev] [PATCH] nir: Optimize useless comparisons against true/false.

Neil Roberts neil at linux.intel.com
Fri Dec 4 10:51:38 PST 2015


Matt Turner <mattst88 at gmail.com> writes:

>  # Written in the form (<search>, <replace>) where <search> is an expression
>  # and <replace> is either an expression or a value.  An expression is
>  # defined as a tuple of the form (<op>, <src0>, <src1>, <src2>, <src3>)
> @@ -94,6 +97,8 @@ optimizations = [
>     (('inot', ('ige', a, b)), ('ilt', a, b)),
>     (('inot', ('ieq', a, b)), ('ine', a, b)),
>     (('inot', ('ine', a, b)), ('ieq', a, b)),
> +   (('ieq', 'a at bool', true), a),
> +   (('ine', 'a at bool', false), a),

I think this second one is already in the file on line 187 here:

   # Boolean simplifications
   (('ine', 'a at bool', 0), 'a'),
   (('ieq', 'a at bool', 0), ('inot', 'a')),

Maybe you could add the first one near these two? It could be good to
add a line like this as well to complete the set:

   (('ine', 'a at bool', true), ('inot', a)),

Regards,
- Neil


More information about the mesa-dev mailing list