[Mesa-dev] [PATCH 2/2] i965/nir: Re-emit instructions instead of doing mov-to-flag when possible

Jason Ekstrand jason at jlekstrand.net
Tue Mar 17 12:20:31 PDT 2015


On Tue, Mar 17, 2015 at 11:38 AM, Matt Turner <mattst88 at gmail.com> wrote:
> On Mon, Mar 16, 2015 at 9:21 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
>> Because of the way that NIR does conditionals, we get them in any old SSA
>> value.  The actual boolean value used in the select or if is x != 0.
>> Previously, we handled this by emitting a mov.nz to move the value to the
>> flag register.  However, this almost always adds at least one if not two
>> instructions because we have to go through the VGRF when we could be
>> comparing directly to the flag and then using the flag.
>>
>> With this commit, we simply re-emit the instruction that produces the value
>> when we can.  By doing so, we can use the flag directly and we trust in CSE
>> to clean up for us if it can.
>>
>> Shader-db results:
>>
>> total instructions in shared programs: 4164120 -> 4110511 (-1.29%)
>> instructions in affected programs:     2397042 -> 2343433 (-2.24%)
>> helped:                                13167
>> HURT:                                  31
>> GAINED:                                4
>> LOST:                                  4
>> ---
>
> A small change to the cmod_propagation branch accomplishes most of this --
>
> total instructions in shared programs: 7850607 -> 7793875 (-0.72%)
> instructions in affected programs:     2425140 -> 2368408 (-2.34%)
> helped:                                13502
> HURT:                                  0
> GAINED:                                1
> LOST:                                  5
>
> We always emit the MOV.NZ with a D-typed destination, which
> cmod_propagate won't combine with a CMP with an F-typed destination.
>
> I don't think we ever emit MOV.NZ without NIR, so no changes without it.
>
> Let me play with this some more.

Another aspect here is how this is going to interact with boolean
resolves.  I've got patches in my wip/nir-booleans branch that I'm
testing right now.  I think the general approach is solid, I just need
to test and work out the bugs.  It could take some time as I am
testing on ILK after all.
--Jason


More information about the mesa-dev mailing list