[Mesa-dev] [PATCH] GLSL: fix too eager constant variable optimization

Aras Pranckevicius aras at unity3d.com
Sat Mar 2 02:20:34 PST 2013


> Now, looking further this optimization pass should also not mark variables
>> as const if there was a dereference of them before that first assignment. I
>> had code to do this (a hashtable that would track dereferences before
>> assignment is done). But couldn't come up with a test case that would break
>> the whole set of optimizations that Mesa does (lower jumps, or inlining,
>> ... were getting in the way and hide the bug).
>>
>
> I'm not sure I agree with this.  The real problem with the example code
> you showed above is that there's an implicit write to the variable c at the
> top of the function, so c is not in fact constant--it's written twice.
> What we should really do is modify the optimization pass so that it's aware
> of the implicit write that happens in "in" and "inout" function args.
> If we resolve the implicit write issue, there should be no harm in marking
> variables as const if there's a dereference of them before the first
> assignment, because a dereference of a variable before the first assignment
> is undefined.
>

Right. I'm not sure what's the correct way of making constant variable pass
robust, all I know is that in it's current form it is clearly wrong.

If function arguments do get marked as "one write", that effectively means
they will be excluded from actual optimization until the function is
inlined? Maybe that's okay, no sure.


-- 
Aras Pranckevičius
work: http://unity3d.com
home: http://aras-p.info
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130302/55631d76/attachment.html>


More information about the mesa-dev mailing list