From: Roman Lebedev Date: Mon, 15 Nov 2021 15:55:39 +0000 (+0300) Subject: [X86][Costmodel] `trunc v8i64 to v16i8/v32i8/v64i8` can appear after legalization... X-Git-Tag: upstream/15.0.7~25692 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9e57d9b09deaa9454c5c081acd68b76ba8ac76bf;p=platform%2Fupstream%2Fllvm.git [X86][Costmodel] `trunc v8i64 to v16i8/v32i8/v64i8` can appear after legalization, cost is same as for `trunc v8i64 to v8i8` While this one is trivial and identical to the previous patch, there is a weird cost change in a follow-up patch that i'm not sure about. Reviewed By: RKSimon Differential Revision: https://reviews.llvm.org/D113851 --- diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp index 7bfa7eb..ee8df2e 100644 --- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp +++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp @@ -1674,6 +1674,9 @@ InstructionCost X86TTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst, { ISD::TRUNCATE, MVT::v2i8, MVT::v2i64, 2 }, // vpmovqb { ISD::TRUNCATE, MVT::v2i16, MVT::v2i64, 1 }, // vpshufb { ISD::TRUNCATE, MVT::v8i8, MVT::v8i64, 2 }, // vpmovqb + { ISD::TRUNCATE, MVT::v16i8, MVT::v8i64, 2 }, // vpmovqb + { ISD::TRUNCATE, MVT::v32i8, MVT::v8i64, 2 }, // vpmovqb + { ISD::TRUNCATE, MVT::v64i8, MVT::v8i64, 2 }, // vpmovqb { ISD::TRUNCATE, MVT::v8i16, MVT::v8i64, 2 }, // vpmovqw { ISD::TRUNCATE, MVT::v16i16, MVT::v8i64, 2 }, // vpmovqw { ISD::TRUNCATE, MVT::v32i16, MVT::v8i64, 2 }, // vpmovqw diff --git a/llvm/test/Analysis/CostModel/X86/trunc.ll b/llvm/test/Analysis/CostModel/X86/trunc.ll index 0e4a356..7816649 100644 --- a/llvm/test/Analysis/CostModel/X86/trunc.ll +++ b/llvm/test/Analysis/CostModel/X86/trunc.ll @@ -1114,36 +1114,36 @@ define i32 @trunc_vXi8() { ; AVX512F-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %i64 = trunc i64 undef to i8 ; AVX512F-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V2i64 = trunc <2 x i64> undef to <2 x i8> ; AVX512F-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V4i64 = trunc <4 x i64> undef to <4 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 12 for instruction: %V6i64 = trunc <6 x i64> undef to <6 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V6i64 = trunc <6 x i64> undef to <6 x i8> ; AVX512F-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V8i64 = trunc <8 x i64> undef to <8 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 20 for instruction: %V10i64 = trunc <10 x i64> undef to <10 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 24 for instruction: %V12i64 = trunc <12 x i64> undef to <12 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 28 for instruction: %V14i64 = trunc <14 x i64> undef to <14 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V10i64 = trunc <10 x i64> undef to <10 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V12i64 = trunc <12 x i64> undef to <12 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V14i64 = trunc <14 x i64> undef to <14 x i8> ; AVX512F-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %V16i64 = trunc <16 x i64> undef to <16 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 47 for instruction: %V20i64 = trunc <20 x i64> undef to <20 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 59 for instruction: %V24i64 = trunc <24 x i64> undef to <24 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 71 for instruction: %V28i64 = trunc <28 x i64> undef to <28 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 11 for instruction: %V32i64 = trunc <32 x i64> undef to <32 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 108 for instruction: %V40i64 = trunc <40 x i64> undef to <40 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 131 for instruction: %V48i64 = trunc <48 x i64> undef to <48 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 157 for instruction: %V56i64 = trunc <56 x i64> undef to <56 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 23 for instruction: %V64i64 = trunc <64 x i64> undef to <64 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 213 for instruction: %V80i64 = trunc <80 x i64> undef to <80 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 262 for instruction: %V96i64 = trunc <96 x i64> undef to <96 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 311 for instruction: %V112i64 = trunc <112 x i64> undef to <112 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 46 for instruction: %V128i64 = trunc <128 x i64> undef to <128 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 442 for instruction: %V160i64 = trunc <160 x i64> undef to <160 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 540 for instruction: %V192i64 = trunc <192 x i64> undef to <192 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 622 for instruction: %V224i64 = trunc <224 x i64> undef to <224 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 92 for instruction: %V256i64 = trunc <256 x i64> undef to <256 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 900 for instruction: %V320i64 = trunc <320 x i64> undef to <320 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 1080 for instruction: %V384i64 = trunc <384 x i64> undef to <384 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 1260 for instruction: %V448i64 = trunc <448 x i64> undef to <448 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 184 for instruction: %V512i64 = trunc <512 x i64> undef to <512 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 1800 for instruction: %V640i64 = trunc <640 x i64> undef to <640 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 2160 for instruction: %V768i64 = trunc <768 x i64> undef to <768 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 2520 for instruction: %V896i64 = trunc <896 x i64> undef to <896 x i8> -; AVX512F-NEXT: Cost Model: Found an estimated cost of 368 for instruction: %V1024i64 = trunc <1024 x i64> undef to <1024 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V20i64 = trunc <20 x i64> undef to <20 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V24i64 = trunc <24 x i64> undef to <24 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V28i64 = trunc <28 x i64> undef to <28 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V32i64 = trunc <32 x i64> undef to <32 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V40i64 = trunc <40 x i64> undef to <40 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V48i64 = trunc <48 x i64> undef to <48 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V56i64 = trunc <56 x i64> undef to <56 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V64i64 = trunc <64 x i64> undef to <64 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 32 for instruction: %V80i64 = trunc <80 x i64> undef to <80 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 32 for instruction: %V96i64 = trunc <96 x i64> undef to <96 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 32 for instruction: %V112i64 = trunc <112 x i64> undef to <112 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 32 for instruction: %V128i64 = trunc <128 x i64> undef to <128 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 64 for instruction: %V160i64 = trunc <160 x i64> undef to <160 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 64 for instruction: %V192i64 = trunc <192 x i64> undef to <192 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 64 for instruction: %V224i64 = trunc <224 x i64> undef to <224 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 64 for instruction: %V256i64 = trunc <256 x i64> undef to <256 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 128 for instruction: %V320i64 = trunc <320 x i64> undef to <320 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 128 for instruction: %V384i64 = trunc <384 x i64> undef to <384 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 128 for instruction: %V448i64 = trunc <448 x i64> undef to <448 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 128 for instruction: %V512i64 = trunc <512 x i64> undef to <512 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 256 for instruction: %V640i64 = trunc <640 x i64> undef to <640 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 256 for instruction: %V768i64 = trunc <768 x i64> undef to <768 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 256 for instruction: %V896i64 = trunc <896 x i64> undef to <896 x i8> +; AVX512F-NEXT: Cost Model: Found an estimated cost of 256 for instruction: %V1024i64 = trunc <1024 x i64> undef to <1024 x i8> ; AVX512F-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %i32 = trunc i32 undef to i8 ; AVX512F-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V2i32 = trunc <2 x i32> undef to <2 x i8> ; AVX512F-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V4i32 = trunc <4 x i32> undef to <4 x i8> @@ -1216,36 +1216,36 @@ define i32 @trunc_vXi8() { ; AVX512BW-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %i64 = trunc i64 undef to i8 ; AVX512BW-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V2i64 = trunc <2 x i64> undef to <2 x i8> ; AVX512BW-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V4i64 = trunc <4 x i64> undef to <4 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 12 for instruction: %V6i64 = trunc <6 x i64> undef to <6 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V6i64 = trunc <6 x i64> undef to <6 x i8> ; AVX512BW-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V8i64 = trunc <8 x i64> undef to <8 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 20 for instruction: %V10i64 = trunc <10 x i64> undef to <10 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 24 for instruction: %V12i64 = trunc <12 x i64> undef to <12 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 28 for instruction: %V14i64 = trunc <14 x i64> undef to <14 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V10i64 = trunc <10 x i64> undef to <10 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V12i64 = trunc <12 x i64> undef to <12 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V14i64 = trunc <14 x i64> undef to <14 x i8> ; AVX512BW-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %V16i64 = trunc <16 x i64> undef to <16 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 47 for instruction: %V20i64 = trunc <20 x i64> undef to <20 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 59 for instruction: %V24i64 = trunc <24 x i64> undef to <24 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 71 for instruction: %V28i64 = trunc <28 x i64> undef to <28 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 11 for instruction: %V32i64 = trunc <32 x i64> undef to <32 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 108 for instruction: %V40i64 = trunc <40 x i64> undef to <40 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 131 for instruction: %V48i64 = trunc <48 x i64> undef to <48 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 157 for instruction: %V56i64 = trunc <56 x i64> undef to <56 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 23 for instruction: %V64i64 = trunc <64 x i64> undef to <64 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 213 for instruction: %V80i64 = trunc <80 x i64> undef to <80 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 262 for instruction: %V96i64 = trunc <96 x i64> undef to <96 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 311 for instruction: %V112i64 = trunc <112 x i64> undef to <112 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 46 for instruction: %V128i64 = trunc <128 x i64> undef to <128 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 442 for instruction: %V160i64 = trunc <160 x i64> undef to <160 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 540 for instruction: %V192i64 = trunc <192 x i64> undef to <192 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 622 for instruction: %V224i64 = trunc <224 x i64> undef to <224 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 92 for instruction: %V256i64 = trunc <256 x i64> undef to <256 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 900 for instruction: %V320i64 = trunc <320 x i64> undef to <320 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 1080 for instruction: %V384i64 = trunc <384 x i64> undef to <384 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 1260 for instruction: %V448i64 = trunc <448 x i64> undef to <448 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 184 for instruction: %V512i64 = trunc <512 x i64> undef to <512 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 1800 for instruction: %V640i64 = trunc <640 x i64> undef to <640 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 2160 for instruction: %V768i64 = trunc <768 x i64> undef to <768 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 2520 for instruction: %V896i64 = trunc <896 x i64> undef to <896 x i8> -; AVX512BW-NEXT: Cost Model: Found an estimated cost of 368 for instruction: %V1024i64 = trunc <1024 x i64> undef to <1024 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V20i64 = trunc <20 x i64> undef to <20 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V24i64 = trunc <24 x i64> undef to <24 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V28i64 = trunc <28 x i64> undef to <28 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V32i64 = trunc <32 x i64> undef to <32 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V40i64 = trunc <40 x i64> undef to <40 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V48i64 = trunc <48 x i64> undef to <48 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V56i64 = trunc <56 x i64> undef to <56 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V64i64 = trunc <64 x i64> undef to <64 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 32 for instruction: %V80i64 = trunc <80 x i64> undef to <80 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 32 for instruction: %V96i64 = trunc <96 x i64> undef to <96 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 32 for instruction: %V112i64 = trunc <112 x i64> undef to <112 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 32 for instruction: %V128i64 = trunc <128 x i64> undef to <128 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 64 for instruction: %V160i64 = trunc <160 x i64> undef to <160 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 64 for instruction: %V192i64 = trunc <192 x i64> undef to <192 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 64 for instruction: %V224i64 = trunc <224 x i64> undef to <224 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 64 for instruction: %V256i64 = trunc <256 x i64> undef to <256 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 128 for instruction: %V320i64 = trunc <320 x i64> undef to <320 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 128 for instruction: %V384i64 = trunc <384 x i64> undef to <384 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 128 for instruction: %V448i64 = trunc <448 x i64> undef to <448 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 128 for instruction: %V512i64 = trunc <512 x i64> undef to <512 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 256 for instruction: %V640i64 = trunc <640 x i64> undef to <640 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 256 for instruction: %V768i64 = trunc <768 x i64> undef to <768 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 256 for instruction: %V896i64 = trunc <896 x i64> undef to <896 x i8> +; AVX512BW-NEXT: Cost Model: Found an estimated cost of 256 for instruction: %V1024i64 = trunc <1024 x i64> undef to <1024 x i8> ; AVX512BW-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %i32 = trunc i32 undef to i8 ; AVX512BW-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V2i32 = trunc <2 x i32> undef to <2 x i8> ; AVX512BW-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V4i32 = trunc <4 x i32> undef to <4 x i8>