[all-commits] [llvm/llvm-project] d31b11: [LV] Make greater use of ScalarEvolution in addDif...

David Sherwood via All-commits all-commits at lists.llvm.org
Wed Aug 5 01:15:14 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d31b11c260ae09545222743ab5c61841dfe248da
      https://github.com/llvm/llvm-project/commit/d31b11c260ae09545222743ab5c61841dfe248da
  Author: David Sherwood <david.sherwood at arm.com>
  Date:   2026-08-05 (Wed, 05 Aug 2026)

  Changed paths:
    M llvm/include/llvm/Transforms/Utils/LoopUtils.h
    M llvm/lib/Transforms/Utils/LoopUtils.cpp
    M llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
    M llvm/test/Transforms/LoopVectorize/AArch64/alias-mask.ll
    M llvm/test/Transforms/LoopVectorize/AArch64/conditional-branches-cost.ll
    M llvm/test/Transforms/LoopVectorize/AArch64/induction-costs-sve.ll
    M llvm/test/Transforms/LoopVectorize/AArch64/scalable-struct-return.ll
    M llvm/test/Transforms/LoopVectorize/AArch64/sve-fneg.ll
    M llvm/test/Transforms/LoopVectorize/AArch64/sve-multiexit.ll
    A llvm/test/Transforms/LoopVectorize/AArch64/sve-nested-loop-diff-checks.ll
    M llvm/test/Transforms/LoopVectorize/AArch64/sve-runtime-check-size-based-threshold.ll
    M llvm/test/Transforms/LoopVectorize/AArch64/sve-vector-reverse.ll
    M llvm/test/Transforms/LoopVectorize/AArch64/sve2-histcnt.ll
    M llvm/test/Transforms/LoopVectorize/RISCV/alias-mask-force-evl.ll
    M llvm/test/Transforms/LoopVectorize/RISCV/fminimumnum.ll
    M llvm/test/Transforms/LoopVectorize/RISCV/riscv-vector-reverse.ll
    M llvm/test/Transforms/LoopVectorize/RISCV/strided-accesses.ll
    M llvm/test/Transforms/LoopVectorize/RISCV/tail-folding-bin-unary-ops-args.ll
    M llvm/test/Transforms/LoopVectorize/RISCV/tail-folding-call-intrinsics.ll
    M llvm/test/Transforms/LoopVectorize/RISCV/tail-folding-cast-intrinsics.ll
    M llvm/test/Transforms/LoopVectorize/scalable-first-order-recurrence.ll

  Log Message:
  -----------
  [LV] Make greater use of ScalarEvolution in addDiffRuntimeChecks (#213668)

When the loop vectoriser calls addDiffRuntimeChecks it goes to a lot of
effort to avoid generating multiple copies of the VF calculation by
caching the first instance. However, now that ScalarEvolution has a
getElementCount function we can simplify this code significantly,
especially since SCEVs are also implicitly cached. Make greater use of
SCEVs for computation also has the side-effect of improving code quality
in the memory check blocks, which is important when estimating costs of
these checks. You can see this in some tests like

LoopVectorize/AArch64/sve-runtime-check-size-based-threshold.ll

where the threshold for entering the loop has been relaxed.

Ideally, all computation in addDiffRuntimeChecks should be done using
SCEV because there are presumably other folds that can be applied to the
comparisons. However, I'd keep things simple in this PR and deal with
that in a follow-on PR.



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