Fixed SelectionDAG combine in LLVM X86 CodeGen. Corrected demand analysis so legalized non-power-of-two vector division operations (such as <3 x i32> or <5 x i32>) remain eligible for vectorized lowering when all lanes are demanded, while safely preserving scalarization for partial-lane and variable-index extraction.
Role
Category
Compiler Backend & Code Generation
Engineering discipline
MERGED UPSTREAM

Patrick Ribbsaeter · Independent open-source contribution
Engineering objective
The X86 SelectionDAG combine treated extract-only users as evidence of partial demand. For legalized non-power-of-two vector returns, every result lane can appear as scalar extracts, triggering premature scalarization even when the full vector result is needed, generating inefficient scalar instructions instead of packed vector operations.
Constraints
Approach
Tracked constant extracted lane indices within SelectionDAG demand analysis.
Differentiated all-lanes-demanded legalized vectors from genuine sub-vector partial demand.
Preserved scalarization for variable-index and partial-lane extraction paths.
Updated lit test checks across six affected X86 CodeGen regression suites.
Technical validation
Observable engineering evidence. Discipline: MERGED UPSTREAM
Merged PR
PR #215076 · merged
Merge Commit
d7f1904
Issue Resolved
#215061
Target
X86 SelectionDAG / AVX
Lit Suites
6 CodeGen Suites
Public evidence
Outcome
Unlocked vectorized SIMD lowering for non-power-of-two vector integer division when all lanes are demanded
Eliminated unnecessary scalar spill and register churn in generated machine code
Merged upstream into llvm/llvm-project (merge commit d7f1904)
Technologies
Explore Engineering Systems
Have an ambitious AI system to build?
I work across AI architecture, product engineering, private inference, automation, SaaS infrastructure, and production hardening.