1.1 --- a/micropython/opt.py Thu Sep 08 00:33:33 2011 +0200
1.2 +++ b/micropython/opt.py Sat Sep 10 20:29:30 2011 +0200
1.3 @@ -137,8 +137,8 @@
1.4 """
1.5
1.6 if self.active in self.active_values:
1.7 - removed = self.active
1.8 - self.translation.remove_op()
1.9 + removed = self.translation.remove_op()
1.10 + self.active_values.remove(removed)
1.11 return removed
1.12 else:
1.13 return None
1.14 @@ -239,7 +239,8 @@
1.15 # NOTE: locals/frames.
1.16
1.17 return isinstance(instruction, (StoreAddress, StoreAddressContext)) and \
1.18 - instruction.attr.assignments == 1
1.19 + instruction.attr.is_constant() and \
1.20 + instruction.attr.is_strict_constant()
1.21
1.22 def is_simple_input(self, instruction):
1.23
1.24 @@ -263,8 +264,11 @@
1.25 last_op = last_op or self.translation.last_op()
1.26 return last_op and last_op.attr == instruction.attr and (
1.27 isinstance(instruction, StoreTemp) and isinstance(last_op, LoadTemp) or
1.28 - isinstance(instruction, StoreAddress) and isinstance(last_op, LoadAddress)
1.29 - )
1.30 + isinstance(instruction, StoreAddress) and isinstance(last_op, LoadAddress) or
1.31 + last_op.source == instruction.target and (
1.32 + isinstance(instruction, LoadTemp) and isinstance(last_op, StoreTemp) or
1.33 + isinstance(instruction, LoadAddress) and isinstance(last_op, StoreAddress)
1.34 + ))
1.35
1.36 # Convenience tests on outputs.
1.37
1.38 @@ -335,7 +339,7 @@
1.39
1.40 # Optimisation methods. See the supported_optimisations class attribute.
1.41
1.42 - def optimise_constant_storage(self, expr=None):
1.43 + def optimise_constant_storage(self, expr):
1.44
1.45 """
1.46 Where the last operation stores a constant into a target which is also