[llvm] 7da2b91 - [Hexagon] Unify getSizeOfs in HexagonVectorCombine, NFC
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 27 10:52:20 PDT 2022
Author: Krzysztof Parzyszek
Date: 2022-09-27T10:51:52-07:00
New Revision: 7da2b918878d1694fe52ab1da8ec988a36417da5
URL: https://github.com/llvm/llvm-project/commit/7da2b918878d1694fe52ab1da8ec988a36417da5
DIFF: https://github.com/llvm/llvm-project/commit/7da2b918878d1694fe52ab1da8ec988a36417da5.diff
LOG: [Hexagon] Unify getSizeOfs in HexagonVectorCombine, NFC
Added:
Modified:
llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
index 5bc9dd6d6156..9e28ec382e38 100644
--- a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
@@ -80,9 +80,12 @@ class HexagonVectorCombine {
// Is V an undef value?
bool isUndef(const Value *Val) const;
- int getSizeOf(const Value *Val) const;
- int getSizeOf(const Type *Ty) const;
- int getAllocSizeOf(const Type *Ty) const;
+ enum SizeKind {
+ Store, // Store size
+ Alloc, // Alloc size
+ };
+ int getSizeOf(const Value *Val, SizeKind Kind = Store) const;
+ int getSizeOf(const Type *Ty, SizeKind Kind = Store) const;
int getTypeAlignment(Type *Ty) const;
Constant *getNullValue(Type *Ty) const;
@@ -446,7 +449,7 @@ auto AlignVectors::createAdjustedPointer(IRBuilder<> &Builder, Value *Ptr,
auto *PtrTy = cast<PointerType>(Ptr->getType());
if (!PtrTy->isOpaque()) {
Type *ElemTy = PtrTy->getNonOpaquePointerElementType();
- int ElemSize = HVC.getAllocSizeOf(ElemTy);
+ int ElemSize = HVC.getSizeOf(ElemTy, HVC.Alloc);
if (Adjust % ElemSize == 0 && Adjust != 0) {
Value *Tmp0 =
Builder.CreateGEP(ElemTy, Ptr, HVC.getConstInt(Adjust / ElemSize));
@@ -984,16 +987,20 @@ auto HexagonVectorCombine::isUndef(const Value *Val) const -> bool {
return isa<UndefValue>(Val);
}
-auto HexagonVectorCombine::getSizeOf(const Value *Val) const -> int {
- return getSizeOf(Val->getType());
-}
-
-auto HexagonVectorCombine::getSizeOf(const Type *Ty) const -> int {
- return DL.getTypeStoreSize(const_cast<Type *>(Ty)).getFixedValue();
+auto HexagonVectorCombine::getSizeOf(const Value *Val, SizeKind Kind) const
+ -> int {
+ return getSizeOf(Val->getType(), Kind);
}
-auto HexagonVectorCombine::getAllocSizeOf(const Type *Ty) const -> int {
- return DL.getTypeAllocSize(const_cast<Type *>(Ty)).getFixedValue();
+auto HexagonVectorCombine::getSizeOf(const Type *Ty, SizeKind Kind) const
+ -> int {
+ auto *NcTy = const_cast<Type *>(Ty);
+ switch (Kind) {
+ case Store:
+ return DL.getTypeStoreSize(NcTy).getFixedValue();
+ case Alloc:
+ return DL.getTypeAllocSize(NcTy).getFixedValue();
+ }
}
auto HexagonVectorCombine::getTypeAlignment(Type *Ty) const -> int {
@@ -1344,7 +1351,7 @@ auto HexagonVectorCombine::calculatePointerDifference(Value *Ptr0,
return None;
Builder B(Gep0->getParent());
- int Scale = getAllocSizeOf(Gep0->getSourceElementType());
+ int Scale = getSizeOf(Gep0->getSourceElementType(), Alloc);
// FIXME: for now only check GEPs with a single index.
if (Gep0->getNumOperands() != 2 || Gep1->getNumOperands() != 2)
More information about the llvm-commits
mailing list