[pypy-commit] pypy regalloc-playground: implement hints for int_sub

cfbolz pypy.commits at gmail.com
Wed Sep 6 12:39:56 EDT 2017


Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch: regalloc-playground
Changeset: r92337:91c860e7fe64
Date: 2017-09-06 18:14 +0200
http://bitbucket.org/pypy/pypy/changeset/91c860e7fe64/

Log:	implement hints for int_sub

diff --git a/rpython/jit/backend/x86/reghint.py b/rpython/jit/backend/x86/reghint.py
--- a/rpython/jit/backend/x86/reghint.py
+++ b/rpython/jit/backend/x86/reghint.py
@@ -76,6 +76,14 @@
         else:
             self._consider_binop_symm(op, position)
 
+    def consider_int_sub(self, op, position):
+        y = op.getarg(1)
+        if isinstance(y, ConstInt) and rx86.fits_in_32bits(-y.value):
+            pass # nothing to be hinted
+        else:
+            self._consider_binop(op, position)
+
+
     consider_nursery_ptr_increment = consider_int_add
 
     def consider_int_lshift(self, op, position):
diff --git a/rpython/jit/backend/x86/test/test_regalloc.py b/rpython/jit/backend/x86/test/test_regalloc.py
--- a/rpython/jit/backend/x86/test/test_regalloc.py
+++ b/rpython/jit/backend/x86/test/test_regalloc.py
@@ -147,7 +147,7 @@
 
     def test_coalescing(self):
         ops = '''
-        [i0, i1, i2, i3]
+        [i0, i1, i3]
         i7 = int_add(i0, i1)
         i8 = int_add(i7, i3)
         i9 = call_i(ConstClass(f1ptr), i8, descr=f1_calldescr)
@@ -155,14 +155,28 @@
         guard_true(i10) []
         finish(i9)
         '''
-        self.interpret(ops, [5, 6, 7, 8])
+        self.interpret(ops, [5, 6, 8])
         # coalescing makes sure that i0 (and thus i71) lands in edi
         assert len(self.filter_log_moves()) == 2
 
+    def test_coalescing_sub(self):
+        ops = '''
+        [i0, i1, i3]
+        i7 = int_sub(i0, i1)
+        i8 = int_sub(i7, i3)
+        i9 = call_i(ConstClass(f1ptr), i8, descr=f1_calldescr)
+        i10 = int_is_true(i9)
+        guard_true(i10) []
+        finish(i9)
+        '''
+        self.interpret(ops, [5, 6, 8])
+        # coalescing makes sure that i7 (and thus i8) lands in edi
+        assert len(self.filter_log_moves()) == 2
+
     def test_coalescing_mul(self):
-        # won't test all operations, but at least check a second one
+        # won't test all symmetric operations, but at least check a second one
         ops = '''
-        [i0, i1, i2, i3]
+        [i0, i1, i3]
         i7 = int_mul(i0, i1)
         i8 = int_mul(i7, i3)
         i9 = call_i(ConstClass(f1ptr), i8, descr=f1_calldescr)
@@ -170,7 +184,7 @@
         guard_true(i10) []
         finish(i9)
         '''
-        self.interpret(ops, [5, 6, 7, 8])
+        self.interpret(ops, [5, 6, 8])
         assert len(self.filter_log_moves()) == 2
 
     def test_lshift(self):


More information about the pypy-commit mailing list