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
Branches
1 merge request!435Fix canonicalization of >2 loops with the same counter
...@@ -102,10 +102,11 @@ class CanonicalizeSymbols: ...@@ -102,10 +102,11 @@ class CanonicalizeSymbols:
cc.mark_as_updated(lhs.symbol) cc.mark_as_updated(lhs.symbol)
case PsLoop(ctr, _, _, _, _): case PsLoop(ctr, _, _, _, _):
decl_symb = ctr.symbol
for c in node.children[::-1]: for c in node.children[::-1]:
self.visit(c, cc) self.visit(c, cc)
cc.mark_as_updated(ctr.symbol) cc.mark_as_updated(ctr.symbol)
cc.end_lifespan(ctr.symbol) cc.end_lifespan(decl_symb)
case PsConditional(cond, then, els): case PsConditional(cond, then, els):
if els is not None: if els is not None:
......
...@@ -104,13 +104,16 @@ def test_loop_counters(): ...@@ -104,13 +104,16 @@ def test_loop_counters():
loops = factory.loops_from_ispace(ispace, body) 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) ast = canonicalize(ast)
assert loops_copy.counter.symbol.name == "ctr_0" assert loops_clone2.counter.symbol.name == "ctr_0"
assert not loops_copy.counter.symbol.get_dtype().const assert not loops_clone2.counter.symbol.get_dtype().const
assert loops.counter.symbol.name == "ctr_0__0" 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 assert not loops.counter.symbol.get_dtype().const
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment