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

Clang crash on aarch64: error in backend: Don't know how to widen the operands for INSERT_SUBVECTOR

Open ktkachov opened this issue 2 years ago • 4 comments

The testcase

long long a;
short b;
long c;
long d(long e) {
  if (e < c)
    return c;
  return e;
}
void f(short e[][12], long long g[][2][2]) {
  for (int h;;)
    for (int i; i < 10; i += e[-1][4])
#pragma clang loop vectorize_predicate(enable)
      for (char j; j < 012; j += 4) {
        b = g[1][h][j];
        a = d(a);
      }
}

crashes with -O3 -march=armv9-a error in backend: Don't know how to widen the operands for INSERT_SUBVECTOR

ktkachov avatar Aug 05 '24 16:08 ktkachov

@llvm/issue-subscribers-backend-aarch64

Author: Kyrill Tkachov (ktkachov)

The testcase ``` long long a; short b; long c; long d(long e) { if (e < c) return c; return e; } void f(short e[][12], long long g[][2][2]) { for (int h;;) for (int i; i < 10; i += e[-1][4]) #pragma clang loop vectorize_predicate(enable) for (char j; j < 012; j += 4) { b = g[1][h][j]; a = d(a); } } ``` crashes with -O3 -march=armv9-a error in backend: Don't know how to widen the operands for INSERT_SUBVECTOR

llvmbot avatar Aug 06 '24 08:08 llvmbot

When I try this on a build with assertions enabled, I get: Assertion 'VF.Width == BestVF && "VPlan cost model and legacy cost model disagreed"' failed.

It seems the LV has picked a VF=vscale x 1 which is not yet supported by AArch64 type legalisation, but the CostModel should have prevented this VF from being picked in the first place. Normally the cost-model returns an invalid cost for memory operations with this VF which would prevent using this VF, but I can't see the (VPlan?) cost-model querying the cost of the load/store operations in this loop.

sdesmalen-arm avatar Aug 06 '24 08:08 sdesmalen-arm

It looks like this would be fixed by #102105, but @sdesmalen-arm comment suggests there might be other case (which have only loads / stores, or other stuff that isn't handled by that patch), where it could still pick an invalid factor.

davemgreen avatar Aug 06 '24 10:08 davemgreen

Please reopen if still not fixed.

abhishek-kaushik22 avatar Jan 28 '25 13:01 abhishek-kaushik22