llvm / llvm/llvm-project

Shuffle lowering regressions on x86

Open
#203,132 1 comment 0 reactions 1 assignee Claimed by @RKSimon View on GitHub
backend:X86
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Small repro case here: https://godbolt.org/z/61898b6Ps

Looks like this regressed from Clang 17 to 18, then regressed even further from Clang 20 to Clang 21.

The 17->18 change looks like a x86 backend regression to me. 17 and 18 both have a int32 `shufflevector` with (0,1,2,3, 12,13,14,15) as the final operation, Clang 17 lowers it to `vblendps` while 18 uses `vinsertf128`.

The 20->21 regression looks trickier to me: evidently extra transforms ran at the IR level that got rid of the shuffles representing the i64 broadcast and coalesced all 3 original shuffles into a int64 `shufflevector` with indices (0,0,2,2).

Either way this was written specifically to avoid shuffle operations in a kernel that is already shuffle-heavy and bottlenecked on the relevant ports (especially on Intel Haswell through the Skylake variants which only have a single shuffle unit on port 5). The literal translation would've been great here (the broadcast-loads get handled by the load unit), this is strictly worse.

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.