Skip to content
Snippets Groups Projects

Do not reorder accesses in `move_constants_before_loop` (quickly)

Merged Daniel Bauer requested to merge terraneo/pystencils:bauerd/move-constants-2 into master
3 files
+ 85
24
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 0
16
@@ -345,14 +345,6 @@ class Block(Node):
@@ -345,14 +345,6 @@ class Block(Node):
assert self._nodes.count(insert_before) == 1
assert self._nodes.count(insert_before) == 1
idx = self._nodes.index(insert_before)
idx = self._nodes.index(insert_before)
# move all assignment (definitions to the top)
if isinstance(new_node, SympyAssignment) and new_node.is_declaration:
while idx > 0:
pn = self._nodes[idx - 1]
if isinstance(pn, LoopOverCoordinate) or isinstance(pn, Conditional):
idx -= 1
else:
break
if not if_not_exists or self._nodes[idx] != new_node:
if not if_not_exists or self._nodes[idx] != new_node:
self._nodes.insert(idx, new_node)
self._nodes.insert(idx, new_node)
@@ -361,14 +353,6 @@ class Block(Node):
@@ -361,14 +353,6 @@ class Block(Node):
assert self._nodes.count(insert_after) == 1
assert self._nodes.count(insert_after) == 1
idx = self._nodes.index(insert_after) + 1
idx = self._nodes.index(insert_after) + 1
# move all assignment (definitions to the top)
if isinstance(new_node, SympyAssignment) and new_node.is_declaration:
while idx > 0:
pn = self._nodes[idx - 1]
if isinstance(pn, LoopOverCoordinate) or isinstance(pn, Conditional):
idx -= 1
else:
break
if not if_not_exists or not (self._nodes[idx - 1] == new_node
if not if_not_exists or not (self._nodes[idx - 1] == new_node
or (idx < len(self._nodes) and self._nodes[idx] == new_node)):
or (idx < len(self._nodes) and self._nodes[idx] == new_node)):
self._nodes.insert(idx, new_node)
self._nodes.insert(idx, new_node)
Loading