[Mesa-dev] r300/compiler: Peephole optimizer.

Marek Olšák maraeo at gmail.com
Thu May 13 17:46:36 PDT 2010


Hi Tom,

your patch helps but glean/texCube still fails here (it doesn't fail on
master).

-Marek

On Tue, May 11, 2010 at 6:45 PM, Tom Stellard <tstellar at gmail.com> wrote:

> I have been testing the peephole optimizer from Nicolai's r300g-glsl
> branch.  There is a bug in it that breaks two of the piglit test cases:
> glsl-fs-fragcoord and glsl-orangebook-ch06-bump.  Here is an example of
> the bug from glsl-fs-fragcoord:
>
> 0: RCP temp[3].w, input[0].w___;
> 1: MUL temp[3].xy, input[0].xy__, temp[3].ww__;
> 2: MAD temp[3].xy, temp[3].xy__, const[3].xy__, const[4].xy__;
> 3: ADD temp[0].y, const[1]._y__, -temp[3]._y__;
> 4: RCP temp[1].w, const[2].x___;
> 5: MUL temp[1].y, temp[3]._x__, temp[1]._w__;
> 6: MOV temp[1].x, temp[1].y___;
> 7: RCP temp[2].x, const[2].x___;
> 8: MUL temp[1].z, temp[0].__y_, temp[2].__x_;
> 9: MOV temp[1].y, temp[1]._z__;
> 10: MOV temp[1].z, const[2].__y_;
> 11: MOV output[0].x, temp[1].x___;
> 12: MOV output[0].y, temp[1]._y__;
> 13: MOV output[0].z, temp[1].__z_;
> 14: MOV output[0].w, const[2].___y;
>
> In this case the peephole optimizer looks at instruction 6, and then
> replace all occurrences of temp[1].x with temp[1].y.  This affects
> instruction 11:
> 11: MOV output[0].x, temp[1].x___; -> 11: MOV output[0].x, temp[1].y___;
>
> This is a problem because temp[1].y is written to in instruction 9,
> so it will no longer have the same value as temp[1].x when instruction
> 11 is executed.
>
> I have attached a patch that appears to fix the problem.
> In order to apply this patch, you will first need to
> cherry-pick commit a5e64199f8359cbff589acc9581b264226c41335 from
> git://anongit.freedesktop.org/~nh/mesa<http://anongit.freedesktop.org/%7Enh/mesa>into master.
>
> With this patch, the peephole optimizer passes all the GLSL
> piglit tests that are currently passed by mesa's master
> branch.  Here are the piglit results for master, master +
> peephole optimizer, and master + peephole optimizier + patch.
> http://ix.cs.uoregon.edu/~tstellar/piglit/peephole/index.html<http://ix.cs.uoregon.edu/%7Etstellar/piglit/peephole/index.html>
>
> -Tom
>
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20100514/06a5d415/attachment.htm>


More information about the mesa-dev mailing list