[all-commits] [llvm/llvm-project] 536095: [RISCV] Refine costs for i1 reductions

Philip Reames via All-commits all-commits at lists.llvm.org
Fri Jun 10 13:30:33 PDT 2022


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

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
    M llvm/test/Analysis/CostModel/RISCV/reduce-add.ll
    M llvm/test/Analysis/CostModel/RISCV/reduce-and.ll
    M llvm/test/Analysis/CostModel/RISCV/reduce-max.ll
    M llvm/test/Analysis/CostModel/RISCV/reduce-min.ll
    M llvm/test/Analysis/CostModel/RISCV/reduce-or.ll
    M llvm/test/Analysis/CostModel/RISCV/reduce-xor.ll

  Log Message:
  -----------
  [RISCV] Refine costs for i1 reductions

Our actual lowering for i1 reductions uses ctpop combined with possibly a vector negate and possibly a logic op afterwards. I believe ctpop to be low cost on all reasonable hardware.

The default costing implementation here was returning quite inconsistent costs. and/or were returning very high costs (because we seem to think moving into scalar registers is very expensive?) and others were returning lower but still too high (because of the assumed tree reduce strategy). While we should probably improve the generic costing strategy for i1 vectors, let's start by fixing the immediate problem.

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




More information about the All-commits mailing list