Skip to content
Snippets Groups Projects
Commit 2fd2aa56 authored by Daniel Bauer's avatar Daniel Bauer :speech_balloon: Committed by Frederik Hennig
Browse files

Fix canonicalization of >2 loops with the same counter

parent 288af99f
No related branches found
No related tags found
1 merge request!435Fix canonicalization of >2 loops with the same counter
......@@ -102,10 +102,11 @@ class CanonicalizeSymbols:
cc.mark_as_updated(lhs.symbol)
case PsLoop(ctr, _, _, _, _):
decl_symb = ctr.symbol
for c in node.children[::-1]:
self.visit(c, cc)
cc.mark_as_updated(ctr.symbol)
cc.end_lifespan(ctr.symbol)
cc.end_lifespan(decl_symb)
case PsConditional(cond, then, els):
if els is not None:
......
......@@ -104,13 +104,16 @@ def test_loop_counters():
loops = factory.loops_from_ispace(ispace, body)
loops_copy = loops.clone()
loops_clone = loops.clone()
loops_clone2 = loops.clone()
ast = PsBlock([loops, loops_copy])
ast = PsBlock([loops, loops_clone, loops_clone2])
ast = canonicalize(ast)
assert loops_copy.counter.symbol.name == "ctr_0"
assert not loops_copy.counter.symbol.get_dtype().const
assert loops.counter.symbol.name == "ctr_0__0"
assert loops_clone2.counter.symbol.name == "ctr_0"
assert not loops_clone2.counter.symbol.get_dtype().const
assert loops_clone.counter.symbol.name == "ctr_0__0"
assert not loops_clone.counter.symbol.get_dtype().const
assert loops.counter.symbol.name == "ctr_0__1"
assert not loops.counter.symbol.get_dtype().const
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment