[pypy-svn] r17532 - in pypy/dist/pypy/translator: . backendopt backendopt/test

arigo at codespeak.net arigo at codespeak.net
Tue Sep 13 18:13:19 CEST 2005


Author: arigo
Date: Tue Sep 13 18:13:18 2005
New Revision: 17532

Modified:
   pypy/dist/pypy/translator/backendopt/all.py
   pypy/dist/pypy/translator/backendopt/malloc.py
   pypy/dist/pypy/translator/backendopt/test/test_all.py
   pypy/dist/pypy/translator/backendopt/test/test_malloc.py
   pypy/dist/pypy/translator/simplify.py
Log:
* Enable inlining and malloc removal in backend_optimizations():
  all the C tests pass now.

* test_malloc.test_fn1 wasn't testing anything -- fixed.


Modified: pypy/dist/pypy/translator/backendopt/all.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/all.py	(original)
+++ pypy/dist/pypy/translator/backendopt/all.py	Tue Sep 13 18:13:18 2005
@@ -12,13 +12,12 @@
         remove_same_as(graph)
         simplify.eliminate_empty_blocks(graph)
 
-    # inline functions around
-    if inline_threshold and 0:  # XXX in progress
+    # inline functions in each other
+    if inline_threshold:
         auto_inlining(translator, inline_threshold)
 
     # vaporize mallocs
-    # XXX in progress
-    for graph in []:# translator.flowgraphs.values():
+    for graph in translator.flowgraphs.values():
         if remove_simple_mallocs(graph):
             # remove typical leftovers from malloc removal
             remove_same_as(graph)

Modified: pypy/dist/pypy/translator/backendopt/malloc.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/malloc.py	(original)
+++ pypy/dist/pypy/translator/backendopt/malloc.py	Tue Sep 13 18:13:18 2005
@@ -214,5 +214,6 @@
     """Iteratively remove (inline) the mallocs that can be simplified away."""
     done_something = False
     while remove_mallocs_once(graph):
+        print 'simple mallocs removed in %r' % graph.name
         done_something = True
     return done_something

Modified: pypy/dist/pypy/translator/backendopt/test/test_all.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/test/test_all.py	(original)
+++ pypy/dist/pypy/translator/backendopt/test/test_all.py	Tue Sep 13 18:13:18 2005
@@ -37,7 +37,6 @@
 
 
 def test_big():
-    py.test.skip("in progress")
     assert big() == 83
 
     t = Translator(big)
@@ -45,7 +44,6 @@
     t.specialize()
     backend_optimizations(t, inline_threshold=100)
 
-    t.view()
     graph = t.getflowgraph()
     check_malloc_removed(graph)
 

Modified: pypy/dist/pypy/translator/backendopt/test/test_malloc.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/test/test_malloc.py	(original)
+++ pypy/dist/pypy/translator/backendopt/test/test_malloc.py	Tue Sep 13 18:13:18 2005
@@ -31,7 +31,11 @@
 
 def test_fn1():
     def fn1(x, y):
-        s, d = x+y, x-y
+        if x > 0:
+            t = x+y, x-y
+        else:
+            t = x-y, x+y
+        s, d = t
         return s*d
     check(fn1, [int, int], [15, 10], 125)
 

Modified: pypy/dist/pypy/translator/simplify.py
==============================================================================
--- pypy/dist/pypy/translator/simplify.py	(original)
+++ pypy/dist/pypy/translator/simplify.py	Tue Sep 13 18:13:18 2005
@@ -341,7 +341,7 @@
         pos neg nonzero abs hex oct ord invert add sub mul
         truediv floordiv div mod divmod pow lshift rshift and_ or_
         xor int float long lt le eq ne gt ge cmp coerce contains
-        iter get same_as cast_pointer '''.split():
+        iter get same_as cast_pointer getfield '''.split():
     CanRemove[_op] = True
 del _op
 CanRemoveBuiltins = {



More information about the Pypy-commit mailing list