Skip to content
Snippets Groups Projects
Commit 3fa05468 authored by Rafael Ravedutti's avatar Rafael Ravedutti
Browse files

Fix LICM transformation with new changes

parent 549770f0
No related branches found
No related tags found
No related merge requests found
...@@ -267,3 +267,5 @@ class VectorAccess(ASTTerm): ...@@ -267,3 +267,5 @@ class VectorAccess(ASTTerm):
def sub(self, other): def sub(self, other):
return self.sim.add_statement(Assign(self.sim, self, self - other)) return self.sim.add_statement(Assign(self.sim, self, self - other))
def children(self):
return [self.expr]
...@@ -212,7 +212,7 @@ class ParticleSimulation: ...@@ -212,7 +212,7 @@ class ParticleSimulation:
# Transformations # Transformations
prioritaze_scalar_ops(program) prioritaze_scalar_ops(program)
simplify_expressions(program) simplify_expressions(program)
#move_loop_invariant_code(program) move_loop_invariant_code(program)
set_used_bin_ops(program) set_used_bin_ops(program)
# For this part on, all bin ops are generated without usage verification # For this part on, all bin ops are generated without usage verification
......
...@@ -155,7 +155,6 @@ class SetBinOpTerminals(Visitor): ...@@ -155,7 +155,6 @@ class SetBinOpTerminals(Visitor):
def visit_Property(self, ast_node): def visit_Property(self, ast_node):
self.push_terminal(ast_node) self.push_terminal(ast_node)
def visit_Var(self, ast_node): def visit_Var(self, ast_node):
self.push_terminal(ast_node) self.push_terminal(ast_node)
...@@ -183,11 +182,11 @@ class LICM(Mutator): ...@@ -183,11 +182,11 @@ class LICM(Mutator):
return ast_node return ast_node
def mutate_Decl(self, ast_node): def mutate_Decl(self, ast_node):
if self.loops: if self.loops and isinstance(ast_node.elem, (BinOp, PropertyAccess)):
last_loop = self.loops[-1] last_loop = self.loops[-1]
#print(f"variants = {last_loop.block.variants}, terminals = {ast_node.bin_op.terminals}") #print(f"variants = {last_loop.block.variants}, terminals = {ast_node.elem.terminals}")
if isinstance(ast_node.elem, (BinOp, PropertyAccess)) and not last_loop.block.variants.intersection(ast_node.elem.terminals): if not last_loop.block.variants.intersection(ast_node.elem.terminals):
#print(f'lifting {ast_node.bin_op.id()}') #print(f'lifting {ast_node.elem.id()}')
self.lifts[id(last_loop)].append(ast_node) self.lifts[id(last_loop)].append(ast_node)
return None return None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment