Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit c8bdfa4

Browse files
author
Sven Verdoolaege
committed
LLVMCodegen: hoist access to for-node loop iterator
This simplifies the code by removing some duplication.
1 parent c1041fa commit c8bdfa4

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/core/polyhedral/codegen_llvm.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -486,16 +486,15 @@ class LLVMCodegen {
486486
halide_cg.get_builder().CreateBr(headerBB);
487487

488488
llvm::PHINode* phi = nullptr;
489+
auto iterator = node.get_iterator().get_id();
489490

490491
// Loop Header
491492
{
492493
auto initVal = IslExprToSInt(node.get_init());
493494
halide_cg.get_builder().SetInsertPoint(headerBB);
494495
phi = halide_cg.get_builder().CreatePHI(
495-
llvm::Type::getInt64Ty(llvmCtx),
496-
2,
497-
node.get_iterator().get_id().get_name());
498-
halide_cg.sym_push(node.get_iterator().get_id().get_name(), phi);
496+
llvm::Type::getInt64Ty(llvmCtx), 2, iterator.get_name());
497+
halide_cg.sym_push(iterator.get_name(), phi);
499498
phi->addIncoming(getLLVMConstantSignedInt64(initVal), incoming);
500499

501500
auto cond_expr = node.get_cond();
@@ -507,7 +506,7 @@ class LLVMCodegen {
507506
CHECK(
508507
isl_ast_expr_get_type(condLHS.get()) ==
509508
isl_ast_expr_type::isl_ast_expr_id);
510-
CHECK_EQ(condLHS.get_id(), node.get_iterator().get_id());
509+
CHECK_EQ(condLHS.get_id(), iterator);
511510

512511
IslAstExprInterpeter i(scop_.globalParameterContext);
513512
auto condRHSVal = i.interpret(cond_expr.get_op_arg(1));
@@ -564,7 +563,7 @@ class LLVMCodegen {
564563
}
565564

566565
halide_cg.get_builder().SetInsertPoint(loopExitBB);
567-
halide_cg.sym_pop(node.get_iterator().get_id().get_name());
566+
halide_cg.sym_pop(iterator.get_name());
568567
#ifdef TAPIR_VERSION_MAJOR
569568
if (parallel) {
570569
auto* syncBB = llvm::BasicBlock::Create(llvmCtx, "synced", function);

0 commit comments

Comments
 (0)