[llvm] r286171 - [AMDGPU] Allow hoisting of comparisons out of a loop and eliminate condition copies

Michel Dänzer via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 9 19:14:30 PST 2016


[ Adding more AMD Mesa/LLVM developers ]

On 10/11/16 06:47 AM, Mekhanoshin, Stanislav wrote:
> I cannot see the problem with the code generated. In fact it is now 2
> instructions less and seems to be equivalent to the old one on behavior.
> What does this test check? Presence of a missing instruction, exact
> match of the produced ISA?

It tests the behaviour of the generated code. Here's the corresponding
GLSL source code and description of what it's testing for:

/* This shader will discard one pixel coordinate, and do an infinite
 * loop on another pixel.  We set the two coordinates to the same, to
 * test whether discard on a channel avoids execution on that channel.
 */
static const char *fs_source =
        "#version 130\n"
        "uniform ivec2 coord1, coord2;\n"
        "void main()\n"
        "{\n"
        "       ivec2 fc = ivec2(gl_FragCoord);\n"
        "       int inc = abs(fc.x - coord2.x) + abs(fc.y - coord2.y);\n"
        "\n"
        "       if (fc == coord1)\n"
        "               discard;\n"
        "\n"
        "       gl_FragColor = vec4(0);\n"
        "       for (int i = 0; i < 10; i += inc)\n"
        "               gl_FragColor.b += 0.1;\n"
        "}\n";


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer


More information about the llvm-commits mailing list