← Open Source & Engineering Work
LLVM Foundation · llvm/llvm-projectMerged · LLVM Core (PR #215076)

[X86] Vectorize non-power-of-two integer division (#215076)

Sole Author: Patrick Ribbsaeter (@patrickswedish) · Immutable Commit SHA: d7f1904ecf19040e686266af38e9df819e9485f4

Compiler backend SelectionDAG demand-analysis fix preserving vectorized SIMD lowering for legalized non-power-of-two integer division vectors (<3 x i32>, <5 x i32>) when every result lane is demanded.

[X86] Vectorize non-power-of-two integer division (#215076)

PR #215076

Merged Mainline

d7f1904

Immutable Git SHA

C++

Compiler

6 Lit Suites Verified

CI & Test Matrix

01 · Engineering problem

The failure mode

In X86 SelectionDAG lowering, the combine pass treated extract_vector_elt-only users as evidence of partial vector demand and scalarized integer division. For legalized non-power-of-two vector returns, every lane can surface as constant scalar extracts, causing unnecessary scalarization even when all lanes are demanded.

02 · Technical response

What changed

  1. 01Tracked constant extracted lane indices across X86ISelLowering SelectionDAG demand analysis.
  2. 02Distinguished full-lane extraction sets from genuinely partial-lane or variable-index extracts.
  3. 03Preserved vectorized integer division lowering when every result lane is demanded while retaining scalarization for partial demand.
  4. 04Updated X86 CodeGen lit regression suites across 6 test files.

03 · Verified outcome

Evidence-backed result

  • ✓Non-power-of-two integer division vectors remain vectorized on X86 when all lanes are demanded.
  • ✓Partial-lane and variable-index extracts retain existing scalarization behavior.
  • ✓Merged upstream into llvm/llvm-project main branch as commit d7f1904ecf19040e686266af38e9df819e9485f4.

04 · Cryptographic Git record

Immutable source evidence

C++LLVMSelectionDAGX86 CodeGenSIMD VectorizationCompilers

Independent open-source engineering authored solely by Patrick Ribbsaeter (@patrickswedish). Company and project names identify the public repository context only under nominative fair use. No employment, client, vendor, or partnership relationship is implied unless explicitly stated.