# HG changeset patch # User Paul Boddie # Date 1220741240 -7200 # Node ID 4cb6ccaaf758bf4f5eeeaa9b12dc016c7a69b9f6 # Parent bd6baced90abb0cbce59aa18cb0c569c0283344a Removed the superfluous temporary storage optimisation since it could never work as implemented (and would be mostly equivalent to the source storage optimisation). diff -r bd6baced90ab -r 4cb6ccaaf758 docs/optimisations.txt --- a/docs/optimisations.txt Sun Sep 07 00:35:03 2008 +0200 +++ b/docs/optimisations.txt Sun Sep 07 00:47:20 2008 +0200 @@ -2,44 +2,38 @@ ------------ ------------------------ constant_storage value instruction references a constant; - storage instruction references a constant; - remove both instructions (currently a single merged instruction) +(elimination) storage instruction references a constant; + remove both instructions (currently a single + merged instruction) source_storage source instruction is a simple input operation; - source instruction is the last instruction; +(elimination) source instruction is the last instruction; remove the source instruction known_target value instruction references a constant; - target and context are provided (no instructions removed) +(guidance) target and context are provided (no instructions removed) self_access value instruction references "self" in a method; - specified attribute name always has the same position; +(guidance) specified attribute name always has the same position; appropriate instruction generated temp_storage value instruction is a simple input operation; - value instruction is the last instruction; - remove the value instruction, provide the value +(elimination) value instruction is the last instruction; +(guidance) remove the value instruction, provide the value instruction in place of a temporary storage reference load_operations value instruction is a simple input operation; - value instruction is the last instruction; +(merge) value instruction is the last instruction; current instruction uses simple input; remove the value instruction, make the value instruction the input to the current instruction no_operations input to the current instruction loads from the - destination of the current instruction; +(elimination) destination of the current instruction; omit the current instruction unused_results value instruction is a simple input operation; - value instruction is the final instruction of a +(elimination) value instruction is the final instruction of a discarded expression; remove the value instruction - -superfluous_temp_operations source instruction writes to temporary storage; - current instruction reads from the same storage; - source instruction is the last instruction; - remove the source instruction, make the current - instruction use the input of the source - instruction diff -r bd6baced90ab -r 4cb6ccaaf758 micropython/ast.py --- a/micropython/ast.py Sun Sep 07 00:35:03 2008 +0200 +++ b/micropython/ast.py Sun Sep 07 00:47:20 2008 +0200 @@ -31,8 +31,7 @@ supported_optimisations = [ "constant_storage", "source_storage", "known_target", "self_access", - "temp_storage", "load_operations", "no_operations", "unused_results", - "superfluous_temp_operations" + "temp_storage", "load_operations", "no_operations", "unused_results" ] def __init__(self, translation, optimisations=None): @@ -69,9 +68,6 @@ def should_optimise_away_no_operations(self): return "no_operations" in self.optimisations - def should_optimise_away_superfluous_temp_operations(self): - return "superfluous_temp_operations" in self.optimisations - def should_optimise_unused_results(self): return "unused_results" in self.optimisations @@ -132,18 +128,6 @@ isinstance(instruction.input, LoadResult) and isinstance(instruction, StoreResult) ) - def is_superfluous_temp_operation(self, instruction): - - """ - Return whether 'instruction' merely loads its input from a recent - temporary storage operation. - """ - - return ( - isinstance(instruction.source, LoadTemp) and isinstance(self.translation.active_source, StoreTemp) and - instruction.source.attr == self.translation.active_source.attr - ) - def is_input(self, instruction): "Return whether 'instruction' provides an input." @@ -377,20 +361,6 @@ else: return 0 - def optimise_away_superfluous_temp_operations(self, instruction): - - """ - Optimise away operations which just store temporary values for - immediate retrieval. - """ - - if self.should_optimise_away_superfluous_temp_operations() and \ - self.is_superfluous_temp_operation(instruction) and \ - self.translation.active_source == self.translation.active: - - instruction.source = self.translation.active_source.input - self.translation.remove_op() - def optimise_unused_results(self): "Discard results which will not be used." @@ -701,7 +671,6 @@ self.optimiser.optimise_load_operations(op) if self.optimiser.optimise_away_no_operations(op): return - self.optimiser.optimise_away_superfluous_temp_operations(op) self.code.append(op) self.active = op