Skip to content
Snippets Groups Projects
Commit 4a790e1c authored by Nils Kohl's avatar Nils Kohl :full_moon_with_face:
Browse files

Removing the replacement of loop nodes with blocks for loops of length one in...

Removing the replacement of loop nodes with blocks for loops of length one in 5f3be7b3 disabled safety mechanism that ensures that the new cutting point is actually in the loop bounds. It's the 'with_conditional' parameters. Reintroduced it in this commit - now both can be combined.
parent 5d9f76d6
No related merge requests found
Pipeline #66507 failed with stages
in 2 minutes and 49 seconds
......@@ -901,14 +901,22 @@ def cut_loop(loop_node, cutting_points, with_conditional: bool = False, replace_
new_start = loop_node.start
cutting_points = list(cutting_points) + [loop_node.stop]
for new_end in cutting_points:
if replace_loops_with_length_one and (new_end - new_start == 1):
if new_end - new_start == 1:
new_body = deepcopy(loop_node.body)
new_body.subs({loop_node.loop_counter_symbol: new_start})
if replace_loops_with_length_one:
new_body.subs({loop_node.loop_counter_symbol: new_start})
if with_conditional:
conditional_expr = sp.And(sp.Ge(new_start, loop_node.start), sp.Le(new_start, loop_node.stop))
new_loops.append(ast.Conditional(conditional_expr, new_body))
new_body_wrapped = ast.Block(ast.Conditional(conditional_expr, new_body))
else:
new_loops.append(new_body)
new_body_wrapped = new_body
if not replace_loops_with_length_one:
new_loop = ast.LoopOverCoordinate(
new_body_wrapped, loop_node.coordinate_to_loop_over,
new_start, new_end, loop_node.step)
else:
new_loop = new_body_wrapped
new_loops.append(new_loop)
elif new_end - new_start == 0:
pass
else:
......
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