Commits

Daniel Roberts committed 26bbe37

Fixed test, cleaned up, working on passing final test.

Comments (0)

Files changed (2)

pypy/jit/metainterp/optimizeopt/addition.py

             self.roperands[result] = constant, root
 
             boxed_constant = ConstInt(constant)
-            new_op = ResOperation(rop.INT_SUB, [boxed_constant, variable], result)
+            new_op = ResOperation(rop.INT_SUB, [boxed_constant, root], result)
             self.emit_operation(new_op)
             return
         except KeyError:
         rv = self.getvalue(op.getarg(1))
         result = op.result
         if lv.is_constant() and rv.is_constant():
-            self.emit_operation(op) # XXX: there's support for optimizing this elsewhere, right?
+            self.emit_operation(op)
         elif lv.is_constant():
             constant = lv.box.getint()
             self._process_add(constant, op.getarg(1), result)
         rv = self.getvalue(op.getarg(1))
         result = op.result
         if lv.is_constant() and rv.is_constant():
-            self.emit_operation(op) # XXX: there's support for optimizing this elsewhere, right?
+            self.emit_operation(op)
         elif lv.is_constant():
             constant = lv.box.getint()
             self._process_sub(constant, op.getarg(1), result)
-            #self.emit_operation(op)
         elif rv.is_constant():
             constant = rv.box.getint()
             self._process_add(-constant, op.getarg(0), result)

pypy/jit/metainterp/test/test_optimizeopt.py

         i2 = int_sub(4, i1)
         i3 = int_sub(i2, 14)
         i4 = int_add(6, i2)
-        jump(i3)
+        jump(i4)
         """
 
         expected = """
         [i0]
         i1 = int_add(i0, 3)
         i2 = int_sub(1, i0)
-        i3 = int_sub(i0, 13)
-        i4 = int_sub(7, i0)
-        jump(i3)
-        """
+        i3 = int_sub(-13, i0)
+        i4 = int_sub(-7, i0)
+        jump(i4)
+        """
+        self.optimize_loop(ops, expected)
 
 ##class TestOOtype(OptimizeOptTest, OOtypeMixin):
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.