[pypy-commit] pypy default: Special-case in RPython the case of "x ** 2.0".

arigo noreply at buildbot.pypy.org
Sat Jan 21 11:38:02 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r51565:c5d041657831
Date: 2012-01-21 11:37 +0100
http://bitbucket.org/pypy/pypy/changeset/c5d041657831/

Log:	Special-case in RPython the case of "x ** 2.0".

diff --git a/pypy/rpython/lltypesystem/module/ll_math.py b/pypy/rpython/lltypesystem/module/ll_math.py
--- a/pypy/rpython/lltypesystem/module/ll_math.py
+++ b/pypy/rpython/lltypesystem/module/ll_math.py
@@ -292,6 +292,10 @@
     # deal directly with IEEE specials, to cope with problems on various
     # platforms whose semantics don't exactly match C99
 
+    if y == 2.0:
+        return x * x     # this is always a correct answer, and is relatively
+                         # common in user programs.
+
     if isnan(y):
         if x == 1.0:
             return 1.0   # 1**Nan = 1


More information about the pypy-commit mailing list