Issue 178777
Summary [X86] Backend crash: Cannot select any_extend from PINSRB result during udivrem vectorization
Labels new issue
Assignees
Reporter alexey-milovidov
    Clang crashes during instruction selection when compiling ClickHouse's `AggregateFunctionSparkbar.cpp` with -O3.

**Clang version:** 23.0.0git (commit 3c45148e9266bbd9830c2b977c497795d9307c72)

**Error:**
fatal error: error in backend: Cannot select: 0x...: i32 = any_extend ...
  ... v16i8 = X86ISD::PINSRB ...
    ... i8,i8 = udivrem ...

**Reproducer:**
[AggregateFunctionSparkbar-3d6231.sh](https://github.com/user-attachments/files/24950252/AggregateFunctionSparkbar-3d6231.sh)
[AggregateFunctionSparkbar-3d6231.cpp](https://github.com/user-attachments/files/24950256/AggregateFunctionSparkbar-3d6231.cpp)

**Analysis:**
The crash occurs in `X86DAGToDAGISel::Select` when the vectorizer creates a sequence involving:
1. 8-bit unsigned division (`udivrem`)
2. Results inserted into a v16i8 vector via `PINSRB`
3. An `any_extend` to i32 from the vector result

The X86 backend cannot select an instruction pattern for this combination.

**Workaround:**
Adding `#pragma clang optimize off` for this function.

See https://github.com/ClickHouse/ClickHouse/pull/95578
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to