Skip to content

Commit 880014b

Browse files
committed
[PPCGCodeGeneration] Avoid another pointer element type access
Use an API that returns both the address and the element type, and use that for the load type.
1 parent cc03414 commit 880014b

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

polly/lib/CodeGen/PPCGCodeGeneration.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,19 +1314,18 @@ void GPUNodeBuilder::createFor(__isl_take isl_ast_node *Node) {
13141314

13151315
void GPUNodeBuilder::createKernelCopy(ppcg_kernel_stmt *KernelStmt) {
13161316
isl_ast_expr *LocalIndex = isl_ast_expr_copy(KernelStmt->u.c.local_index);
1317-
LocalIndex = isl_ast_expr_address_of(LocalIndex);
1318-
Value *LocalAddr = ExprBuilder.create(LocalIndex);
1317+
auto LocalAddr = ExprBuilder.createAccessAddress(LocalIndex);
13191318
isl_ast_expr *Index = isl_ast_expr_copy(KernelStmt->u.c.index);
1320-
Index = isl_ast_expr_address_of(Index);
1321-
Value *GlobalAddr = ExprBuilder.create(Index);
1322-
Type *IndexTy = GlobalAddr->getType()->getPointerElementType();
1319+
auto GlobalAddr = ExprBuilder.createAccessAddress(Index);
13231320

13241321
if (KernelStmt->u.c.read) {
1325-
LoadInst *Load = Builder.CreateLoad(IndexTy, GlobalAddr, "shared.read");
1326-
Builder.CreateStore(Load, LocalAddr);
1322+
LoadInst *Load =
1323+
Builder.CreateLoad(GlobalAddr.second, GlobalAddr.first, "shared.read");
1324+
Builder.CreateStore(Load, LocalAddr.first);
13271325
} else {
1328-
LoadInst *Load = Builder.CreateLoad(IndexTy, LocalAddr, "shared.write");
1329-
Builder.CreateStore(Load, GlobalAddr);
1326+
LoadInst *Load =
1327+
Builder.CreateLoad(LocalAddr.second, LocalAddr.first, "shared.write");
1328+
Builder.CreateStore(Load, GlobalAddr.first);
13301329
}
13311330
}
13321331

0 commit comments

Comments
 (0)