Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Missed loop vectorization #48446

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR49476
Status NEW
Importance P enhancement
Reported by David Bolvansky (david.bolvansky@gmail.com)
Reported on 2021-03-08 08:16:23 -0800
Last modified on 2021-03-08 10:10:54 -0800
Version trunk
Hardware PC Linux
CC a.bataev@hotmail.com, florian_hahn@apple.com, hideki.saito@intel.com, listmail@philipreames.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
#define M 32000
#define N 256

double a[M],x[N][N];

void compute()
{

    for (int j = 0; j < N; j++) {
            for (int i = j+1; i < N; i++) {
                a[i] -= x[j][i] * a[j];
            }
        }

}

With -Ofast, LLVM does not vectorize this code.

for a[j]:
remark: failed to move load with loop-invariant address because the loop may
invalidate its value [-Rpass-missed=licm]

https://godbolt.org/z/Gx6Px4
Quuxplusone commented 3 years ago

Type does not matter, so simpler testcase with int and -O3:

https://godbolt.org/z/9s8MPj