From 39e9d60ebd27aa24f57d8aa5d4bd5de96a84f424 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Thu, 5 Jan 2017 22:48:02 +0000 Subject: [PATCH] [CostModel][X86] Tidyup arithmetic costs code. NFCI. Remove unnecessary braces, remove one use variables and keep LUTs to similar naming convention. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291187 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86TargetTransformInfo.cpp | 43 ++++++++--------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/lib/Target/X86/X86TargetTransformInfo.cpp b/lib/Target/X86/X86TargetTransformInfo.cpp index b19d5cb7714..80187a9fcc9 100644 --- a/lib/Target/X86/X86TargetTransformInfo.cpp +++ b/lib/Target/X86/X86TargetTransformInfo.cpp @@ -214,11 +214,9 @@ int X86TTIImpl::getArithmeticInstrCost( }; // Look for AVX512DQ lowering tricks for custom cases. - if (ST->hasDQI()) { - if (const auto *Entry = CostTableLookup(AVX512DQCostTable, ISD, - LT.second)) + if (ST->hasDQI()) + if (const auto *Entry = CostTableLookup(AVX512DQCostTable, ISD, LT.second)) return LT.first * Entry->Cost; - } static const CostTblEntry AVX512BWCostTable[] = { { ISD::MUL, MVT::v64i8, 11 }, // extend/pmullw/trunc sequence. @@ -237,11 +235,9 @@ int X86TTIImpl::getArithmeticInstrCost( }; // Look for AVX512BW lowering tricks for custom cases. - if (ST->hasBWI()) { - if (const auto *Entry = CostTableLookup(AVX512BWCostTable, ISD, - LT.second)) + if (ST->hasBWI()) + if (const auto *Entry = CostTableLookup(AVX512BWCostTable, ISD, LT.second)) return LT.first * Entry->Cost; - } static const CostTblEntry AVX512CostTable[] = { { ISD::SHL, MVT::v16i32, 1 }, @@ -257,10 +253,9 @@ int X86TTIImpl::getArithmeticInstrCost( { ISD::MUL, MVT::v8i64, 8 } // 3*pmuludq/3*shift/2*add }; - if (ST->hasAVX512()) { + if (ST->hasAVX512()) if (const auto *Entry = CostTableLookup(AVX512CostTable, ISD, LT.second)) return LT.first * Entry->Cost; - } static const CostTblEntry AVX2CostTable[] = { // Shifts on v4i64/v8i32 on AVX2 is legal even though we declare to @@ -320,10 +315,9 @@ int X86TTIImpl::getArithmeticInstrCost( }; // Look for XOP lowering tricks. - if (ST->hasXOP()) { + if (ST->hasXOP()) if (const auto *Entry = CostTableLookup(XOPCostTable, ISD, LT.second)) return LT.first * Entry->Cost; - } static const CostTblEntry AVX2CustomCostTable[] = { { ISD::SHL, MVT::v32i8, 11 }, // vpblendvb sequence. @@ -351,11 +345,10 @@ int X86TTIImpl::getArithmeticInstrCost( }; // Look for AVX2 lowering tricks for custom cases. - if (ST->hasAVX2()) { + if (ST->hasAVX2()) if (const auto *Entry = CostTableLookup(AVX2CustomCostTable, ISD, LT.second)) return LT.first * Entry->Cost; - } static const CostTblEntry AVXCustomCostTable[] = { { ISD::MUL, MVT::v32i8, 26 }, // extend/pmullw/trunc sequence. @@ -379,11 +372,10 @@ int X86TTIImpl::getArithmeticInstrCost( }; // Look for AVX2 lowering tricks for custom cases. - if (ST->hasAVX()) { + if (ST->hasAVX()) if (const auto *Entry = CostTableLookup(AVXCustomCostTable, ISD, LT.second)) return LT.first * Entry->Cost; - } static const CostTblEntry SSE2UniformCostTable[] = { @@ -480,10 +472,9 @@ int X86TTIImpl::getArithmeticInstrCost( { ISD::MUL, MVT::v4i32, 1 } // pmulld }; - if (ST->hasSSE41()) { + if (ST->hasSSE41()) if (const auto *Entry = CostTableLookup(SSE41CostTable, ISD, LT.second)) return LT.first * Entry->Cost; - } static const CostTblEntry SSE2CostTable[] = { // We don't correctly identify costs of casts because they are marked as @@ -532,10 +523,9 @@ int X86TTIImpl::getArithmeticInstrCost( { ISD::UDIV, MVT::v2i64, 2*20 }, }; - if (ST->hasSSE2()) { + if (ST->hasSSE2()) if (const auto *Entry = CostTableLookup(SSE2CostTable, ISD, LT.second)) return LT.first * Entry->Cost; - } static const CostTblEntry AVX1CostTable[] = { // We don't have to scalarize unsupported ops. We can issue two half-sized @@ -560,22 +550,19 @@ int X86TTIImpl::getArithmeticInstrCost( }; // Look for AVX1 lowering tricks. - if (ST->hasAVX() && !ST->hasAVX2()) { - MVT VT = LT.second; - - if (const auto *Entry = CostTableLookup(AVX1CostTable, ISD, VT)) + if (ST->hasAVX() && !ST->hasAVX2()) + if (const auto *Entry = CostTableLookup(AVX1CostTable, ISD, LT.second)) return LT.first * Entry->Cost; - } - static const CostTblEntry SSE1FloatCostTable[] = { + static const CostTblEntry SSE1CostTable[] = { { ISD::FDIV, MVT::f32, 17 }, // Pentium III from http://www.agner.org/ { ISD::FDIV, MVT::v4f32, 34 }, // Pentium III from http://www.agner.org/ }; if (ST->hasSSE1()) - if (const auto *Entry = CostTableLookup(SSE1FloatCostTable, ISD, - LT.second)) + if (const auto *Entry = CostTableLookup(SSE1CostTable, ISD, LT.second)) return LT.first * Entry->Cost; + // Fallback to the default implementation. return BaseT::getArithmeticInstrCost(Opcode, Ty, Op1Info, Op2Info); } -- 2.49.0