[all-commits] [llvm/llvm-project] d764aa: [RISCV] Add cost model for scalable scatter and ga...

Philip Reames via All-commits all-commits at lists.llvm.org
Thu Jun 16 14:22:46 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d764aa7fc6b9cc3fbe960019018f5f9e941eb0a6
      https://github.com/llvm/llvm-project/commit/d764aa7fc6b9cc3fbe960019018f5f9e941eb0a6
  Author: Philip Reames <preames at rivosinc.com>
  Date:   2022-06-16 (Thu, 16 Jun 2022)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
    M llvm/test/Analysis/CostModel/RISCV/scalable-gather.ll
    M llvm/test/Analysis/CostModel/RISCV/scalable-scatter.ll

  Log Message:
  -----------
  [RISCV] Add cost model for scalable scatter and gather

The costing we use for fixed length vector gather and scatter is to simply count up the memory ops, and multiply by a fixed memory op cost. For scalable vectors, we don't actually know how many lanes are active. Instead, we have to end up making a worst case assumption on how many lanes could be active. In the generic +V case, this results in very high costs, but we can do better when we know an upper bound on the VLEN.

There's some obvious ways to improve this - e.g. using information about VL and mask bits from the instruction to reduce the upper bound - but this seems like a reasonable starting point.

The resulting costs do bias us pretty strongly away from generating scatter/gather for generic +V.  Without this, we'd be returning an invalid cost and thus definitely not vectorizing, so no major change in practical behavior expected.

Differential Revision: https://reviews.llvm.org/D127541




More information about the All-commits mailing list