[llvm] [PowerPC] lower partial vector store cost (PR #78358)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 16 14:13:13 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: None (RolandF77)
<details>
<summary>Changes</summary>
There are matching store opcodes for the load opcodes that make
32-bit and 64-bit vector operations cheap with VSX, so stores
should also be cheap.
---
Full diff: https://github.com/llvm/llvm-project/pull/78358.diff
2 Files Affected:
- (modified) llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp (+3-2)
- (modified) llvm/test/Analysis/CostModel/PowerPC/load_store.ll (+19)
``````````diff
diff --git a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
index 062b53e24a0d79..eb578c59f57080 100644
--- a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
@@ -788,9 +788,10 @@ InstructionCost PPCTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
// VSX has 32b/64b load instructions. Legalization can handle loading of
// 32b/64b to VSR correctly and cheaply. But BaseT::getMemoryOpCost and
// PPCTargetLowering can't compute the cost appropriately. So here we
- // explicitly check this case.
+ // explicitly check this case. There are also corresponding store
+ // instructions.
unsigned MemBytes = Src->getPrimitiveSizeInBits();
- if (Opcode == Instruction::Load && ST->hasVSX() && IsAltivecType &&
+ if (ST->hasVSX() && IsAltivecType &&
(MemBytes == 64 || (ST->hasP8Vector() && MemBytes == 32)))
return 1;
diff --git a/llvm/test/Analysis/CostModel/PowerPC/load_store.ll b/llvm/test/Analysis/CostModel/PowerPC/load_store.ll
index 574a3d40d27344..167cdf9c333036 100644
--- a/llvm/test/Analysis/CostModel/PowerPC/load_store.ll
+++ b/llvm/test/Analysis/CostModel/PowerPC/load_store.ll
@@ -43,3 +43,22 @@ define i32 @loads(i32 %arg) {
ret i32 undef
}
+define i32 @partialvector32(i32 %arg) #0 {
+
+ ; CHECK: cost of 1 {{.*}} store
+ store <4 x i8> undef, ptr undef, align 16
+
+ ret i32 undef
+}
+
+define i32 @partialvector64(i32 %arg) #1 {
+
+ ; CHECK: cost of 1 {{.*}} store
+ store <4 x i16> undef, ptr undef, align 16
+
+ ret i32 undef
+}
+
+attributes #0 = { "target-features"="+power8-vector,+vsx" }
+
+attributes #1 = { "target-features"="+vsx" }
``````````
</details>
https://github.com/llvm/llvm-project/pull/78358
More information about the llvm-commits
mailing list