[llvm] 6b95fd1 - Revert "[X86] X86TTIImpl::getInterleavedMemoryOpCostAVX2(): use getMemoryOpCost()"
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Thu May 13 14:03:59 PDT 2021
Author: Roman Lebedev
Date: 2021-05-14T00:03:36+03:00
New Revision: 6b95fd199d96e3ba5c28a23b17b74203522bdaa8
URL: https://github.com/llvm/llvm-project/commit/6b95fd199d96e3ba5c28a23b17b74203522bdaa8
DIFF: https://github.com/llvm/llvm-project/commit/6b95fd199d96e3ba5c28a23b17b74203522bdaa8.diff
LOG: Revert "[X86] X86TTIImpl::getInterleavedMemoryOpCostAVX2(): use getMemoryOpCost()"
Depends on a commit that is about to be reverted.
This reverts commit 69ed93a4355123a45c1d7216aea7cd53d07a361b.
Added:
Modified:
llvm/lib/Target/X86/X86TargetTransformInfo.cpp
llvm/test/Analysis/CostModel/X86/interleaved-load-i8.ll
llvm/test/Analysis/CostModel/X86/interleaved-store-i8.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index 66a7b10617aa7..924d76af762c2 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -4691,9 +4691,17 @@ InstructionCost X86TTIImpl::getInterleavedMemoryOpCostAVX2(
ScalarTy =
Type::getIntNTy(ScalarTy->getContext(), DL.getTypeSizeInBits(ScalarTy));
- // Get the cost of all the memory operations.
- InstructionCost MemOpCosts = getMemoryOpCost(
- Opcode, VecTy, MaybeAlign(Alignment), AddressSpace, CostKind);
+ // Calculate the number of memory operations (NumOfMemOps), required
+ // for load/store the VecTy.
+ unsigned VecTySize = DL.getTypeStoreSize(VecTy);
+ unsigned LegalVTSize = LegalVT.getStoreSize();
+ unsigned NumOfMemOps = (VecTySize + LegalVTSize - 1) / LegalVTSize;
+
+ // Get the cost of one memory operation.
+ auto *SingleMemOpTy = FixedVectorType::get(VecTy->getElementType(),
+ LegalVT.getVectorNumElements());
+ InstructionCost MemOpCost = getMemoryOpCost(
+ Opcode, SingleMemOpTy, MaybeAlign(Alignment), AddressSpace, CostKind);
auto *VT = FixedVectorType::get(ScalarTy, VF);
EVT ETy = TLI->getValueType(DL, VT);
@@ -4748,13 +4756,13 @@ InstructionCost X86TTIImpl::getInterleavedMemoryOpCostAVX2(
if (Opcode == Instruction::Load) {
if (const auto *Entry =
CostTableLookup(AVX2InterleavedLoadTbl, Factor, ETy.getSimpleVT()))
- return MemOpCosts + Entry->Cost;
+ return NumOfMemOps * MemOpCost + Entry->Cost;
} else {
assert(Opcode == Instruction::Store &&
"Expected Store Instruction at this point");
if (const auto *Entry =
CostTableLookup(AVX2InterleavedStoreTbl, Factor, ETy.getSimpleVT()))
- return MemOpCosts + Entry->Cost;
+ return NumOfMemOps * MemOpCost + Entry->Cost;
}
return BaseT::getInterleavedMemoryOpCost(Opcode, VecTy, Factor, Indices,
diff --git a/llvm/test/Analysis/CostModel/X86/interleaved-load-i8.ll b/llvm/test/Analysis/CostModel/X86/interleaved-load-i8.ll
index d20745080981a..f43d73e646528 100644
--- a/llvm/test/Analysis/CostModel/X86/interleaved-load-i8.ll
+++ b/llvm/test/Analysis/CostModel/X86/interleaved-load-i8.ll
@@ -7,9 +7,9 @@ target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: norecurse nounwind readonly uwtable
define i32 @doit_stride3(i8* nocapture readonly %Ptr, i32 %Nels) {
;CHECK: LV: Found an estimated cost of 1 for VF 1 For instruction: %0 = load i8
-;CHECK: LV: Found an estimated cost of 13 for VF 2 For instruction: %0 = load i8
-;CHECK: LV: Found an estimated cost of 7 for VF 4 For instruction: %0 = load i8
-;CHECK: LV: Found an estimated cost of 12 for VF 8 For instruction: %0 = load i8
+;CHECK: LV: Found an estimated cost of 11 for VF 2 For instruction: %0 = load i8
+;CHECK: LV: Found an estimated cost of 5 for VF 4 For instruction: %0 = load i8
+;CHECK: LV: Found an estimated cost of 10 for VF 8 For instruction: %0 = load i8
;CHECK: LV: Found an estimated cost of 13 for VF 16 For instruction: %0 = load i8
;CHECK: LV: Found an estimated cost of 16 for VF 32 For instruction: %0 = load i8
entry:
diff --git a/llvm/test/Analysis/CostModel/X86/interleaved-store-i8.ll b/llvm/test/Analysis/CostModel/X86/interleaved-store-i8.ll
index 349f5ad21a6f4..0923f131c004f 100644
--- a/llvm/test/Analysis/CostModel/X86/interleaved-store-i8.ll
+++ b/llvm/test/Analysis/CostModel/X86/interleaved-store-i8.ll
@@ -7,9 +7,9 @@ target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: norecurse nounwind uwtable
define void @doit_stride3(i8* nocapture %Ptr, i32 %Nels) local_unnamed_addr {
;CHECK: LV: Found an estimated cost of 1 for VF 1 For instruction: store i8 %conv4
-;CHECK: LV: Found an estimated cost of 10 for VF 2 For instruction: store i8 %conv4
-;CHECK: LV: Found an estimated cost of 11 for VF 4 For instruction: store i8 %conv4
-;CHECK: LV: Found an estimated cost of 14 for VF 8 For instruction: store i8 %conv4
+;CHECK: LV: Found an estimated cost of 8 for VF 2 For instruction: store i8 %conv4
+;CHECK: LV: Found an estimated cost of 9 for VF 4 For instruction: store i8 %conv4
+;CHECK: LV: Found an estimated cost of 12 for VF 8 For instruction: store i8 %conv4
;CHECK: LV: Found an estimated cost of 13 for VF 16 For instruction: store i8 %conv4
;CHECK: LV: Found an estimated cost of 16 for VF 32 For instruction: store i8 %conv4
entry:
More information about the llvm-commits
mailing list