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

Backend crashes on a store to a large vector #122571

Open
npanchen opened this issue Jan 11, 2025 · 1 comment
Open

Backend crashes on a store to a large vector #122571

npanchen opened this issue Jan 11, 2025 · 1 comment

Comments

@npanchen
Copy link
Contributor

I'm investigating issue we have that is similar to #93391. From my understanding, the #93391 was closed assuming it's impossible to write C/C++ code that generates provided code as frontend will catch and report that large type.
However, our case is possible to reproduce using vector type that Clang and GCC support:

typedef int vtype __attribute__ ((vector_size (262144)));

void zero(vtype *x) {
  *x = *x ^ *x;
}
% clang -c test.c -O1 
Assertion failed: (SDNode::getMaxNumOperands() >= Vals.size() && "too many operands to fit into SDNode"), function createOperands, file SelectionDAG.cpp, line 13500

The IR is quite trivial:

define void @zero(ptr initializes((0, 262144)) %x) {
entry:
  store <65536 x i32> zeroinitializer, ptr %x, align 16
  ret void
}

C code can be compiled by GCC without any problems.

So the questions is: should backend correctly handle large vector sizes or it's assumed to be unsupported by LLVM in general, therefore vector with #elements > 65535 are disallowed ?

@topperc
Copy link
Collaborator

topperc commented Jan 11, 2025

gcc seems to have turned that into a memset of 0. If I change the xor to an add, gcc times out on godbolt.

We can raise the limit in the backend, but I suspect it would lead to long compile times for large vectors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants