[PATCH] D90554: [CostModel] remove cost-kind predicate for intrinsics in basic TTI implementation

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 2 12:02:46 PST 2020


spatel updated this revision to Diff 302350.
spatel added a comment.

Rebased - the x86 diffs changed with D90613 <https://reviews.llvm.org/D90613> and some cleanups in the test files.

For the ARM tests, I looked at @llvm.sadd.with.overflow() specifically, and the costs are based on this in the basic class:

  Cost += thisT()->getArithmeticInstrCost(Opcode, SumTy, CostKind);
  Cost += 3 * thisT()->getCmpSelInstrCost(
                  BinaryOperator::ICmp, SumTy, OverflowTy,
                  CmpInst::BAD_ICMP_PREDICATE, CostKind);
  Cost += 2 * thisT()->getCmpSelInstrCost(
                  BinaryOperator::ICmp, OverflowTy, OverflowTy,
                  CmpInst::BAD_ICMP_PREDICATE, CostKind);
  Cost += thisT()->getArithmeticInstrCost(BinaryOperator::And, OverflowTy,
                                          CostKind);

So we get for i32 as an example: 1 (add) + 3 (cmp) + 2 (select) + 2 (and) = 8. 
For vector types, it's similarly a sum of those basic ops, so it's up to the target to handle the scalarization costs, and that doesn't seem to be happening. For <4 x i32>, I see: 1 + 3 + 2 + 1 = 7.
And that may be drastically different than the expected throughput cost because we have this in ARMTTIImpl::getArithmeticInstrCost():

  // TODO: Handle more cost kinds.
  if (CostKind != TTI::TCK_RecipThroughput)

Do we need to fix that before trying this patch?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90554/new/

https://reviews.llvm.org/D90554

Files:
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/test/Analysis/CostModel/ARM/arith-overflow.ll
  llvm/test/Analysis/CostModel/ARM/arith-ssat.ll
  llvm/test/Analysis/CostModel/ARM/arith-usat.ll
  llvm/test/Analysis/CostModel/ARM/intrinsic-cost-kinds.ll
  llvm/test/Analysis/CostModel/X86/fmaxnum-size-latency.ll
  llvm/test/Analysis/CostModel/X86/fminnum-size-latency.ll
  llvm/test/Analysis/CostModel/X86/intrinsic-cost-kinds.ll
  llvm/test/Transforms/LoopVectorize/X86/gather_scatter.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90554.302350.patch
Type: text/x-patch
Size: 190028 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201102/8740d05c/attachment-0001.bin>


More information about the llvm-commits mailing list