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

Luke Lau via All-commits all-commits at lists.llvm.org
Fri Sep 25 08:24:22 PDT 2026


  Branch: refs/heads/users/lukel97/loop-vectorize/handleFindLastReductions-freeze-cond
  Home:   https://github.com/llvm/llvm-project
  Commit: 2d39903c46d8b224dcdc73f37fc0ea11c0eacb94
      https://github.com/llvm/llvm-project/commit/2d39903c46d8b224dcdc73f37fc0ea11c0eacb94
  Author: Luke Lau <luke at igalia.com>
  Date:   2026-09-25 (Fri, 25 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

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, 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