On Fri, Mar 20, 2015 at 2:51 PM, Matt Turner <matts...@gmail.com> wrote:
> On Fri, Mar 20, 2015 at 1:58 PM, Ian Romanick <i...@freedesktop.org> wrote:
>> From: Ian Romanick <ian.d.roman...@intel.com>
>>
>> An expression like -(x * 8) becomes (x * -8).
>>
>> Much of the hurt caused by this change appears to be from CSE not being
>> able to see (x * -8) and (x * 8) as common.  Previously -(x * 8) and (x
>> * 8) would have had a common subexpression.  Later patches address this
>> at the GLSL IR level, but additional work will be needed in NIR and the
>> i965 backend.
>
> I've got patches that do the opposite of this: pull the negate out of
> the multiplication.
>
> It was a three patch series and one of the patches was never reviewed.
> I would have just pushed them, but they hurt NIR and I haven't figured
> out how to fix that yet.
>
> The third patch recognizes neg(mul(...)) in the GLSL -> i965
> translators and set a source modifier to avoid an additional
> instruction from the case where we can't eliminate the negates
> entirely.
>
> It's not just recognizing -(x * y) and (x * -y) that's problematic,
> it's (-x * y) as well. My patches handle that case too.
>
> So I'd probably rather not take this patch.

Yeah, I've thought quite a bit about this problem as well.  I haven't
had a chance to test this and get numbers, but my inclination is that
the best approach is probably a two-pronged one.  First, we pull
negatives down so (x * -y) becomes -(x * y) and (-x + -y) becomes -(x
+ y).  That *should* be easier for CSE to handle.  Then, once the
optimization loop is done, we push them back up so that we can use
source modifiers.

The problem is that there are an infinity of different identical
combinations there and trying to special-case them all in CSE is a
mess.  We're probably better off making opt_algebraic go towards
things that are easy to optimize and/or CSE in the hopes that we can
optimize further from there.  Then we can push stuff up so we can use
it for source mods.  Unfortunately, as I said, I don't have any
numbers to back that up yet.
--Jason
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to