<p dir="ltr"><br>
On Feb 12, 2015 1:28 AM, "Kenneth Graunke" <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>> wrote:<br>
><br>
> On Wednesday, February 11, 2015 04:14:20 PM Ian Romanick wrote:<br>
> > On 02/11/2015 04:05 PM, Matt Turner wrote:<br>
> > > On Wed, Feb 11, 2015 at 3:51 PM, Ian Romanick <<a href="mailto:idr@freedesktop.org">idr@freedesktop.org</a>> wrote:<br>
> > >> On 02/11/2015 02:54 PM, Matt Turner wrote:<br>
> > >>> We propagate negations to the right-most leaves of the multiplication<br>
> > >>> expression trees:<br>
> > >>><br>
> > >>>  - mul(neg(x), neg(y)) -> mul(x, y)<br>
> > >>>  - mul(neg(x), y) -> neg(mul(x, y))<br>
> > >>>  - mul(x, neg(y)) -> neg(mul(x, y))<br>
> > >>><br>
> > >>> total instructions in shared programs: 5943123 -> 5937229 (-0.10%)<br>
> > >>> instructions in affected programs:     868221 -> 862327 (-0.68%)<br>
> > >>> helped:                                4518<br>
> > >>> HURT:                                  356<br>
> > >>> GAINED:                                1<br>
> > >><br>
> > >> This seems very counter intuitive.  Why does this help?  It seems like<br>
> > >> the negate modifier on the multiplication sources should be free... how<br>
> > >> do we get cheaper than free? :)<br>
> > ><br>
> > > Lots of shaders do things like var * 0.5 and var * -0.5. By making the<br>
> > > second of those -(var * 0.5) we can do the multiplication once and use<br>
> > > its result in both places, negated once.<br>
> > ><br>
> > > I also noticed we were generating a lot more LRPs after this. I guess<br>
> > > the LRP peephole is able to recognize more stuff without some negates<br>
> > > in the way.<br>
> > ><br>
> > > If you want, I can try to take a closer look at some affected shaders<br>
> > > -- though it is kind of hard. Diff'ing GLSL IR is impossible, and even<br>
> > > if you get past the compiler_temp@ variables being renumbered it's<br>
> > > still really difficult to see what's going on.<br>
> ><br>
> > Naw, that's fine.  Enabling additional CSE is a perfectly valid<br>
> > explanation... though it makes me wonder if CSE should be smarter.  For<br>
> > all the programs helped, about 8% are hurt.  *shrug*<br>
><br>
> CSE at the GLSL IR level is currently awful.  It only handles variables<br>
> with the read_only flag set (to avoid dealing with kill sets).  It also<br>
> starts at the leaves and works its way up - so if you have a huge<br>
> expression tree that's identical, it will CSE the tiniest piece,<br>
> introducing a new variable *without* read_only set, then completely bail<br>
> on the whole endeavor.<br>
><br>
> I wasn't sure exactly what the semantics of read_only were, or if I<br>
> could just go set it on a new temporary.  It's mostly used for uniforms,<br>
> IIRC.<br>
><br>
> It's also not really worth fixing.  SSA eliminates the need to track<br>
> variable kills, so NIR's pass doesn't have these restrictions and<br>
> already just works.  We should just focus on moving to NIR.</p>
<p dir="ltr">I'm OK with continuing to do stuff in the old IR as long as it's not too troublesome.  However, it would be good if it also came with the corresponding 4-line NIR patch so we don't get even further out-of-sync.<br>
--Jason</p>
<p dir="ltr">> _______________________________________________<br>
> mesa-dev mailing list<br>
><a href="mailto:mesa-dev@lists.freedesktop.org"> mesa-dev@lists.freedesktop.org</a><br>
><a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev"> http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
><br>
</p>