[llvm] [RISCV][CostModel] Add getCFInstrCost RISC-V implementation (PR #65599)

Sergey Kachkov via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 7 07:40:07 PDT 2023


skachkov-sc wrote:

To put more context how LoopVectorizer is affected with this patch, let's consider the following example:
```
Loop:
  %indvar = phi(...)
  <loop body>
  %latch = icmp(...)
  br %latch, Loop, Exit
```
With current model, cost of loop is 3 + Cost(loop body), cost of vectorized loop is (3 + Cost(vectorized loop body))/VF (phi and branch have non-zero cost). After the change, cost is 1 + Cost(loop body) and (1 + Cost(vectorized loop body))/VF respectively, so cost of scalar loop is reduced by 2, cost of vectorized loop is reduced by 2/VF (VF > 1), and in some cases the cost of scalar loop may become less then cost of vectorized loop.

https://github.com/llvm/llvm-project/pull/65599


More information about the llvm-commits mailing list