[llvm] 0116c70 - [X86][Costmodel] `trunc v16i32 to v32i8/v64i8` can appear after legalization, cost is same as for `trunc v16i32 to v16i8`

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 15 08:04:27 PST 2021


Author: Roman Lebedev
Date: 2021-11-15T19:04:02+03:00
New Revision: 0116c708c6bf2d83ac2218ccdef5fd69b7283817

URL: https://github.com/llvm/llvm-project/commit/0116c708c6bf2d83ac2218ccdef5fd69b7283817
DIFF: https://github.com/llvm/llvm-project/commit/0116c708c6bf2d83ac2218ccdef5fd69b7283817.diff

LOG: [X86][Costmodel] `trunc v16i32 to v32i8/v64i8` can appear after legalization, cost is same as for `trunc v16i32 to v16i8`

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/D113850

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86TargetTransformInfo.cpp
    llvm/test/Analysis/CostModel/X86/trunc.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index 27f06365e032..7bfa7ebb3bac 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -1667,6 +1667,8 @@ InstructionCost X86TTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
     { ISD::TRUNCATE,  MVT::v2i8,    MVT::v2i32,  2 }, // vpmovdb
     { ISD::TRUNCATE,  MVT::v4i8,    MVT::v4i32,  2 }, // vpmovdb
     { ISD::TRUNCATE,  MVT::v16i8,   MVT::v16i32, 2 }, // vpmovdb
+    { ISD::TRUNCATE,  MVT::v32i8,   MVT::v16i32, 2 }, // vpmovdb
+    { ISD::TRUNCATE,  MVT::v64i8,   MVT::v16i32, 2 }, // vpmovdb
     { ISD::TRUNCATE,  MVT::v16i16,  MVT::v16i32, 2 }, // vpmovdw
     { ISD::TRUNCATE,  MVT::v32i16,  MVT::v16i32, 2 }, // vpmovdw
     { ISD::TRUNCATE,  MVT::v2i8,    MVT::v2i64,  2 }, // vpmovqb

diff  --git a/llvm/test/Analysis/CostModel/X86/trunc.ll b/llvm/test/Analysis/CostModel/X86/trunc.ll
index b01bc6df6dbd..0e4a3563c8f7 100644
--- a/llvm/test/Analysis/CostModel/X86/trunc.ll
+++ b/llvm/test/Analysis/CostModel/X86/trunc.ll
@@ -1153,30 +1153,30 @@ define i32 @trunc_vXi8() {
 ; AVX512F-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %V12i32 = trunc <12 x i32> undef to <12 x i8>
 ; AVX512F-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %V14i32 = trunc <14 x i32> undef to <14 x i8>
 ; AVX512F-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %V16i32 = trunc <16 x i32> undef to <16 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 47 for instruction: %V20i32 = trunc <20 x i32> undef to <20 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 59 for instruction: %V24i32 = trunc <24 x i32> undef to <24 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 71 for instruction: %V28i32 = trunc <28 x i32> undef to <28 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 5 for instruction: %V32i32 = trunc <32 x i32> undef to <32 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 108 for instruction: %V40i32 = trunc <40 x i32> undef to <40 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 131 for instruction: %V48i32 = trunc <48 x i32> undef to <48 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 157 for instruction: %V56i32 = trunc <56 x i32> undef to <56 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 11 for instruction: %V64i32 = trunc <64 x i32> undef to <64 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 213 for instruction: %V80i32 = trunc <80 x i32> undef to <80 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 262 for instruction: %V96i32 = trunc <96 x i32> undef to <96 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 311 for instruction: %V112i32 = trunc <112 x i32> undef to <112 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 22 for instruction: %V128i32 = trunc <128 x i32> undef to <128 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 442 for instruction: %V160i32 = trunc <160 x i32> undef to <160 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 540 for instruction: %V192i32 = trunc <192 x i32> undef to <192 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 622 for instruction: %V224i32 = trunc <224 x i32> undef to <224 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 44 for instruction: %V256i32 = trunc <256 x i32> undef to <256 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 900 for instruction: %V320i32 = trunc <320 x i32> undef to <320 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 1080 for instruction: %V384i32 = trunc <384 x i32> undef to <384 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 1260 for instruction: %V448i32 = trunc <448 x i32> undef to <448 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 88 for instruction: %V512i32 = trunc <512 x i32> undef to <512 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 1800 for instruction: %V640i32 = trunc <640 x i32> undef to <640 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 2160 for instruction: %V768i32 = trunc <768 x i32> undef to <768 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 2520 for instruction: %V896i32 = trunc <896 x i32> undef to <896 x i8>
-; AVX512F-NEXT:  Cost Model: Found an estimated cost of 176 for instruction: %V1024i32 = trunc <1024 x i32> undef to <1024 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %V20i32 = trunc <20 x i32> undef to <20 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %V24i32 = trunc <24 x i32> undef to <24 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %V28i32 = trunc <28 x i32> undef to <28 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %V32i32 = trunc <32 x i32> undef to <32 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %V40i32 = trunc <40 x i32> undef to <40 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %V48i32 = trunc <48 x i32> undef to <48 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %V56i32 = trunc <56 x i32> undef to <56 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %V64i32 = trunc <64 x i32> undef to <64 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %V80i32 = trunc <80 x i32> undef to <80 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %V96i32 = trunc <96 x i32> undef to <96 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %V112i32 = trunc <112 x i32> undef to <112 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %V128i32 = trunc <128 x i32> undef to <128 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 32 for instruction: %V160i32 = trunc <160 x i32> undef to <160 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 32 for instruction: %V192i32 = trunc <192 x i32> undef to <192 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 32 for instruction: %V224i32 = trunc <224 x i32> undef to <224 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 32 for instruction: %V256i32 = trunc <256 x i32> undef to <256 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 64 for instruction: %V320i32 = trunc <320 x i32> undef to <320 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 64 for instruction: %V384i32 = trunc <384 x i32> undef to <384 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 64 for instruction: %V448i32 = trunc <448 x i32> undef to <448 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 64 for instruction: %V512i32 = trunc <512 x i32> undef to <512 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 128 for instruction: %V640i32 = trunc <640 x i32> undef to <640 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 128 for instruction: %V768i32 = trunc <768 x i32> undef to <768 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 128 for instruction: %V896i32 = trunc <896 x i32> undef to <896 x i8>
+; AVX512F-NEXT:  Cost Model: Found an estimated cost of 128 for instruction: %V1024i32 = trunc <1024 x i32> undef to <1024 x i8>
 ; AVX512F-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %i16 = trunc i16 undef to i8
 ; AVX512F-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %V2i16 = trunc <2 x i16> undef to <2 x i8>
 ; AVX512F-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %V4i16 = trunc <4 x i16> undef to <4 x i8>
@@ -1255,30 +1255,30 @@ define i32 @trunc_vXi8() {
 ; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %V12i32 = trunc <12 x i32> undef to <12 x i8>
 ; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %V14i32 = trunc <14 x i32> undef to <14 x i8>
 ; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %V16i32 = trunc <16 x i32> undef to <16 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 47 for instruction: %V20i32 = trunc <20 x i32> undef to <20 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 59 for instruction: %V24i32 = trunc <24 x i32> undef to <24 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 71 for instruction: %V28i32 = trunc <28 x i32> undef to <28 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 5 for instruction: %V32i32 = trunc <32 x i32> undef to <32 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 108 for instruction: %V40i32 = trunc <40 x i32> undef to <40 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 131 for instruction: %V48i32 = trunc <48 x i32> undef to <48 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 157 for instruction: %V56i32 = trunc <56 x i32> undef to <56 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 11 for instruction: %V64i32 = trunc <64 x i32> undef to <64 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 213 for instruction: %V80i32 = trunc <80 x i32> undef to <80 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 262 for instruction: %V96i32 = trunc <96 x i32> undef to <96 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 311 for instruction: %V112i32 = trunc <112 x i32> undef to <112 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 22 for instruction: %V128i32 = trunc <128 x i32> undef to <128 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 442 for instruction: %V160i32 = trunc <160 x i32> undef to <160 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 540 for instruction: %V192i32 = trunc <192 x i32> undef to <192 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 622 for instruction: %V224i32 = trunc <224 x i32> undef to <224 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 44 for instruction: %V256i32 = trunc <256 x i32> undef to <256 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 900 for instruction: %V320i32 = trunc <320 x i32> undef to <320 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 1080 for instruction: %V384i32 = trunc <384 x i32> undef to <384 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 1260 for instruction: %V448i32 = trunc <448 x i32> undef to <448 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 88 for instruction: %V512i32 = trunc <512 x i32> undef to <512 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 1800 for instruction: %V640i32 = trunc <640 x i32> undef to <640 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 2160 for instruction: %V768i32 = trunc <768 x i32> undef to <768 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 2520 for instruction: %V896i32 = trunc <896 x i32> undef to <896 x i8>
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 176 for instruction: %V1024i32 = trunc <1024 x i32> undef to <1024 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %V20i32 = trunc <20 x i32> undef to <20 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %V24i32 = trunc <24 x i32> undef to <24 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %V28i32 = trunc <28 x i32> undef to <28 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %V32i32 = trunc <32 x i32> undef to <32 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %V40i32 = trunc <40 x i32> undef to <40 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %V48i32 = trunc <48 x i32> undef to <48 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %V56i32 = trunc <56 x i32> undef to <56 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %V64i32 = trunc <64 x i32> undef to <64 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %V80i32 = trunc <80 x i32> undef to <80 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %V96i32 = trunc <96 x i32> undef to <96 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %V112i32 = trunc <112 x i32> undef to <112 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %V128i32 = trunc <128 x i32> undef to <128 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 32 for instruction: %V160i32 = trunc <160 x i32> undef to <160 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 32 for instruction: %V192i32 = trunc <192 x i32> undef to <192 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 32 for instruction: %V224i32 = trunc <224 x i32> undef to <224 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 32 for instruction: %V256i32 = trunc <256 x i32> undef to <256 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 64 for instruction: %V320i32 = trunc <320 x i32> undef to <320 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 64 for instruction: %V384i32 = trunc <384 x i32> undef to <384 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 64 for instruction: %V448i32 = trunc <448 x i32> undef to <448 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 64 for instruction: %V512i32 = trunc <512 x i32> undef to <512 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 128 for instruction: %V640i32 = trunc <640 x i32> undef to <640 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 128 for instruction: %V768i32 = trunc <768 x i32> undef to <768 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 128 for instruction: %V896i32 = trunc <896 x i32> undef to <896 x i8>
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 128 for instruction: %V1024i32 = trunc <1024 x i32> undef to <1024 x i8>
 ; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %i16 = trunc i16 undef to i8
 ; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %V2i16 = trunc <2 x i16> undef to <2 x i8>
 ; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %V4i16 = trunc <4 x i16> undef to <4 x i8>


        


More information about the llvm-commits mailing list