aboutsummaryrefslogtreecommitdiff
path: root/lib/Target
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2012-12-23 17:31:23 +0000
committerNadav Rotem <nrotem@apple.com>2012-12-23 17:31:23 +0000
commit6f3d81a92919954d156c863d3aeb4ff09f701480 (patch)
treea0bcf58e9f4f3578a1b39cec0832bef2f55d677e /lib/Target
parenta1acf55738a9d6c0376c7d36b27897817685e157 (diff)
CostModel: Change the default target-independent implementation for finding
the cost of arithmetic functions. We now assume that the cost of arithmetic operations that are marked as Legal or Promote is low, but ops that are marked as custom are higher. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171002 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/TargetTransformImpl.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Target/TargetTransformImpl.cpp b/lib/Target/TargetTransformImpl.cpp
index 1f568506d9..3d640dc023 100644
--- a/lib/Target/TargetTransformImpl.cpp
+++ b/lib/Target/TargetTransformImpl.cpp
@@ -179,12 +179,22 @@ unsigned VectorTargetTransformImpl::getArithmeticInstrCost(unsigned Opcode,
std::pair<unsigned, MVT> LT = getTypeLegalizationCost(Ty);
- if (!TLI->isOperationExpand(ISD, LT.second)) {
- // The operation is legal. Assume it costs 1. Multiply
- // by the type-legalization overhead.
+ if (TLI->isOperationLegalOrPromote(ISD, LT.second)) {
+ // The operation is legal. Assume it costs 1.
+ // If the type is split to multiple registers, assume that thre is some
+ // overhead to this.
+ // TODO: Once we have extract/insert subvector cost we need to use them.
+ if (LT.first > 1)
+ return LT.first * 2;
return LT.first * 1;
}
+ if (!TLI->isOperationExpand(ISD, LT.second)) {
+ // If the operation is custom lowered then assume
+ // thare the code is twice as expensive.
+ return LT.first * 2;
+ }
+
// Else, assume that we need to scalarize this op.
if (Ty->isVectorTy()) {
unsigned Num = Ty->getVectorNumElements();