Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ktkachov opened this issue Aug 5, 2024 · 4 comments
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:SelectionDAG SelectionDAGISel as well

Comments

@ktkachov
Copy link

ktkachov commented Aug 5, 2024

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

@github-actions github-actions bot added the clang Clang issues not falling into any other category label Aug 5, 2024
@ktkachov ktkachov changed the title Clang error on aarch64: error in backend: Don't know how to widen the operands for INSERT_SUBVECTOR Clang crash on aarch64: error in backend: Don't know how to widen the operands for INSERT_SUBVECTOR Aug 5, 2024
@RKSimon RKSimon added backend:AArch64 llvm:codegen llvm:SelectionDAG SelectionDAGISel as well and removed clang Clang issues not falling into any other category labels Aug 6, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 6, 2024

@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

@sdesmalen-arm
Copy link
Collaborator

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.

@davemgreen
Copy link
Collaborator

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.

abhishek-kaushik22 added a commit to abhishek-kaushik22/llvm-project that referenced this issue Jan 25, 2025
…OR_ELT`

If the operands to `INSERT_SUBVECTOR` can't be widened legally, just replace the `INSERT_SUBVECTOR` with a series of `INSERT_VECTOR_ELT`.

Closes llvm#124255 (and possibly llvm#102016)
abhishek-kaushik22 added a commit that referenced this issue Jan 28, 2025
…R` with series of `INSERT_VECTOR_ELT` (#124420)

If the operands to `INSERT_SUBVECTOR` can't be widened legally, just
replace the `INSERT_SUBVECTOR` with a series of `INSERT_VECTOR_ELT`.

Closes #124255 (and possibly #102016)
@abhishek-kaushik22
Copy link
Contributor

Please reopen if still not fixed.

@EugeneZelenko EugeneZelenko added crash Prefer [crash-on-valid] or [crash-on-invalid] and removed backend:AArch64 llvm:codegen vectorizers labels Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:SelectionDAG SelectionDAGISel as well
Projects
None yet
Development

No branches or pull requests

7 participants