[all-commits] [llvm/llvm-project] b7bd84: [VPlan] Fix find last reductions not using frozen ...

Luke Lau via All-commits all-commits at lists.llvm.org
Tue Sep 29 03:38:09 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b7bd84ff2a30e08e7f1bd2b36db5f8ec9ba300ee
      https://github.com/llvm/llvm-project/commit/b7bd84ff2a30e08e7f1bd2b36db5f8ec9ba300ee
  Author: Luke Lau <luke at igalia.com>
  Date:   2026-09-29 (Tue, 29 Sep 2026)

  Changed paths:
    M llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
    M llvm/test/Transforms/LoopVectorize/AArch64/conditional-scalar-assignment-fold-tail.ll
    M llvm/test/Transforms/LoopVectorize/AArch64/conditional-scalar-assignment.ll
    M llvm/test/Transforms/LoopVectorize/AArch64/findlast-epilogue-loop.ll
    M llvm/test/Transforms/LoopVectorize/AArch64/sve-select-cmp.ll
    M llvm/test/Transforms/LoopVectorize/RISCV/conditional-scalar-assignment-fold-tail.ll
    M llvm/test/Transforms/LoopVectorize/RISCV/conditional-scalar-assignment.ll
    M llvm/test/Transforms/LoopVectorize/RISCV/iv-select-cmp.ll
    M llvm/test/Transforms/LoopVectorize/RISCV/select-cmp-reduction.ll
    M llvm/test/Transforms/LoopVectorize/VPlan/conditional-scalar-assignment-vplan.ll
    M llvm/test/Transforms/LoopVectorize/VPlan/interleave-conditional-scalar-assignment-vplan.ll
    M llvm/test/Transforms/LoopVectorize/X86/conditional-scalar-assignment.ll
    M llvm/test/Transforms/LoopVectorize/alias-mask.ll
    M llvm/test/Transforms/LoopVectorize/conditional-scalar-assignment-interleave-only.ll
    M llvm/test/Transforms/LoopVectorize/find-last-iv-sinkable-expr-tail-folding.ll
    M llvm/test/Transforms/LoopVectorize/find-last-iv-sinkable-expr.ll
    M llvm/test/Transforms/LoopVectorize/find-last-iv-sinkable-load.ll
    M llvm/test/Transforms/LoopVectorize/find-last-ptr-induction.ll
    M llvm/test/Transforms/LoopVectorize/find-last.ll
    M llvm/test/Transforms/LoopVectorize/iv-select-cmp-fold-tail.ll
    M llvm/test/Transforms/LoopVectorize/iv-select-cmp-non-const-iv-start.ll
    M llvm/test/Transforms/LoopVectorize/iv-select-cmp-trunc.ll
    M llvm/test/Transforms/LoopVectorize/iv-select-cmp.ll
    M llvm/test/Transforms/LoopVectorize/select-cmp.ll

  Log Message:
  -----------
  [VPlan] Fix find last reductions not using frozen condition in select (#223962)

A find last reduction is something like:

    (select c[n], x[n], (select c[n-1], x[n-1], (select ...)))

So even if previous iterations had poison for c[x], the top-level select
blocks it.

MaskSelect uses the non-frozen Cond, and that in turn is fed into
VPInstruction::ExtractLastActive, which in turn gets expanded to
vector.reduce.umax, which returns poison if any of the lanes were
poison.

So in the case e.g. c[n] = 1, c[n-1] = poison and VF=2, the scalar loop
returns x[n] whilst vector loop returns poison.

We're also introducing multiple uses of Cond which isn't sound for
undef, so for these reasons we need to use the frozen Cond.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list