Skip to content

Commit 8d1046a

Browse files
author
Chen Zheng
authored
[PowerPC] adjust cost for extract i64 from vector on P9 and above (#82963)
https://godbolt.org/z/Ma347Tx1W
1 parent 5f058aa commit 8d1046a

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -716,12 +716,10 @@ InstructionCost PPCTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
716716
} else if (ISD == ISD::EXTRACT_VECTOR_ELT) {
717717
// It's an extract. Maybe we can do a cheap move-from VSR.
718718
unsigned EltSize = Val->getScalarSizeInBits();
719-
if (EltSize == 64) {
720-
// FIXME: no need to worry about endian, P9 has both mfvsrd/mfvsrld.
721-
unsigned MfvsrdIndex = ST->isLittleEndian() ? 1 : 0;
722-
if (Index == MfvsrdIndex)
723-
return 1;
724-
} else if (EltSize == 32) {
719+
// P9 has both mfvsrd and mfvsrld for 64 bit integer.
720+
if (EltSize == 64 && Index != -1U)
721+
return 1;
722+
else if (EltSize == 32) {
725723
unsigned MfvsrwzIndex = ST->isLittleEndian() ? 2 : 1;
726724
if (Index == MfvsrwzIndex)
727725
return 1;

llvm/test/Analysis/CostModel/PowerPC/insert_extract-inseltpoison.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ define void @vexti64(<2 x i64> %p1) {
147147
;
148148
; CHECK-P9BE-LABEL: 'vexti64'
149149
; CHECK-P9BE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %i1 = extractelement <2 x i64> %p1, i32 0
150-
; CHECK-P9BE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %i2 = extractelement <2 x i64> %p1, i32 1
150+
; CHECK-P9BE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %i2 = extractelement <2 x i64> %p1, i32 1
151151
; CHECK-P9BE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
152152
;
153153
; CHECK-P9LE-LABEL: 'vexti64'
154-
; CHECK-P9LE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %i1 = extractelement <2 x i64> %p1, i32 0
154+
; CHECK-P9LE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %i1 = extractelement <2 x i64> %p1, i32 0
155155
; CHECK-P9LE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %i2 = extractelement <2 x i64> %p1, i32 1
156156
; CHECK-P9LE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
157157
;

llvm/test/Analysis/CostModel/PowerPC/insert_extract.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ define void @vexti64(<2 x i64> %p1) {
172172
;
173173
; CHECK-P9BE-LABEL: 'vexti64'
174174
; CHECK-P9BE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %i1 = extractelement <2 x i64> %p1, i32 0
175-
; CHECK-P9BE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %i2 = extractelement <2 x i64> %p1, i32 1
175+
; CHECK-P9BE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %i2 = extractelement <2 x i64> %p1, i32 1
176176
; CHECK-P9BE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
177177
;
178178
; CHECK-P9LE-LABEL: 'vexti64'
179-
; CHECK-P9LE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %i1 = extractelement <2 x i64> %p1, i32 0
179+
; CHECK-P9LE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %i1 = extractelement <2 x i64> %p1, i32 0
180180
; CHECK-P9LE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %i2 = extractelement <2 x i64> %p1, i32 1
181181
; CHECK-P9LE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
182182
;

0 commit comments

Comments
 (0)