Skip to content

Commit

Permalink
Parallel: Add missing recursion on remove_block_loops
Browse files Browse the repository at this point in the history
  • Loading branch information
mlange05 committed Nov 14, 2024
1 parent 2731d1a commit c6c7b50
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions loki/transformations/parallel/block_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ class RemoveBlockLoopTransformer(Transformer):
"""

def visit_Loop(self, loop, **kwargs): # pylint: disable=unused-argument
body = self.visit(loop.body, **kwargs)

if not loop.variable == idx:
return loop
return loop._rebuild(body=body)

to_remove = tuple(
a for a in FindNodes(ir.Assignment).visit(loop.body)
a for a in FindNodes(ir.Assignment).visit(body)
if a.lhs in variables
)
return tuple(n for n in loop.body if n not in to_remove)
return tuple(n for n in body if n not in to_remove)

routine.body = RemoveBlockLoopTransformer().visit(routine.body)

Expand Down

0 comments on commit c6c7b50

Please sign in to comment.