http://d.puremagic.com/issues/show_bug.cgi?id=2905





--- Comment #6 from Don <clugd...@yahoo.com.au>  2009-07-10 07:37:23 PDT ---
Revised patch against DMD2.031, which fixes the problem, and optimises a larger
number of cases. This patch significantly improves performance of
floating-point operations involving reals.
----

Index: cg87.c
===================================================================
--- cg87.c    (revision 192)
+++ cg87.c    (working copy)
@@ -914,7 +914,8 @@
     case X(OPadd, TYdouble, TYdouble):
     case X(OPadd, TYdouble_alias, TYdouble_alias):
     case X(OPadd, TYldouble, TYldouble):
-//    case X(OPadd, TYldouble, TYdouble):
+    case X(OPadd, TYldouble, TYdouble):
+    case X(OPadd, TYdouble, TYldouble):
     case X(OPadd, TYifloat, TYifloat):
     case X(OPadd, TYidouble, TYidouble):
     case X(OPadd, TYildouble, TYildouble):
@@ -925,8 +926,8 @@
     case X(OPmin, TYdouble, TYdouble):
     case X(OPmin, TYdouble_alias, TYdouble_alias):
     case X(OPmin, TYldouble, TYldouble):
-//    case X(OPmin, TYldouble, TYdouble):
-//    case X(OPmin, TYdouble, TYldouble):
+    case X(OPmin, TYldouble, TYdouble):
+    case X(OPmin, TYdouble, TYldouble):
     case X(OPmin, TYifloat, TYifloat):
     case X(OPmin, TYidouble, TYidouble):
     case X(OPmin, TYildouble, TYildouble):
@@ -937,7 +938,8 @@
     case X(OPmul, TYdouble, TYdouble):
     case X(OPmul, TYdouble_alias, TYdouble_alias):
     case X(OPmul, TYldouble, TYldouble):
-//    case X(OPmul, TYldouble, TYdouble):
+    case X(OPmul, TYldouble, TYdouble):
+    case X(OPmul, TYdouble, TYldouble):
     case X(OPmul, TYifloat, TYifloat):
     case X(OPmul, TYidouble, TYidouble):
     case X(OPmul, TYildouble, TYildouble):
@@ -954,8 +956,8 @@
     case X(OPdiv, TYdouble, TYdouble):
     case X(OPdiv, TYdouble_alias, TYdouble_alias):
     case X(OPdiv, TYldouble, TYldouble):
-//    case X(OPdiv, TYldouble, TYdouble):
-//    case X(OPdiv, TYdouble, TYldouble):
+    case X(OPdiv, TYldouble, TYdouble):
+    case X(OPdiv, TYdouble, TYldouble):
     case X(OPdiv, TYifloat, TYifloat):
     case X(OPdiv, TYidouble, TYidouble):
     case X(OPdiv, TYildouble, TYildouble):
@@ -1364,7 +1366,12 @@
     #undef X

     e2oper = e2->Eoper;
-    if (e1->Eoper == OPconst ||
+    // Move double-sized operand into the second position if there's a chance
it will allow
+    // combining a load with an operation (DMD Bugzilla 2905)
+    if ( ((tybasic(e1->Ety)==TYdouble)
+          && ((e1->Eoper==OPvar) || (e1->Eoper==OPconst))
+          && (tybasic(e2->Ety) != TYdouble))
+    || (e1->Eoper == OPconst ) ||
     (e1->Eoper == OPvar &&
      ((e1->Ety & (mTYconst | mTYimmutable) && !OTleaf(e2oper)) ||
       (e2oper == OPd_f &&
Index: el.c
===================================================================
--- el.c    (revision 192)
+++ el.c    (working copy)
@@ -2052,7 +2052,6 @@
  * operations, since then it could change the type (eg, in the function call
  * printf("%La", 2.0L); the 2.0 must stay as a long double).
  */
-#if 0
 void shrinkLongDoubleConstantIfPossible(elem *e)
 {
     if (e->Eoper == OPconst && e->Ety == TYldouble)
@@ -2072,7 +2071,6 @@
     }
     }
 }
-#endif


 /*************************
@@ -2115,7 +2113,7 @@
          */
         break;
         }
-#if 0
+
     case OPdiv:
     case OPadd:
     case OPmin:
@@ -2125,7 +2123,6 @@
         if (tyreal(e->Ety))
         shrinkLongDoubleConstantIfPossible(e->E2);
         // fall through...
-#endif
     default:
         if (OTbinary(op))
         {

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to