llvm / llvm/llvm-project

[X86] Backend crash: Cannot select any_extend from PINSRB result during udivrem vectorization

Open
#178,777 8 comments 0 reactions 0 assignees View on GitHub
crash vectorizers
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.