[Bug target/88271] Omit test instruction after add

bugzilla@poradnik-webmastera.com gcc-bugzilla@gcc.gnu.org
Mon Dec 10 21:11:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88271

--- Comment #10 from Daniel Fruzynski <bugzilla@poradnik-webmastera.com> ---
Here is possible code transformation to equivalent form, where this
optimization can be simply applied. This change also has a bit surprising side
effect, second nested while loop is unrolled.

[code]
void test2()
{
    int level = 0;
    int val = 1;
    while (1)
    {
        while(1)
        {
            val = data[level] << 1;
            ++level;
            if (val)
                continue;
            else
                break;
        }

        while(1)
        {
            --level;
            val = data[level];
            if (!val)
                continue;
            else
                break;

        }
    }
}
[/code]


More information about the Gcc-bugs mailing list