Skip to content

Commit c850d5c

Browse files
committed
[X86][Costmodel] Add SSE2 sub-128bit vXi8/16 stride 2 interleaved store costs
Differential Revision: https://reviews.llvm.org/D111941
1 parent b37efed commit c850d5c

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

llvm/lib/Target/X86/X86TargetTransformInfo.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5318,14 +5318,9 @@ InstructionCost X86TTIImpl::getInterleavedMemoryOpCost(
53185318
};
53195319

53205320
static const CostTblEntry AVX2InterleavedStoreTbl[] = {
5321-
{2, MVT::v2i8, 1}, // interleave 2 x 2i8 into 4i8 (and store)
5322-
{2, MVT::v4i8, 1}, // interleave 2 x 4i8 into 8i8 (and store)
5323-
{2, MVT::v8i8, 1}, // interleave 2 x 8i8 into 16i8 (and store)
53245321
{2, MVT::v16i8, 3}, // interleave 2 x 16i8 into 32i8 (and store)
53255322
{2, MVT::v32i8, 4}, // interleave 2 x 32i8 into 64i8 (and store)
53265323

5327-
{2, MVT::v2i16, 1}, // interleave 2 x 2i16 into 4i16 (and store)
5328-
{2, MVT::v4i16, 1}, // interleave 2 x 4i16 into 8i16 (and store)
53295324
{2, MVT::v8i16, 3}, // interleave 2 x 8i16 into 16i16 (and store)
53305325
{2, MVT::v16i16, 4}, // interleave 2 x 16i16 into 32i16 (and store)
53315326
{2, MVT::v32i16, 8}, // interleave 2 x 32i16 into 64i16 (and store)
@@ -5410,6 +5405,15 @@ InstructionCost X86TTIImpl::getInterleavedMemoryOpCost(
54105405
{6, MVT::v8i64, 30}, // interleave 6 x 8i64 into 48i64 (and store)
54115406
};
54125407

5408+
static const CostTblEntry SSE2InterleavedStoreTbl[] = {
5409+
{2, MVT::v2i8, 1}, // interleave 2 x 2i8 into 4i8 (and store)
5410+
{2, MVT::v4i8, 1}, // interleave 2 x 4i8 into 8i8 (and store)
5411+
{2, MVT::v8i8, 1}, // interleave 2 x 8i8 into 16i8 (and store)
5412+
5413+
{2, MVT::v2i16, 1}, // interleave 2 x 2i16 into 4i16 (and store)
5414+
{2, MVT::v4i16, 1}, // interleave 2 x 4i16 into 8i16 (and store)
5415+
};
5416+
54135417
if (Opcode == Instruction::Load) {
54145418
// FIXME: if we have a partially-interleaved groups, with gaps,
54155419
// should we discount the not-demanded indicies?
@@ -5436,6 +5440,11 @@ InstructionCost X86TTIImpl::getInterleavedMemoryOpCost(
54365440
if (const auto *Entry = CostTableLookup(AVX2InterleavedStoreTbl, Factor,
54375441
ETy.getSimpleVT()))
54385442
return MemOpCosts + Entry->Cost;
5443+
5444+
if (ST->hasSSE2())
5445+
if (const auto *Entry = CostTableLookup(SSE2InterleavedStoreTbl, Factor,
5446+
ETy.getSimpleVT()))
5447+
return MemOpCosts + Entry->Cost;
54395448
}
54405449

54415450
return BaseT::getInterleavedMemoryOpCost(Opcode, VecTy, Factor, Indices,

llvm/test/Analysis/CostModel/X86/interleaved-store-i16-stride-2.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ target triple = "x86_64-unknown-linux-gnu"
1313
; CHECK: LV: Checking a loop in "test"
1414
;
1515
; SSE2: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %v1, i16* %out1, align 2
16-
; SSE2: LV: Found an estimated cost of 9 for VF 2 For instruction: store i16 %v1, i16* %out1, align 2
17-
; SSE2: LV: Found an estimated cost of 17 for VF 4 For instruction: store i16 %v1, i16* %out1, align 2
16+
; SSE2: LV: Found an estimated cost of 2 for VF 2 For instruction: store i16 %v1, i16* %out1, align 2
17+
; SSE2: LV: Found an estimated cost of 2 for VF 4 For instruction: store i16 %v1, i16* %out1, align 2
1818
; SSE2: LV: Found an estimated cost of 34 for VF 8 For instruction: store i16 %v1, i16* %out1, align 2
1919
; SSE2: LV: Found an estimated cost of 68 for VF 16 For instruction: store i16 %v1, i16* %out1, align 2
2020
;
2121
; AVX1: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %v1, i16* %out1, align 2
22-
; AVX1: LV: Found an estimated cost of 9 for VF 2 For instruction: store i16 %v1, i16* %out1, align 2
23-
; AVX1: LV: Found an estimated cost of 17 for VF 4 For instruction: store i16 %v1, i16* %out1, align 2
22+
; AVX1: LV: Found an estimated cost of 2 for VF 2 For instruction: store i16 %v1, i16* %out1, align 2
23+
; AVX1: LV: Found an estimated cost of 2 for VF 4 For instruction: store i16 %v1, i16* %out1, align 2
2424
; AVX1: LV: Found an estimated cost of 35 for VF 8 For instruction: store i16 %v1, i16* %out1, align 2
2525
; AVX1: LV: Found an estimated cost of 86 for VF 16 For instruction: store i16 %v1, i16* %out1, align 2
2626
; AVX1: LV: Found an estimated cost of 172 for VF 32 For instruction: store i16 %v1, i16* %out1, align 2

llvm/test/Analysis/CostModel/X86/interleaved-store-i8-stride-2.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ target triple = "x86_64-unknown-linux-gnu"
1313
; CHECK: LV: Checking a loop in "test"
1414
;
1515
; SSE2: LV: Found an estimated cost of 1 for VF 1 For instruction: store i8 %v1, i8* %out1, align 1
16-
; SSE2: LV: Found an estimated cost of 14 for VF 2 For instruction: store i8 %v1, i8* %out1, align 1
17-
; SSE2: LV: Found an estimated cost of 30 for VF 4 For instruction: store i8 %v1, i8* %out1, align 1
18-
; SSE2: LV: Found an estimated cost of 62 for VF 8 For instruction: store i8 %v1, i8* %out1, align 1
16+
; SSE2: LV: Found an estimated cost of 2 for VF 2 For instruction: store i8 %v1, i8* %out1, align 1
17+
; SSE2: LV: Found an estimated cost of 2 for VF 4 For instruction: store i8 %v1, i8* %out1, align 1
18+
; SSE2: LV: Found an estimated cost of 2 for VF 8 For instruction: store i8 %v1, i8* %out1, align 1
1919
; SSE2: LV: Found an estimated cost of 126 for VF 16 For instruction: store i8 %v1, i8* %out1, align 1
2020
;
2121
; AVX1: LV: Found an estimated cost of 1 for VF 1 For instruction: store i8 %v1, i8* %out1, align 1
22-
; AVX1: LV: Found an estimated cost of 9 for VF 2 For instruction: store i8 %v1, i8* %out1, align 1
23-
; AVX1: LV: Found an estimated cost of 17 for VF 4 For instruction: store i8 %v1, i8* %out1, align 1
24-
; AVX1: LV: Found an estimated cost of 33 for VF 8 For instruction: store i8 %v1, i8* %out1, align 1
22+
; AVX1: LV: Found an estimated cost of 2 for VF 2 For instruction: store i8 %v1, i8* %out1, align 1
23+
; AVX1: LV: Found an estimated cost of 2 for VF 4 For instruction: store i8 %v1, i8* %out1, align 1
24+
; AVX1: LV: Found an estimated cost of 2 for VF 8 For instruction: store i8 %v1, i8* %out1, align 1
2525
; AVX1: LV: Found an estimated cost of 67 for VF 16 For instruction: store i8 %v1, i8* %out1, align 1
2626
; AVX1: LV: Found an estimated cost of 166 for VF 32 For instruction: store i8 %v1, i8* %out1, align 1
2727

0 commit comments

Comments
 (0)