[RISCV] Refine costs for i1 reductions
authorPhilip Reames <preames@rivosinc.com>
Fri, 10 Jun 2022 20:21:52 +0000 (13:21 -0700)
committerPhilip Reames <listmail@philipreames.com>
Fri, 10 Jun 2022 20:21:52 +0000 (13:21 -0700)
commit536095a27c17e2f30765111f57d36c0ee9e211c7
tree6dd61acf409d67f5513a969156d985fd939b9d6b
parentf7bb691d6140e83699a89c4adf67c1d850852a9c
[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
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
llvm/test/Analysis/CostModel/RISCV/reduce-add.ll
llvm/test/Analysis/CostModel/RISCV/reduce-and.ll
llvm/test/Analysis/CostModel/RISCV/reduce-max.ll
llvm/test/Analysis/CostModel/RISCV/reduce-min.ll
llvm/test/Analysis/CostModel/RISCV/reduce-or.ll
llvm/test/Analysis/CostModel/RISCV/reduce-xor.ll