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

--- Comment #1 from Hongtao.liu <crazylht at gmail dot com> ---

> real_t* __restrict__ xx;
> real_t* yy;
> real_t s243(void)
> {
>     for (int nl = 0; nl < iterations; nl++) {
>         for (int i = 0; i < LEN_1D-1; i++) {
>             a[i] = b[i] + c[i  ] * d[i];
>             b[i] = a[i] + d[i  ] * e[i];
>             a[i] = b[i] + a[i+1] * d[i];
>         }
>     }
> }

Manually change the code to below, gcc can vectorize the loop.
real_t s243(void)
{
    for (int nl = 0; nl < iterations; nl++) {
        for (int i = 0; i < LEN_1D-1; i++) {
//          a[i] = b[i] + c[i  ] * d[i]; propagate it into next line.
            b[i] = b[i] + c[i  ] * d[i] + d[i  ] * e[i];
            a[i] = b[i] + a[i+1] * d[i];
        }
    }
}

Reply via email to