[all-commits] [llvm/llvm-project] 48eb69: [LV] Count cost of middle block if TC <= VF. (#168...

Florian Hahn via All-commits all-commits at lists.llvm.org
Mon Nov 24 11:23:26 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 48eb697441e20f2e1a66d953436b9d66e0fc466d
      https://github.com/llvm/llvm-project/commit/48eb697441e20f2e1a66d953436b9d66e0fc466d
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2025-11-24 (Mon, 24 Nov 2025)

  Changed paths:
    M llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
    M llvm/test/Transforms/LoopVectorize/X86/replicating-load-store-costs.ll

  Log Message:
  -----------
  [LV] Count cost of middle block if TC <= VF. (#168949)

If the expected trip count is less than the VF, the vector loop will
only execute a single iteration. When that's the case, the cost of the
middle block has the same impact as the cost of the vector loop. Include
it in isOutsideLoopWorkProfitable to avoid vectorizing when the extra
work in the middle block makes it unprofitable.

Note that isOutsideLoopWorkProfitable already scales the cost of blocks
outside the vector region, but the patch restricts accounting for the
middle block to cases where VF <= ExpectedTC, to initially catch some
worst cases and avoid regressions.

This initial version should specifically avoid unprofitable tail-folding
for loops with low trip counts after re-applying
https://github.com/llvm/llvm-project/pull/149042.

PR: https://github.com/llvm/llvm-project/pull/168949



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