Skip to content
Snippets Groups Projects
Commit 131fa9ca authored by Frederik Hennig's avatar Frederik Hennig
Browse files

Merge branch 'bauerd/fix-canon-loops' into 'v2.0-dev'

Fix canonicalization of >2 loops with the same counter

See merge request !435
parents 288af99f 2fd2aa56
No related branches found
No related tags found
No related merge requests found
Pipeline #71985 passed
...@@ -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% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment