[Mesa-dev] [PATCH 4/4] i965/fs: Optimize (gl_FrontFacing ? x : -1.0) where x is ±0.0.

Matt Turner mattst88 at gmail.com
Tue Jan 13 12:36:26 PST 2015


On Thu, Jan 8, 2015 at 10:59 PM, Matt Turner <mattst88 at gmail.com> wrote:
> The pattern
>
>    gl_FrontFacing ? -0.0 : -1.0
>
> appears in many shaders, but there's no significance of the 0.0's sign
> since it the result of the expression is always used in an addition.
>
> Getting the sign bit right would be an extra OR instruction and seems
> unnecessary.
>
> total instructions in shared programs: 5884883 -> 5883393 (-0.03%)
> instructions in affected programs:     194415 -> 192925 (-0.77%)
> GAINED:                                2
> LOST:                                  0
>
> (one of the GAINED programs had been lost in the previous commit)
> ---

And on Ironlake:

total instructions in shared programs: 4413238 -> 4412404 (-0.02%)
instructions in affected programs:     165044 -> 164210 (-0.51%)


More information about the mesa-dev mailing list