From 076967c8064b62b0b3563af71bc4f570bb37060d Mon Sep 17 00:00:00 2001 From: Silviu Baranga Date: Wed, 9 Sep 2015 15:35:02 +0000 Subject: [PATCH] [CostModel][AArch64] Remove amortization factor for some of the vector select instructions Summary: We are not scalarizing the wide selects in codegen for i16 and i32 and therefore we can remove the amortization factor. We still have issues with i64 vectors in codegen though. Reviewers: mcrosier Subscribers: mcrosier, aemerson, llvm-commits, rengolin Differential Revision: http://reviews.llvm.org/D12724 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247156 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/AArch64/AArch64TargetTransformInfo.cpp | 9 +++++---- test/Analysis/CostModel/AArch64/select.ll | 12 ++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/Target/AArch64/AArch64TargetTransformInfo.cpp b/lib/Target/AArch64/AArch64TargetTransformInfo.cpp index 79f657fa26b..f7bad98a74a 100644 --- a/lib/Target/AArch64/AArch64TargetTransformInfo.cpp +++ b/lib/Target/AArch64/AArch64TargetTransformInfo.cpp @@ -380,15 +380,16 @@ int AArch64TTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy) { int ISD = TLI->InstructionOpcodeToISD(Opcode); - // We don't lower vector selects well that are wider than the register width. + // We don't lower some vector selects well that are wider than the register + // width. if (ValTy->isVectorTy() && ISD == ISD::SELECT) { // We would need this many instructions to hide the scalarization happening. const int AmortizationCost = 20; static const TypeConversionCostTblEntry VectorSelectTbl[] = { - { ISD::SELECT, MVT::v16i1, MVT::v16i16, 16 * AmortizationCost }, - { ISD::SELECT, MVT::v8i1, MVT::v8i32, 8 * AmortizationCost }, - { ISD::SELECT, MVT::v16i1, MVT::v16i32, 16 * AmortizationCost }, + { ISD::SELECT, MVT::v16i1, MVT::v16i16, 16 }, + { ISD::SELECT, MVT::v8i1, MVT::v8i32, 8 }, + { ISD::SELECT, MVT::v16i1, MVT::v16i32, 16 }, { ISD::SELECT, MVT::v4i1, MVT::v4i64, 4 * AmortizationCost }, { ISD::SELECT, MVT::v8i1, MVT::v8i64, 8 * AmortizationCost }, { ISD::SELECT, MVT::v16i1, MVT::v16i64, 16 * AmortizationCost } diff --git a/test/Analysis/CostModel/AArch64/select.ll b/test/Analysis/CostModel/AArch64/select.ll index 216dc5ddc48..1a1248e661c 100644 --- a/test/Analysis/CostModel/AArch64/select.ll +++ b/test/Analysis/CostModel/AArch64/select.ll @@ -17,16 +17,16 @@ define void @select() { ; CHECK: cost of 1 {{.*}} select %v6 = select i1 undef, double undef, double undef - ; Vector values - check for vectors that have a high cost because they end up - ; scalarized. - ; CHECK: cost of 320 {{.*}} select + ; CHECK: cost of 16 {{.*}} select %v13b = select <16 x i1> undef, <16 x i16> undef, <16 x i16> undef - ; CHECK: cost of 160 {{.*}} select + ; CHECK: cost of 8 {{.*}} select %v15b = select <8 x i1> undef, <8 x i32> undef, <8 x i32> undef - ; CHECK: cost of 320 {{.*}} select + ; CHECK: cost of 16 {{.*}} select %v15c = select <16 x i1> undef, <16 x i32> undef, <16 x i32> undef + ; Vector values - check for vectors of i64s that have a high cost because + ; they end up scalarized. ; CHECK: cost of 80 {{.*}} select %v16a = select <4 x i1> undef, <4 x i64> undef, <4 x i64> undef ; CHECK: cost of 160 {{.*}} select @@ -34,5 +34,5 @@ define void @select() { ; CHECK: cost of 320 {{.*}} select %v16c = select <16 x i1> undef, <16 x i64> undef, <16 x i64> undef - ret void + ret void } -- 2.34.1