[Loongarch] assertion failure with loop vectorizer with BitInt
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Live Reproducer: https://godbolt.org/z/jaKvccPxE
Compiling the following C code for `loongarch64` with `clang -O1` crashes with assertion failure.
```c
typedef _BitInt(24) i24;
void f(i24 *a, i24 *b, long long *c, int n) {
#pragma clang loop vectorize_width(4)
for (int i = 0; i < n; i++)
c[i] = a[i] < b[i] ? 5LL : 0LL;
}
```
clang command:
```sh
clang --target=loongarch64-linux-gnu -O1 repro.c
```
The compiler crashes with the following output:
```
clang: /root/llvm-project/llvm/include/llvm/CodeGen/ValueTypes.h:340: llvm::MVT llvm::EVT::getSimpleVT() const: Assertion `isSimple() && "Expected a SimpleValueType!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics --target=loongarch64-linux-gnu -O1
1. parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module ''.
4. Running pass 'LoongArch DAG->DAG Pattern Instruction Selection' on function '@f'
...
#11 0x0000000002170a49 llvm::LoongArchTargetLowering::ReplaceNodeResults(llvm::SDNode*, llvm::SmallVectorImpl&, llvm::SelectionDAG&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2170a49)
#12 0x0000000005d782a6 llvm::DAGTypeLegalizer::CustomLowerNode(llvm::SDNode*, llvm::EVT, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5d782a6)
#13 0x0000000005dda73d llvm::DAGTypeLegalizer::SplitVectorResult(llvm::SDNode*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5dda73d)
#14 0x0000000005d78bcb llvm::DAGTypeLegalizer::run() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5d78bcb)
#15 0x0000000005d79bd1 llvm::SelectionDAG::LegalizeTypes() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5d79bd1)
#16 0x0000000005cdcceb llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5cdcceb)
#17 0x0000000005ce0d56 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ce0d56)
#18 0x0000000005ce23fc llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ce23fc)
#19 0x0000000005ccae4e llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ccae4e)
#20 0x00000000036efa6d llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
```
clang version:
```text
clang version 24.0.0git (https://github.com/llvm/llvm-project 05fa66e6624e6b14346e559cd7b692aaf48f3ca7)
```
This reproduces with current LLVM trunk.
Contributor guide
Research direction
Start by reproducing the supplied C code with clang --target=loongarch64-linux-gnu -O1. Read the LoongArchTargetLowering::ReplaceNodeResults and DAGTypeLegalizer frames in the stack trace, then trace the vectorized _BitInt lowering path. Done means the reproducer compiles without the ValueTypes.h assertion failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100