[PATCH] D55397: [CostModel][X86] Fix overcounting arithmetic cost in illegal types getArithmeticReductionCost

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 6 16:04:30 PST 2018


craig.topper created this revision.
craig.topper added reviewers: spatel, RKSimon.
Herald added a subscriber: zzheng.

We were overcounting the number of arithmetic operations needed at each level before we reach a legal type. We were using the full vector type for that level, but we are going to split the input vector at that level in half. So the effective arithmetic operation cost at that level is half the width.

So for example on 8i32 on an sse target. Were were calculating the cost of an 8i32 op which is likely 2 for basic integer. Then after the loop we count 2 more v4i32 ops. For a total arith cost of 4. But if you look at the assembly there would only be 3 arithmetic ops.

There are still more bugs in this code that I'm going to work on next. The non pairwise code shouldn't count extract subvectors in the loop. There are no extracts, the types are split in registers. For pairwise we need to use 2 two src permute shuffles.


https://reviews.llvm.org/D55397

Files:
  include/llvm/CodeGen/BasicTTIImpl.h
  test/Analysis/CostModel/X86/reduce-add-widen.ll
  test/Analysis/CostModel/X86/reduce-add.ll
  test/Analysis/CostModel/X86/reduce-and-widen.ll
  test/Analysis/CostModel/X86/reduce-and.ll
  test/Analysis/CostModel/X86/reduce-mul-widen.ll
  test/Analysis/CostModel/X86/reduce-mul.ll
  test/Analysis/CostModel/X86/reduce-or-widen.ll
  test/Analysis/CostModel/X86/reduce-or.ll
  test/Analysis/CostModel/X86/reduce-xor-widen.ll
  test/Analysis/CostModel/X86/reduce-xor.ll
  test/Analysis/CostModel/X86/reduction.ll
  test/Transforms/SLPVectorizer/X86/reduction_unrolled.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55397.177075.patch
Type: text/x-patch
Size: 403338 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181207/983b548d/attachment-0001.bin>


More information about the llvm-commits mailing list