Skip to content

Commit 4beea6b

Browse files
authored
[PowerPC] lower partial vector store cost (llvm#78358)
There are matching store opcodes (stfd, stxsiwx) for the load opcodes that make 32-bit and 64-bit vector operations cheap with VSX, so stores should also be cheap.
1 parent 4fcd7cf commit 4beea6b

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,9 +788,10 @@ InstructionCost PPCTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
788788
// VSX has 32b/64b load instructions. Legalization can handle loading of
789789
// 32b/64b to VSR correctly and cheaply. But BaseT::getMemoryOpCost and
790790
// PPCTargetLowering can't compute the cost appropriately. So here we
791-
// explicitly check this case.
791+
// explicitly check this case. There are also corresponding store
792+
// instructions.
792793
unsigned MemBytes = Src->getPrimitiveSizeInBits();
793-
if (Opcode == Instruction::Load && ST->hasVSX() && IsAltivecType &&
794+
if (ST->hasVSX() && IsAltivecType &&
794795
(MemBytes == 64 || (ST->hasP8Vector() && MemBytes == 32)))
795796
return 1;
796797

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,22 @@ define i32 @loads(i32 %arg) {
4343
ret i32 undef
4444
}
4545

46+
define i32 @partialvector32(i32 %arg) #0 {
47+
48+
; CHECK: cost of 1 {{.*}} store
49+
store <4 x i8> undef, ptr undef, align 16
50+
51+
ret i32 undef
52+
}
53+
54+
define i32 @partialvector64(i32 %arg) #1 {
55+
56+
; CHECK: cost of 1 {{.*}} store
57+
store <4 x i16> undef, ptr undef, align 16
58+
59+
ret i32 undef
60+
}
61+
62+
attributes #0 = { "target-features"="+power8-vector,+vsx" }
63+
64+
attributes #1 = { "target-features"="+vsx" }

0 commit comments

Comments
 (0)