Skip to content

Commit

Permalink
[X86][Costmodel] trunc v16i32 to v32i8/v64i8 can appear after legal…
Browse files Browse the repository at this point in the history
…ization, 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
  • Loading branch information
LebedevRI committed Nov 15, 2021
1 parent 49c08a2 commit 0116c70
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 48 deletions.
2 changes: 2 additions & 0 deletions llvm/lib/Target/X86/X86TargetTransformInfo.cpp
Expand Up @@ -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
Expand Down
96 changes: 48 additions & 48 deletions llvm/test/Analysis/CostModel/X86/trunc.ll
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 0116c70

Please sign in to comment.