[all-commits] [llvm/llvm-project] 26ecf9: [LoopVectorize] Further improve cost model for ear...

David Sherwood via All-commits all-commits at lists.llvm.org
Tue Mar 11 04:49:17 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 26ecf978951b79138b76afbba6a4adc926d28507
      https://github.com/llvm/llvm-project/commit/26ecf978951b79138b76afbba6a4adc926d28507
  Author: David Sherwood <david.sherwood at arm.com>
  Date:   2025-03-11 (Tue, 11 Mar 2025)

  Changed paths:
    M llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
    M llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
    A llvm/test/Transforms/LoopVectorize/AArch64/early_exit_costs.ll
    M llvm/test/Transforms/LoopVectorize/AArch64/simple_early_exit.ll

  Log Message:
  -----------
  [LoopVectorize] Further improve cost model for early exit loops (#126235)

Following on from #125058, this patch takes into account the
work done in the vector early exit block when assessing the
profitability of vectorising the loop. I have renamed
areRuntimeChecksProfitable to isOutsideLoopWorkProfitable and
we now pass in the early exit costs. As part of this, I have
added the ExtractFirstActive opcode to VPInstruction::computeCost.

It's worth pointing out that when we assess profitability of the
loop we calculate a minimum trip count and compare that against
the *maximum* trip count. However, since the loop has an early
exit the runtime trip count can still end up being less than the
minimum. Alternatively, we may never take the early exit at all
at runtime and so we have the opposite problem of over-estimating
the cost of the loop. The loop vectoriser cannot simultaneously
take two contradictory positions and so I feel the only sensible
thing to do is be conservative and assume the loop will be more
expensive than loops without early exits.

We may find in future that we need to adjust the cost according to
the probability of taking the early exit. This will become even
more important once we support multiple early exits. However, we
have to start somewhere and we can always revisit this later.



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