llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Clang crash with -mcpu=grace -O3 -msve-vector-bits=128: error in backend: Cannot scalarize scalable vector loads

Open ktkachov opened this issue 2 years ago • 6 comments

The following reduced testcase: https://godbolt.org/z/hhb8n6fnT

int a, d;
extern short b[];
long c;
void e(bool f[]) {
#pragma clang loop vectorize_predicate(enable)
  for (signed char g = 1; g < (char)d; g += 3) {
    a = f[g] ? c : 0;
    b[g] = 0;
  }
}

crashes for me with -mcpu=grace -O3 -msve-vector-bits=128: error in backend: Cannot scalarize scalable vector loads

ktkachov avatar Aug 05 '24 15:08 ktkachov

https://clang.godbolt.org/z/cKa3v7P5K

fhahn avatar Aug 05 '24 19:08 fhahn

@llvm/issue-subscribers-backend-aarch64

Author: Kyrill Tkachov (ktkachov)

The following reduced testcase: ``` int a, d; extern short b[]; long c; void e(bool f[]) { #pragma clang loop vectorize_predicate(enable) for (signed char g = 1; g < (char)d; g += 3) { a = f[g] ? c : 0; b[g] = 0; } } ``` crashes for me with -mcpu=grace -O3 -msve-vector-bits=128: error in backend: Cannot scalarize scalable vector loads

llvmbot avatar Aug 05 '24 19:08 llvmbot

It looks like an extract of a bitcast is expanded via the stack (which itself doesn't need sve-vector-bits) https://clang.godbolt.org/z/j81czfxjc

davemgreen avatar Aug 05 '24 19:08 davemgreen

The C reproducer no longer triggers the same issue. https://godbolt.org/z/hhb8n6fnT But the backend issue probably still remains.

davemgreen avatar Jun 13 '25 08:06 davemgreen

The C reproducer no longer triggers the same issue. https://godbolt.org/z/hhb8n6fnT But the backend issue probably still remains.

I extracted the optimised IR from the original reproducer https://godbolt.org/z/fbafKd6We and can reproduce on 20, but it's fixed on trunk https://godbolt.org/z/GcnYej3fW. Which suggests it's actually been fixed and this can be closed?

c-rhodes avatar Aug 15 '25 12:08 c-rhodes

Yeah I believe this was fixed by better splitting of scalable bitcasts.

davemgreen avatar Aug 17 '25 20:08 davemgreen