[Bug tree-optimization/79351] [7/8/9 Regression] Invalid tree PRE optimization around compound literal

amonakov at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Nov 27 17:40:00 GMT 2018


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

Alexander Monakov <amonakov at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|WAITING                     |NEW
                 CC|                            |amonakov at gcc dot gnu.org
      Known to work|                            |4.3.2
            Summary|Invalid tree PRE            |[7/8/9 Regression] Invalid
                   |optimization around         |tree PRE optimization
                   |compound literal            |around compound literal
      Known to fail|                            |4.7.2

--- Comment #4 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Thanks, confirmed. Reduced testcase, aborts with -O -ftree-pre:

static struct state {
    int k;
    int dummy;
} states[256];

__attribute((noipa))
static void
ismatch(int n)
{
    for (int j=0; j<n; j++) {
#if 1
        states[j] = (struct state){0};
#else
        __builtin_memset(states + j, 0, sizeof(states[0]));
#endif
        for (int i = 0; i <= j; i++) {
            states[i].k++;
        }
    }
}

int
main()
{
    ismatch(2);
    if (states[0].k != 2)
        __builtin_abort();
}


More information about the Gcc-bugs mailing list