From 0016b62b09a1d4151904ea4e8031412ba7caa607 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sun, 15 Jan 2017 20:44:00 +0000 Subject: [PATCH] [CostModel][X86] Fix AVX512BW vector shift costs for vXi16 types We already have patterns in place to support 128/256-bit shifts without AVX512VL git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292077 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86TargetTransformInfo.cpp | 8 ++++++++ test/Analysis/CostModel/X86/vshift-ashr-cost.ll | 12 ++++++++---- test/Analysis/CostModel/X86/vshift-lshr-cost.ll | 12 ++++++++---- test/Analysis/CostModel/X86/vshift-shl-cost.ll | 6 ++++-- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/lib/Target/X86/X86TargetTransformInfo.cpp b/lib/Target/X86/X86TargetTransformInfo.cpp index dfc2a8d8c62..567ef743f6b 100644 --- a/lib/Target/X86/X86TargetTransformInfo.cpp +++ b/lib/Target/X86/X86TargetTransformInfo.cpp @@ -323,6 +323,14 @@ int X86TTIImpl::getArithmeticInstrCost( return LT.first * Entry->Cost; static const CostTblEntry AVX512BWCostTable[] = { + { ISD::SHL, MVT::v8i16, 1 }, // vpsllvw + { ISD::SRL, MVT::v8i16, 1 }, // vpsrlvw + { ISD::SRA, MVT::v8i16, 1 }, // vpsravw + + { ISD::SHL, MVT::v16i16, 1 }, // vpsllvw + { ISD::SRL, MVT::v16i16, 1 }, // vpsrlvw + { ISD::SRA, MVT::v16i16, 1 }, // vpsravw + { ISD::SHL, MVT::v32i16, 1 }, // vpsllvw { ISD::SRL, MVT::v32i16, 1 }, // vpsrlvw { ISD::SRA, MVT::v32i16, 1 }, // vpsravw diff --git a/test/Analysis/CostModel/X86/vshift-ashr-cost.ll b/test/Analysis/CostModel/X86/vshift-ashr-cost.ll index 811914b6666..a23b13fb2e2 100644 --- a/test/Analysis/CostModel/X86/vshift-ashr-cost.ll +++ b/test/Analysis/CostModel/X86/vshift-ashr-cost.ll @@ -98,7 +98,8 @@ define <8 x i16> @var_shift_v8i16(<8 x i16> %a, <8 x i16> %b) { ; SSE41: Found an estimated cost of 14 for instruction: %shift ; AVX: Found an estimated cost of 14 for instruction: %shift ; AVX2: Found an estimated cost of 14 for instruction: %shift -; AVX512: Found an estimated cost of 14 for instruction: %shift +; AVX512F: Found an estimated cost of 14 for instruction: %shift +; AVX512BW: Found an estimated cost of 1 for instruction: %shift ; XOP: Found an estimated cost of 2 for instruction: %shift %shift = ashr <8 x i16> %a, %b ret <8 x i16> %shift @@ -110,7 +111,8 @@ define <16 x i16> @var_shift_v16i16(<16 x i16> %a, <16 x i16> %b) { ; SSE41: Found an estimated cost of 28 for instruction: %shift ; AVX: Found an estimated cost of 28 for instruction: %shift ; AVX2: Found an estimated cost of 10 for instruction: %shift -; AVX512: Found an estimated cost of 10 for instruction: %shift +; AVX512F: Found an estimated cost of 10 for instruction: %shift +; AVX512BW: Found an estimated cost of 1 for instruction: %shift ; XOP: Found an estimated cost of 4 for instruction: %shift %shift = ashr <16 x i16> %a, %b ret <16 x i16> %shift @@ -432,7 +434,8 @@ define <8 x i16> @constant_shift_v8i16(<8 x i16> %a) { ; SSE41: Found an estimated cost of 14 for instruction: %shift ; AVX: Found an estimated cost of 14 for instruction: %shift ; AVX2: Found an estimated cost of 14 for instruction: %shift -; AVX512: Found an estimated cost of 14 for instruction: %shift +; AVX512F: Found an estimated cost of 14 for instruction: %shift +; AVX512BW: Found an estimated cost of 1 for instruction: %shift ; XOP: Found an estimated cost of 2 for instruction: %shift %shift = ashr <8 x i16> %a, ret <8 x i16> %shift @@ -444,7 +447,8 @@ define <16 x i16> @constant_shift_v16i16(<16 x i16> %a) { ; SSE41: Found an estimated cost of 28 for instruction: %shift ; AVX: Found an estimated cost of 28 for instruction: %shift ; AVX2: Found an estimated cost of 10 for instruction: %shift -; AVX512: Found an estimated cost of 10 for instruction: %shift +; AVX512F: Found an estimated cost of 10 for instruction: %shift +; AVX512BW: Found an estimated cost of 1 for instruction: %shift ; XOP: Found an estimated cost of 4 for instruction: %shift %shift = ashr <16 x i16> %a, ret <16 x i16> %shift diff --git a/test/Analysis/CostModel/X86/vshift-lshr-cost.ll b/test/Analysis/CostModel/X86/vshift-lshr-cost.ll index f1cc2747c9d..546b2bb50f2 100644 --- a/test/Analysis/CostModel/X86/vshift-lshr-cost.ll +++ b/test/Analysis/CostModel/X86/vshift-lshr-cost.ll @@ -101,7 +101,8 @@ define <8 x i16> @var_shift_v8i16(<8 x i16> %a, <8 x i16> %b) { ; SSE41: Found an estimated cost of 14 for instruction: %shift ; AVX: Found an estimated cost of 14 for instruction: %shift ; AVX2: Found an estimated cost of 14 for instruction: %shift -; AVX512: Found an estimated cost of 14 for instruction: %shift +; AVX512F: Found an estimated cost of 14 for instruction: %shift +; AVX512BW: Found an estimated cost of 1 for instruction: %shift ; XOP: Found an estimated cost of 2 for instruction: %shift %shift = lshr <8 x i16> %a, %b ret <8 x i16> %shift @@ -113,7 +114,8 @@ define <16 x i16> @var_shift_v16i16(<16 x i16> %a, <16 x i16> %b) { ; SSE41: Found an estimated cost of 28 for instruction: %shift ; AVX: Found an estimated cost of 28 for instruction: %shift ; AVX2: Found an estimated cost of 10 for instruction: %shift -; AVX512: Found an estimated cost of 10 for instruction: %shift +; AVX512F: Found an estimated cost of 10 for instruction: %shift +; AVX512BW: Found an estimated cost of 1 for instruction: %shift ; XOP: Found an estimated cost of 4 for instruction: %shift %shift = lshr <16 x i16> %a, %b ret <16 x i16> %shift @@ -437,7 +439,8 @@ define <8 x i16> @constant_shift_v8i16(<8 x i16> %a) { ; SSE41: Found an estimated cost of 14 for instruction: %shift ; AVX: Found an estimated cost of 14 for instruction: %shift ; AVX2: Found an estimated cost of 14 for instruction: %shift -; AVX512: Found an estimated cost of 14 for instruction: %shift +; AVX512F: Found an estimated cost of 14 for instruction: %shift +; AVX512BW: Found an estimated cost of 1 for instruction: %shift ; XOP: Found an estimated cost of 2 for instruction: %shift %shift = lshr <8 x i16> %a, ret <8 x i16> %shift @@ -449,7 +452,8 @@ define <16 x i16> @constant_shift_v16i16(<16 x i16> %a) { ; SSE41: Found an estimated cost of 28 for instruction: %shift ; AVX: Found an estimated cost of 28 for instruction: %shift ; AVX2: Found an estimated cost of 10 for instruction: %shift -; AVX512: Found an estimated cost of 10 for instruction: %shift +; AVX512F: Found an estimated cost of 10 for instruction: %shift +; AVX512BW: Found an estimated cost of 1 for instruction: %shift ; XOP: Found an estimated cost of 4 for instruction: %shift %shift = lshr <16 x i16> %a, ret <16 x i16> %shift diff --git a/test/Analysis/CostModel/X86/vshift-shl-cost.ll b/test/Analysis/CostModel/X86/vshift-shl-cost.ll index 5d0590a3542..90356f5ce8b 100644 --- a/test/Analysis/CostModel/X86/vshift-shl-cost.ll +++ b/test/Analysis/CostModel/X86/vshift-shl-cost.ll @@ -102,7 +102,8 @@ define <8 x i16> @var_shift_v8i16(<8 x i16> %a, <8 x i16> %b) { ; SSE41: Found an estimated cost of 14 for instruction: %shift ; AVX: Found an estimated cost of 14 for instruction: %shift ; AVX2: Found an estimated cost of 14 for instruction: %shift -; AVX512: Found an estimated cost of 14 for instruction: %shift +; AVX512F: Found an estimated cost of 14 for instruction: %shift +; AVX512BW: Found an estimated cost of 1 for instruction: %shift ; XOP: Found an estimated cost of 1 for instruction: %shift %shift = shl <8 x i16> %a, %b ret <8 x i16> %shift @@ -114,7 +115,8 @@ define <16 x i16> @var_shift_v16i16(<16 x i16> %a, <16 x i16> %b) { ; SSE41: Found an estimated cost of 28 for instruction: %shift ; AVX: Found an estimated cost of 28 for instruction: %shift ; AVX2: Found an estimated cost of 10 for instruction: %shift -; AVX512: Found an estimated cost of 10 for instruction: %shift +; AVX512F: Found an estimated cost of 10 for instruction: %shift +; AVX512BW: Found an estimated cost of 1 for instruction: %shift ; XOP: Found an estimated cost of 2 for instruction: %shift %shift = shl <16 x i16> %a, %b ret <16 x i16> %shift -- 2.40.0