[Mesa-dev] [PATCH 6/6] nir: Don't condition 'a-b < 0' -> 'a < b' on is_not_used_by_conditional

Ian Romanick idr at freedesktop.org
Fri Mar 23 22:44:57 UTC 2018


On 03/23/2018 11:39 AM, Matt Turner wrote:
> On Wed, Mar 21, 2018 at 5:58 PM, Ian Romanick <idr at freedesktop.org> wrote:
>> From: Ian Romanick <ian.d.romanick at intel.com>
>>
>> Now that i965 recognizes that a-b generates the same conditions as 'a <
>> b', there is no reason to condition this transformation on 'is not used
>> by conditional.'
>>
>> Since this was the only user of the is_not_used_by_conditional function,
>> delete it.
>>
>> All Gen6+ platforms had similar results. (Skylake shown)
>> total instructions in shared programs: 14400775 -> 14400595 (<.01%)
>> instructions in affected programs: 36712 -> 36532 (-0.49%)
>> helped: 182
>> HURT: 26
> 
> Looked at why these are hurt? :)

I should have known you were going to ask that. :)  Since the changes
were small, I tried to avoid looking at them so that I wouldn't get
distracted again.  But since you asked...

Shaders from 4 apps were hurt.  All but one of the hurt sharders was an
ARB_fragment_program.  I looked at a shader from each of the four apps,
and in all of those cases a ffma / compare with zero became a multiply /
compare with something else.

We already have a general case of this transformation in last
optimizations.  So, I tried making this transformation more general (by
removing the fneg) and added a transformation to strip the fnegs from -a
< -b.  The results on SKL are below.  I'm not excited about the "max: 27
 x̄: 2.26".

I think I'd like to land this patch as-is.  I'm also going to play with
moving all the comparison munging out of late optimizations.  I have
some patches in the queue that add some more transformations, so it will
be interesting to see the effect of moving them earlier.

total instructions in shared programs: 14400775 -> 14399973 (<.01%)
instructions in affected programs: 242118 -> 241316 (-0.33%)
helped: 1298
HURT: 325
helped stats (abs) min: 1 max: 7 x̄: 1.18 x̃: 1
helped stats (rel) min: 0.11% max: 9.09% x̄: 1.73% x̃: 1.16%
HURT stats (abs)   min: 1 max: 27 x̄: 2.26 x̃: 1
HURT stats (rel)   min: 0.14% max: 5.26% x̄: 0.79% x̃: 0.43%
95% mean confidence interval for instructions value: -0.61 -0.38
95% mean confidence interval for instructions %-change: -1.32% -1.14%
Instructions are helped.

total cycles in shared programs: 532929592 -> 532919072 (<.01%)
cycles in affected programs: 3525194 -> 3514674 (-0.30%)
helped: 1896
HURT: 608
helped stats (abs) min: 1 max: 714 x̄: 14.12 x̃: 4
helped stats (rel) min: 0.03% max: 26.92% x̄: 1.10% x̃: 0.68%
HURT stats (abs)   min: 1 max: 281 x̄: 26.72 x̃: 8
HURT stats (rel)   min: 0.01% max: 40.94% x̄: 2.19% x̃: 0.95%
95% mean confidence interval for cycles value: -5.88 -2.53
95% mean confidence interval for cycles %-change: -0.41% -0.19%


More information about the mesa-dev mailing list