Commit ed8637b8 authored by Jayke Meijer's avatar Jayke Meijer

Working on copy propagation.

parent 7b0de9af
from src.dataflow import find_basic_blocks
from dataflow import find_basic_blocks
from standard import redundant_move_1, redundant_move_2, \
redundant_move_3, redundant_move_4, redundant_load, \
......@@ -57,7 +57,7 @@ def optimize_block(block):
# or fold_constants(block)
while eliminate_common_subexpressions(block) \
| fold_constants(block):
| fold_constants(block) | copy_propagation(block):
pass
def optimize(statements, verbose=0):
......
from src.statement import Statement as S
from statement import Statement as S
def eliminate_common_subexpressions(block):
......@@ -55,9 +55,20 @@ def fold_constants(block):
"""
return False
def copy_propagtion(block):
def copy_propagation(block):
"""
Rename values that were copied to there original, so the copy statement
might be useless, allowing it to be removed by dead code elimination.
"""
moves = []
count = 0
while not block.end():
s = block.read()
if s.is_command('move'):
moves.append((s[0], s[1]))
count += 1
print "count", count
return false
Markdown is supported
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