Skip to content

Commit 2eac8ce

Browse files
Get the address space within getVectorPtrTy
getVectorPtrTy is private to VectorBlockGenerator, and all uses query the address space from the passed-in pointer prior to calling it. Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D89745
1 parent d5c022d commit 2eac8ce

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

polly/include/polly/CodeGen/BlockGenerators.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ class VectorBlockGenerator : BlockGenerator {
662662
Value *getVectorValue(ScopStmt &Stmt, Value *Old, ValueMapT &VectorMap,
663663
VectorValueMapT &ScalarMaps, Loop *L);
664664

665-
Type *getVectorPtrTy(const Value *V, int Width, unsigned AddrSpace);
665+
Type *getVectorPtrTy(const Value *V, int Width);
666666

667667
/// Load a vector from a set of adjacent scalars
668668
///

polly/lib/CodeGen/BlockGenerators.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,10 +1037,9 @@ Value *VectorBlockGenerator::getVectorValue(ScopStmt &Stmt, Value *Old,
10371037
return Vector;
10381038
}
10391039

1040-
Type *VectorBlockGenerator::getVectorPtrTy(const Value *Val, int Width,
1041-
unsigned AddrSpace) {
1042-
PointerType *PointerTy = dyn_cast<PointerType>(Val->getType());
1043-
assert(PointerTy && "PointerType expected");
1040+
Type *VectorBlockGenerator::getVectorPtrTy(const Value *Val, int Width) {
1041+
auto *PointerTy = cast<PointerType>(Val->getType());
1042+
unsigned AddrSpace = PointerTy->getAddressSpace();
10441043

10451044
Type *ScalarType = PointerTy->getElementType();
10461045
auto *FVTy = FixedVectorType::get(ScalarType, Width);
@@ -1053,8 +1052,7 @@ Value *VectorBlockGenerator::generateStrideOneLoad(
10531052
__isl_keep isl_id_to_ast_expr *NewAccesses, bool NegativeStride = false) {
10541053
unsigned VectorWidth = getVectorWidth();
10551054
auto *Pointer = Load->getPointerOperand();
1056-
auto AS = Pointer->getType()->getPointerAddressSpace();
1057-
Type *VectorPtrType = getVectorPtrTy(Pointer, VectorWidth, AS);
1055+
Type *VectorPtrType = getVectorPtrTy(Pointer, VectorWidth);
10581056
unsigned Offset = NegativeStride ? VectorWidth - 1 : 0;
10591057

10601058
Value *NewPointer = generateLocationAccessed(Stmt, Load, ScalarMaps[Offset],
@@ -1083,8 +1081,7 @@ Value *VectorBlockGenerator::generateStrideZeroLoad(
10831081
ScopStmt &Stmt, LoadInst *Load, ValueMapT &BBMap,
10841082
__isl_keep isl_id_to_ast_expr *NewAccesses) {
10851083
auto *Pointer = Load->getPointerOperand();
1086-
auto AS = Pointer->getType()->getPointerAddressSpace();
1087-
Type *VectorPtrType = getVectorPtrTy(Pointer, 1, AS);
1084+
Type *VectorPtrType = getVectorPtrTy(Pointer, 1);
10881085
Value *NewPointer =
10891086
generateLocationAccessed(Stmt, Load, BBMap, VLTS[0], NewAccesses);
10901087
Value *VectorPtr = Builder.CreateBitCast(NewPointer, VectorPtrType,
@@ -1204,8 +1201,7 @@ void VectorBlockGenerator::copyStore(
12041201
extractScalarValues(Store, VectorMap, ScalarMaps);
12051202

12061203
if (Access.isStrideOne(isl::manage_copy(Schedule))) {
1207-
auto AS = Pointer->getType()->getPointerAddressSpace();
1208-
Type *VectorPtrType = getVectorPtrTy(Pointer, getVectorWidth(), AS);
1204+
Type *VectorPtrType = getVectorPtrTy(Pointer, getVectorWidth());
12091205
Value *NewPointer = generateLocationAccessed(Stmt, Store, ScalarMaps[0],
12101206
VLTS[0], NewAccesses);
12111207

@@ -1343,8 +1339,7 @@ void VectorBlockGenerator::generateScalarVectorLoads(
13431339
continue;
13441340

13451341
auto *Address = getOrCreateAlloca(*MA);
1346-
auto AS = Address->getType()->getPointerAddressSpace();
1347-
Type *VectorPtrType = getVectorPtrTy(Address, 1, AS);
1342+
Type *VectorPtrType = getVectorPtrTy(Address, 1);
13481343
Value *VectorPtr = Builder.CreateBitCast(Address, VectorPtrType,
13491344
Address->getName() + "_p_vec_p");
13501345
auto *Val = Builder.CreateLoad(VectorPtr, Address->getName() + ".reload");

0 commit comments

Comments
 (0)