[llvm] 9c9e877 - [Hexagon] Move function to a different class, NFC
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 27 10:33:11 PDT 2022
Author: Krzysztof Parzyszek
Date: 2022-09-27T10:32:52-07:00
New Revision: 9c9e877b7e969b3e5d8382fca9a4da9a1be8ed62
URL: https://github.com/llvm/llvm-project/commit/9c9e877b7e969b3e5d8382fca9a4da9a1be8ed62
DIFF: https://github.com/llvm/llvm-project/commit/9c9e877b7e969b3e5d8382fca9a4da9a1be8ed62.diff
LOG: [Hexagon] Move function to a different class, NFC
"Sector" is a concept from AlignVectors, so the check for it
should be there.
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 f37c50900adb4..5bc9dd6d6156a 100644
--- a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
@@ -110,6 +110,9 @@ class HexagonVectorCombine {
BasicBlock::const_iterator To,
const T &Ignore = {}) const;
+ // This function is only used for assertions at the moment.
+ [[maybe_unused]] bool isByteVecTy(Type *Ty) const;
+
Function &F;
const DataLayout &DL;
AliasAnalysis &AA;
@@ -119,11 +122,6 @@ class HexagonVectorCombine {
const HexagonSubtarget &HST;
private:
-#ifndef NDEBUG
- // These two functions are only used for assertions at the moment.
- bool isByteVecTy(Type *Ty) const;
- bool isSectorTy(Type *Ty) const;
-#endif
Value *getElementRange(IRBuilder<> &Builder, Value *Lo, Value *Hi, int Start,
int Length) const;
};
@@ -224,6 +222,8 @@ class AlignVectors {
Optional<MemoryLocation> getLocation(const Instruction &In) const;
Optional<AddrInfo> getAddrInfo(Instruction &In) const;
bool isHvx(const AddrInfo &AI) const;
+ // This function is only used for assertions at the moment.
+ [[maybe_unused]] bool isSectorTy(Type *Ty) const;
Value *getPayload(Value *Val) const;
Value *getMask(Value *Val) const;
@@ -804,6 +804,7 @@ auto AlignVectors::realignGroup(const MoveGroup &Move) const -> bool {
if (DoAlign) {
for (int j = 0; j != NumSectors; ++j) {
+ assert(isSectorTy(ASpan[j].Seg.Val->getType()));
ASpan[j].Seg.Val = HVC.vralignb(Builder, ASpan[j].Seg.Val,
ASpan[j + 1].Seg.Val, AlignVal);
}
@@ -867,10 +868,11 @@ auto AlignVectors::realignGroup(const MoveGroup &Move) const -> bool {
// vlalign
if (DoAlign) {
for (int j = 1; j != NumSectors + 2; ++j) {
- ASpanV[j - 1].Seg.Val = HVC.vlalignb(Builder, ASpanV[j - 1].Seg.Val,
- ASpanV[j].Seg.Val, AlignVal);
- ASpanM[j - 1].Seg.Val = HVC.vlalignb(Builder, ASpanM[j - 1].Seg.Val,
- ASpanM[j].Seg.Val, AlignVal);
+ Value *PrevV = ASpanV[j - 1].Seg.Val, *ThisV = ASpanV[j].Seg.Val;
+ Value *PrevM = ASpanM[j - 1].Seg.Val, *ThisM = ASpanM[j].Seg.Val;
+ assert(isSectorTy(PrevV->getType()) && isSectorTy(PrevM->getType()));
+ ASpanV[j - 1].Seg.Val = HVC.vlalignb(Builder, PrevV, ThisV, AlignVal);
+ ASpanM[j - 1].Seg.Val = HVC.vlalignb(Builder, PrevM, ThisM, AlignVal);
}
}
@@ -897,6 +899,15 @@ auto AlignVectors::realignGroup(const MoveGroup &Move) const -> bool {
return true;
}
+auto AlignVectors::isSectorTy(Type *Ty) const -> bool {
+ if (!HVC.isByteVecTy(Ty))
+ return false;
+ int Size = HVC.getSizeOf(Ty);
+ if (HVC.HST.isTypeForHVX(Ty))
+ return Size == static_cast<int>(HVC.HST.getVectorLength());
+ return Size == 4 || Size == 8;
+}
+
auto AlignVectors::run() -> bool {
if (!createAddressGroups())
return false;
@@ -1039,7 +1050,6 @@ auto HexagonVectorCombine::insertb(IRBuilder<> &Builder, Value *Dst, Value *Src,
auto HexagonVectorCombine::vlalignb(IRBuilder<> &Builder, Value *Lo, Value *Hi,
Value *Amt) const -> Value * {
assert(Lo->getType() == Hi->getType() && "Argument type mismatch");
- assert(isSectorTy(Hi->getType()));
if (isZero(Amt))
return Hi;
int VecLen = getSizeOf(Hi);
@@ -1073,7 +1083,6 @@ auto HexagonVectorCombine::vlalignb(IRBuilder<> &Builder, Value *Lo, Value *Hi,
auto HexagonVectorCombine::vralignb(IRBuilder<> &Builder, Value *Lo, Value *Hi,
Value *Amt) const -> Value * {
assert(Lo->getType() == Hi->getType() && "Argument type mismatch");
- assert(isSectorTy(Lo->getType()));
if (isZero(Amt))
return Lo;
int VecLen = getSizeOf(Lo);
@@ -1448,23 +1457,12 @@ auto HexagonVectorCombine::isSafeToMoveBeforeInBB(const Instruction &In,
return true;
}
-#ifndef NDEBUG
auto HexagonVectorCombine::isByteVecTy(Type *Ty) const -> bool {
if (auto *VecTy = dyn_cast<VectorType>(Ty))
return VecTy->getElementType() == getByteTy();
return false;
}
-auto HexagonVectorCombine::isSectorTy(Type *Ty) const -> bool {
- if (!isByteVecTy(Ty))
- return false;
- int Size = getSizeOf(Ty);
- if (HST.isTypeForHVX(Ty))
- return Size == static_cast<int>(HST.getVectorLength());
- return Size == 4 || Size == 8;
-}
-#endif
-
auto HexagonVectorCombine::getElementRange(IRBuilder<> &Builder, Value *Lo,
Value *Hi, int Start,
int Length) const -> Value * {
More information about the llvm-commits
mailing list