[PATCH] D76478: [X86] More accurately model the cost of horizontal reductions for types.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 19 23:57:45 PDT 2020


craig.topper created this revision.
craig.topper added reviewers: spatel, RKSimon.
Herald added subscribers: zzheng, hiraditya.
Herald added a reviewer: aartbik.
Herald added a project: LLVM.

This patch attempts to more accurately model the reduction of
power of 2 vectors of types we natively support. This takes into
account the narrowing of vectors that occur as we go from 512
bits to 256 bits, to 128 bits. It also takes into account the use
of wider elements in the shuffles for the first 2 steps of a
reduction from 128 bits. And uses a v8i16 shift for the final step
of vXi8 reduction.

The default implementation uses the legalized type for the arithmetic
for all levels. And uses the single source permute cost of the
legalized type for all levels. This penalizes things like
lack of v16i8 pshufb on pre-sse3 targets and the splitting and
joining that needs to be done for integer types on AVX1. We never
need v16i8 shuffle for a reduction and we only need split AVX1 ops
when type the type wide and needs to be split. I think we're still
over costing splits and joins for AVX1, but we're closer now.

I've also removed all pairwise special casing because I don't
think we ever want to generate that on X86. I've also adjusted
the add handling to more accurately account for any type splitting
that occurs before we reach a legal type.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76478

Files:
  llvm/lib/Target/X86/X86TargetTransformInfo.cpp
  llvm/test/Analysis/CostModel/X86/reduce-add.ll
  llvm/test/Analysis/CostModel/X86/reduce-and.ll
  llvm/test/Analysis/CostModel/X86/reduce-mul.ll
  llvm/test/Analysis/CostModel/X86/reduce-or.ll
  llvm/test/Analysis/CostModel/X86/reduce-xor.ll
  llvm/test/Analysis/CostModel/X86/reduction.ll
  llvm/test/Transforms/SLPVectorizer/X86/reduction_unrolled.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76478.251557.patch
Type: text/x-patch
Size: 216776 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200320/d7000ed9/attachment-0001.bin>


More information about the llvm-commits mailing list