[PATCH] D153570: [CostModel][SLP] Use getGEPCost AccessTy in more places
Luke Lau via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 29 09:15:32 PDT 2023
luke updated this revision to Diff 535843.
luke added a comment.
Split out non-SLP changes
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153570/new/
https://reviews.llvm.org/D153570
Files:
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/RISCV/gep.ll
Index: llvm/test/Transforms/SLPVectorizer/RISCV/gep.ll
===================================================================
--- llvm/test/Transforms/SLPVectorizer/RISCV/gep.ll
+++ llvm/test/Transforms/SLPVectorizer/RISCV/gep.ll
@@ -2,8 +2,8 @@
; RUN: opt < %s -passes=slp-vectorizer -mtriple=riscv64 -mattr=+v \
; RUN: -riscv-v-slp-max-vf=0 -S | FileCheck %s
-; FIXME: This should not be vectorized, as the cost of computing the
-; offsets nullifies the benefits of vectorizing:
+; This should not be vectorized, as the cost of computing the offsets nullifies
+; the benefits of vectorizing:
;
; copy_with_offset_v2i8:
; addi a0, a0, 8
@@ -27,9 +27,13 @@
; CHECK-LABEL: @copy_with_offset_v2i8(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 8
+; CHECK-NEXT: [[X1:%.*]] = load i8, ptr [[P1]], align 1
; CHECK-NEXT: [[Q1:%.*]] = getelementptr i8, ptr [[Q:%.*]], i32 16
-; CHECK-NEXT: [[TMP0:%.*]] = load <2 x i8>, ptr [[P1]], align 1
-; CHECK-NEXT: store <2 x i8> [[TMP0]], ptr [[Q1]], align 1
+; CHECK-NEXT: store i8 [[X1]], ptr [[Q1]], align 1
+; CHECK-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 9
+; CHECK-NEXT: [[X2:%.*]] = load i8, ptr [[P2]], align 1
+; CHECK-NEXT: [[Q2:%.*]] = getelementptr i8, ptr [[Q]], i32 17
+; CHECK-NEXT: store i8 [[X2]], ptr [[Q2]], align 1
; CHECK-NEXT: ret void
;
entry:
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -7446,15 +7446,10 @@
ScalarCost = TTI->getPointersChainCost(Ptrs, BasePtr, PtrsInfo, ScalarTy,
CostKind);
-
- // Remark: it not quite correct to use scalar GEP cost for a vector GEP,
- // but it's not clear how to do that without having vector GEP arguments
- // ready.
- // Perhaps using just TTI::TCC_Free/TTI::TCC_Basic would be better option.
- if (const auto *Base = dyn_cast<GetElementPtrInst>(BasePtr)) {
- SmallVector<const Value *> Indices(Base->indices());
- VecCost = TTI->getGEPCost(Base->getSourceElementType(),
- Base->getPointerOperand(), Indices, nullptr,
+ if (auto *BaseGEP = dyn_cast<GEPOperator>(BasePtr)) {
+ SmallVector<const Value *> Indices(BaseGEP->indices());
+ VecCost = TTI->getGEPCost(BaseGEP->getSourceElementType(),
+ BaseGEP->getPointerOperand(), Indices, VecTy,
CostKind);
}
}
Index: llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -1641,7 +1641,7 @@
} else {
SmallVector<const Value *> Indices(GEP->indices());
Cost += getGEPCost(GEP->getSourceElementType(), GEP->getPointerOperand(),
- Indices, nullptr, CostKind);
+ Indices, AccessTy, CostKind);
}
}
return Cost;
Index: llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
===================================================================
--- llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -1098,7 +1098,7 @@
SmallVector<const Value *> Indices(GEP->indices());
Cost += static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
GEP->getPointerOperand(),
- Indices, nullptr, CostKind);
+ Indices, AccessTy, CostKind);
}
}
return Cost;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153570.535843.patch
Type: text/x-patch
Size: 3906 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230629/f4704bbe/attachment.bin>
More information about the llvm-commits
mailing list