[llvm] r179413 - CostModel: increase the default cost of supported floating point operations from 1 to two. Fixed a few tests that changes because now the cost of one insert + a vector operation on two doubles is lower than two scalar operations on doubles.
Nadav Rotem
nrotem at apple.com
Fri Apr 12 14:15:03 PDT 2013
Author: nadav
Date: Fri Apr 12 16:15:03 2013
New Revision: 179413
URL: http://llvm.org/viewvc/llvm-project?rev=179413&view=rev
Log:
CostModel: increase the default cost of supported floating point operations from 1 to two. Fixed a few tests that changes because now the cost of one insert + a vector operation on two doubles is lower than two scalar operations on doubles.
Modified:
llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp
llvm/trunk/test/Analysis/CostModel/X86/arith.ll
llvm/trunk/test/Transforms/BBVectorize/X86/loop1.ll
llvm/trunk/test/Transforms/BBVectorize/X86/simple.ll
Modified: llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp?rev=179413&r1=179412&r2=179413&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/BasicTargetTransformInfo.cpp Fri Apr 12 16:15:03 2013
@@ -204,20 +204,23 @@ unsigned BasicTTI::getArithmeticInstrCos
std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Ty);
+ bool IsFloat = Ty->getScalarType()->isFloatingPointTy();
+ unsigned OpCost = (IsFloat ? 2 : 1);
+
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;
+ return LT.first * 2 * OpCost;
+ return LT.first * 1 * OpCost;
}
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;
+ return LT.first * 2 * OpCost;
}
// Else, assume that we need to scalarize this op.
@@ -230,7 +233,7 @@ unsigned BasicTTI::getArithmeticInstrCos
}
// We don't know anything about this scalar instruction.
- return 1;
+ return OpCost;
}
unsigned BasicTTI::getShuffleCost(ShuffleKind Kind, Type *Tp, int Index,
Modified: llvm/trunk/test/Analysis/CostModel/X86/arith.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CostModel/X86/arith.ll?rev=179413&r1=179412&r2=179413&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/CostModel/X86/arith.ll (original)
+++ llvm/trunk/test/Analysis/CostModel/X86/arith.ll Fri Apr 12 16:15:03 2013
@@ -66,9 +66,9 @@ define void @avx2mull() {
; CHECK: fmul
define i32 @fmul(i32 %arg) {
- ;CHECK: cost of 1 {{.*}} fmul
+ ;CHECK: cost of 2 {{.*}} fmul
%A = fmul <4 x float> undef, undef
- ;CHECK: cost of 1 {{.*}} fmul
+ ;CHECK: cost of 2 {{.*}} fmul
%B = fmul <8 x float> undef, undef
ret i32 undef
}
Modified: llvm/trunk/test/Transforms/BBVectorize/X86/loop1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/BBVectorize/X86/loop1.ll?rev=179413&r1=179412&r2=179413&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/BBVectorize/X86/loop1.ll (original)
+++ llvm/trunk/test/Transforms/BBVectorize/X86/loop1.ll Fri Apr 12 16:15:03 2013
@@ -34,7 +34,15 @@ for.body:
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
%exitcond = icmp eq i32 %lftr.wideiv, 10
br i1 %exitcond, label %for.end, label %for.body
-; CHECK-NOT: <2 x double>
+; CHECK: insertelement
+; CHECK-NEXT: insertelement
+; CHECK-NEXT: fadd <2 x double>
+; CHECK-NEXT: insertelement
+; CHECK-NEXT: insertelement
+; CHECK-NEXT: fadd <2 x double>
+; CHECK-NEXT: insertelement
+; CHECK-NEXT: fmul <2 x double>
+
; CHECK-UNRL: %mul = fmul <2 x double> %2, %2
; CHECK-UNRL: %mul3 = fmul <2 x double> %2, %3
; CHECK-UNRL: %add = fadd <2 x double> %mul, %mul3
Modified: llvm/trunk/test/Transforms/BBVectorize/X86/simple.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/BBVectorize/X86/simple.ll?rev=179413&r1=179412&r2=179413&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/BBVectorize/X86/simple.ll (original)
+++ llvm/trunk/test/Transforms/BBVectorize/X86/simple.ll Fri Apr 12 16:15:03 2013
@@ -12,7 +12,11 @@ define double @test1(double %A1, double
%R = fmul double %Z1, %Z2
ret double %R
; CHECK: @test1
-; CHECK-NOT: fmul <2 x double>
+; CHECK: fsub <2 x double>
+; CHECK: fmul <2 x double>
+; CHECK: fadd <2 x double>
+; CHECK: extract
+; CHECK: extract
; CHECK: ret double %R
}
@@ -63,7 +67,12 @@ define double @test2(double %A1, double
%R = fmul double %Z1, %Z2
ret double %R
; CHECK: @test2
-; CHECK-NOT: fmul <2 x double>
+; CHECK: insertelement
+; CHECK: insertelement
+; CHECK: insertelement
+; CHECK: insertelement
+; CHECK: fsub <2 x double>
+; CHECK: fmul <2 x double>
; CHECK: ret double %R
}
@@ -80,7 +89,15 @@ define double @test4(double %A1, double
%R = fmul double %Z1, %Z2
ret double %R
; CHECK: @test4
-; CHECK-NOT: fmul <2 x double>
+; CHECK: insertelement
+; CHECK: insertelement
+; CHECK: insertelement
+; CHECK: insertelement
+; CHECK: fsub <2 x double>
+; CHECK: fmul <2 x double>
+; CHECK: insertelement
+; CHECK: insertelement
+; CHECK: fadd <2 x double>
; CHECK: ret double %R
}
More information about the llvm-commits
mailing list