Skip to content

Commit 21d7de1

Browse files
committed
Address review feedback, fix tests
1 parent 2bcc65e commit 21d7de1

File tree

4 files changed

+458
-1785
lines changed

4 files changed

+458
-1785
lines changed

llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -637,33 +637,33 @@ class LegalizeBufferContentTypesVisitor
637637
Value *makeIllegalNonAggregate(Value *V, Type *OrigType, const Twine &Name);
638638

639639
struct VecSlice {
640-
uint64_t Index;
641-
uint64_t Length;
642-
VecSlice(uint64_t Index, uint64_t Length) : Index(Index), Length(Length) {}
640+
uint64_t Index = 0;
641+
uint64_t Length = 0;
642+
VecSlice() = delete;
643643
};
644-
// Return the [index, length] pairs into which `T` needs to be cut to form
645-
// legal buffer load or store operations. Clears `Slices`. Creates an empty
646-
// `Slices` for non-vector inputs and creates one slice if no slicing will be
647-
// needed.
644+
/// Return the [index, length] pairs into which `T` needs to be cut to form
645+
/// legal buffer load or store operations. Clears `Slices`. Creates an empty
646+
/// `Slices` for non-vector inputs and creates one slice if no slicing will be
647+
/// needed.
648648
void getVecSlices(Type *T, SmallVectorImpl<VecSlice> &Slices);
649649

650650
Value *extractSlice(Value *Vec, VecSlice S, const Twine &Name);
651651
Value *insertSlice(Value *Whole, Value *Part, VecSlice S, const Twine &Name);
652652

653-
// In most cases, return `LegalType`. However, when given an input that would
654-
// normally be a legal type for the buffer intrinsics to return but that isn't
655-
// hooked up through SelectionDAG, return a type of the same width that can be
656-
// used with the relevant intrinsics. Specifically, handle the cases:
657-
// - <1 x T> => T for all T
658-
// - <N x i8> <=> i16, i32, 2xi32, 4xi32 (as needed)
659-
// - <N x T> where T is under 32 bits and the total size is 96 bits <=> <3 x
660-
// i32>
653+
/// In most cases, return `LegalType`. However, when given an input that would
654+
/// normally be a legal type for the buffer intrinsics to return but that
655+
/// isn't hooked up through SelectionDAG, return a type of the same width that
656+
/// can be used with the relevant intrinsics. Specifically, handle the cases:
657+
/// - <1 x T> => T for all T
658+
/// - <N x i8> <=> i16, i32, 2xi32, 4xi32 (as needed)
659+
/// - <N x T> where T is under 32 bits and the total size is 96 bits <=> <3 x
660+
/// i32>
661661
Type *intrinsicTypeFor(Type *LegalType);
662662

663663
bool visitLoadImpl(LoadInst &OrigLI, Type *PartType,
664664
SmallVectorImpl<uint32_t> &AggIdxs, uint64_t AggByteOffset,
665665
Value *&Result, const Twine &Name);
666-
// Return value is (Changed, ModifiedInPlace)
666+
/// Return value is (Changed, ModifiedInPlace)
667667
std::pair<bool, bool> visitStoreImpl(StoreInst &OrigSI, Type *PartType,
668668
SmallVectorImpl<uint32_t> &AggIdxs,
669669
uint64_t AggByteOffset,
@@ -838,7 +838,8 @@ void LegalizeBufferContentTypesVisitor::getVecSlices(
838838
uint64_t Index = 0;
839839
auto TrySlice = [&](unsigned MaybeLen) {
840840
if (MaybeLen > 0 && Index + MaybeLen <= TotalElems) {
841-
Slices.emplace_back(/*Index=*/Index, /*Length=*/MaybeLen);
841+
VecSlice Slice{/*Index=*/Index, /*Length=*/MaybeLen};
842+
Slices.push_back(Slice);
842843
Index += MaybeLen;
843844
return true;
844845
}
@@ -966,7 +967,7 @@ bool LegalizeBufferContentTypesVisitor::visitLoadImpl(
966967
unsigned ElemBytes = DL.getTypeStoreSize(ElemType);
967968
AAMDNodes AANodes = OrigLI.getAAMetadata();
968969
if (IsAggPart && Slices.empty())
969-
Slices.emplace_back(/*Index=*/0, /*Length=*/1);
970+
Slices.push_back(VecSlice{/*Index=*/0, /*Length=*/1});
970971
for (VecSlice S : Slices) {
971972
Type *SliceType =
972973
S.Length != 1 ? FixedVectorType::get(ElemType, S.Length) : ElemType;
@@ -1084,7 +1085,7 @@ std::pair<bool, bool> LegalizeBufferContentTypesVisitor::visitStoreImpl(
10841085
Value *OrigPtr = OrigSI.getPointerOperand();
10851086
Type *ElemType = LegalType->getScalarType();
10861087
if (IsAggPart && Slices.empty())
1087-
Slices.emplace_back(/*Index=*/0, /*Length=*/1);
1088+
Slices.push_back(VecSlice{/*Index=*/0, /*Length=*/1});
10881089
unsigned ElemBytes = DL.getTypeStoreSize(ElemType);
10891090
AAMDNodes AANodes = OrigSI.getAAMetadata();
10901091
for (VecSlice S : Slices) {

0 commit comments

Comments
 (0)