From 9c06a18a73d4f2ebd6f2f77788734eecd53371ab Mon Sep 17 00:00:00 2001 From: Jacob Hinkle Date: Tue, 22 Aug 2023 19:30:56 -0400 Subject: [PATCH] Ignore trivial loops in memory aliasing pass --- csrc/device_lower/pass/alias_memory.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/csrc/device_lower/pass/alias_memory.cpp b/csrc/device_lower/pass/alias_memory.cpp index b1f17c436a9..1367761f89b 100644 --- a/csrc/device_lower/pass/alias_memory.cpp +++ b/csrc/device_lower/pass/alias_memory.cpp @@ -743,7 +743,13 @@ class AllocationInfoMap : private kir::IrVisitor { void handle(kir::ForLoop* for_loop) final { auto loop_info = scope_map_.getLoopScopeInfo(for_loop); - current_stack_.push_back(loop_info); + if (!for_loop->isTrivial()) { + // Parallelized loops do not result in for loops in the CUDA kernel, so + // they should not affect liveness analysis. This means that + // current_stack_ will differ from kir::IrVisitor::for_loops_, which will + // actually hold all ForLoops regardless of parallelization. + current_stack_.push_back(loop_info); + } if (debug_printer_) { debug_printer_->pushScope(); } @@ -751,7 +757,9 @@ class AllocationInfoMap : private kir::IrVisitor { if (debug_printer_) { debug_printer_->popScope(); } - current_stack_.pop_back(); + if (!for_loop->isTrivial()) { + current_stack_.pop_back(); + } } void handle(kir::IfThenElse* ite) final {