Skip to content

Commit

Permalink
[TTI CostModel] change default cost of FP ops to 1 (PR36280)
Browse files Browse the repository at this point in the history
This change was mentioned at least as far back as:
https://bugs.llvm.org/show_bug.cgi?id=26837#c26
...and I found a real program that is harmed by this: 
Himeno running on AMD Jaguar gets 6% slower with SLP vectorization:
https://bugs.llvm.org/show_bug.cgi?id=36280
...but the change here appears to solve that bug only accidentally.

The div/rem costs for x86 look very wrong in some cases, but that's already true, 
so we can fix those in follow-up patches. There's also evidence that more cost model
changes are needed to solve SLP problems as shown in D42981, but that's an independent 
problem (though the solution may be adjusted after this change is made).

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

llvm-svn: 325515
  • Loading branch information
rotateright committed Feb 19, 2018
1 parent c7e5180 commit 3e8a76a
Show file tree
Hide file tree
Showing 11 changed files with 297 additions and 355 deletions.
10 changes: 6 additions & 4 deletions llvm/include/llvm/CodeGen/BasicTTIImpl.h
Expand Up @@ -488,10 +488,12 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {

std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(DL, Ty);

bool IsFloat = Ty->isFPOrFPVectorTy();
// Assume that floating point arithmetic operations cost twice as much as
// integer operations.
unsigned OpCost = (IsFloat ? 2 : 1);
// Assume that the throughput of any integer or floating-point math
// operation is the same and maximal (disregarding free operations).
// That is, operations with less throughput should have a relative cost
// greater than 1. Targets should override this assumption when they can
// provide more accurate information.
unsigned OpCost = 1;

if (TLI->isOperationLegalOrPromote(ISD, LT.second)) {
// The operation is legal. Assume it costs 1.
Expand Down

0 comments on commit 3e8a76a

Please sign in to comment.