aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Friedrich Bolz-Tereick <cfbolz@gmx.de>2021-01-31 20:49:09 +0100
committerCarl Friedrich Bolz-Tereick <cfbolz@gmx.de>2021-01-31 20:49:09 +0100
commit805e9fcd6c03542901bf0423afd29e2f4207bd6e (patch)
treeb760b91d18964b1d9c5d94e6fda0af6bd0aca57e /rpython
parentmerge branch to improve PyModule* (diff)
downloadpypy-805e9fcd6c03542901bf0423afd29e2f4207bd6e.tar.gz
pypy-805e9fcd6c03542901bf0423afd29e2f4207bd6e.tar.bz2
pypy-805e9fcd6c03542901bf0423afd29e2f4207bd6e.zip
optimize chains of longlong2float(float2longlong(x)) and vice versa
Diffstat (limited to 'rpython')
-rw-r--r--rpython/jit/metainterp/optimizeopt/rewrite.py8
-rw-r--r--rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py22
2 files changed, 30 insertions, 0 deletions
diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py b/rpython/jit/metainterp/optimizeopt/rewrite.py
index fc4cb8fa37..7024e51ad5 100644
--- a/rpython/jit/metainterp/optimizeopt/rewrite.py
+++ b/rpython/jit/metainterp/optimizeopt/rewrite.py
@@ -917,6 +917,14 @@ class OptRewrite(Optimization):
self.optimizer.pure_from_args(rop.CAST_PTR_TO_INT, [op], op.getarg(0))
return self.emit(op)
+ def optimize_CONVERT_FLOAT_BYTES_TO_LONGLONG(self, op):
+ self.optimizer.pure_from_args(rop.CONVERT_LONGLONG_BYTES_TO_FLOAT, [op], op.getarg(0))
+ return self.emit(op)
+
+ def optimize_CONVERT_LONGLONG_BYTES_TO_FLOAT(self, op):
+ self.optimizer.pure_from_args(rop.CONVERT_FLOAT_BYTES_TO_LONGLONG, [op], op.getarg(0))
+ return self.emit(op)
+
def optimize_SAME_AS_I(self, op):
self.make_equal_to(op, op.getarg(0))
optimize_SAME_AS_R = optimize_SAME_AS_I
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
index 8f1ce2bfb0..4daf55065d 100644
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -6303,3 +6303,25 @@ class TestOptimizeBasic(BaseTestBasic):
i57 = int_or(i51, i52)
"""
self.optimize_loop(ops, expected)
+
+ def test_convert_float_bytes_to_longlong(self):
+ ops = """
+ [f0, i0]
+ i1 = convert_float_bytes_to_longlong(f0)
+ f1 = convert_longlong_bytes_to_float(i1)
+ escape_f(f1)
+
+ f2 = convert_longlong_bytes_to_float(i0)
+ i2 = convert_float_bytes_to_longlong(f2)
+ escape_i(i2)
+ """
+
+ expected = """
+ [f0, i0]
+ i1 = convert_float_bytes_to_longlong(f0)
+ escape_f(f0)
+
+ f2 = convert_longlong_bytes_to_float(i0)
+ escape_i(i0)
+ """
+ self.optimize_loop(ops, expected)