Issue 242245
Summary [RISCV] error in backend "Do not know how to promote this operator's operand!" on vp_scatter with BitInt and RVV
Labels new issue
Assignees
Reporter hazohelet
    Live Reproducer: [https://godbolt.org/z/3fv5MGoGn](<https://godbolt.org/z/3fv5MGoGn>)

Compiling the following C code for `riscv64` with `-march=rv64gcv` and `clang -O2` crashes.

```c
void f(int *a, unsigned _BitInt(9) i) {
  for (; i; i++)
 a[i & 2] = 0;
}
```

clang command:

```sh
clang --target=riscv64-linux-gnu -march=rv64gcv -O2 -c repro.c
```

The compiler crashes with the following output:

```
PromoteIntegerOperand Op #3: t60: ch = vp_scatter<(store unknown-size, align 4, !tbaa !9)> t0, t29, t22, t59, TargetConstant:i64<1>, t33, t80

fatal error: error in backend: Do not know how to promote this operator's operand!
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: clang --target=riscv64-linux-gnu -march=rv64gcv -O2 -c repro.c
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'repro.c'.
4.	Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on function '@f'
...
 #7 0x... llvm::DAGTypeLegalizer::PromoteIntegerOperand(llvm::SDNode*, unsigned int)
 #8 0x... llvm::DAGTypeLegalizer::run()
 #9 0x... llvm::SelectionDAG::LegalizeTypes()
#10 0x... llvm::SelectionDAGISel::CodeGenAndEmitDAG()
```

Notes:

* `-O2`, `-O3` and `-Os` crash; `-O0`, `-O1`, `-Oz`, `-fno-vectorize` and `-march=rv64gc` compile it
* `i & 4` crashes too; `i & 1`, `i & 3` and `i & 7` compile
* Clang 22.1.8 compiles it; 23.1.2 crashes

clang version:

```text
clang version 24.0.0git (https://github.com/llvm/llvm-project 7d25e4f9cd72686727beaf0b661ce3e910ee1349)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to