[Issue 2905] New: [PATCH] Faster +-*/ involving a floating-pointing literal

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 27 05:56:08 PDT 2009


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

           Summary: [PATCH] Faster +-*/ involving a floating-pointing
                    literal
           Product: D
           Version: 2.029
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: patch, performance
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: clugdbug at yahoo.com.au


The front-end converts all floating-point literals into 80-bit real values, if
they are specified either (1) with an L suffix, or (2) they are involved in an
operation with a 'real'. It does this _even if the number could be represented
as a double without loss of precision_. Unfortunately, the x87 can only do
fused load-and-multiply, load-and-add, etc of float and double operands, so
mixed-precision operations are a bit slower than they could be.

So, something like "x + 3.0" (where x is real), becomes:
static real THREE=3.0;
fld real ptr THREE;
faddp ST(1), ST;

and with this patch it becomes:
static double THREE=3.0;
fadd ST, double ptr THREE;

The patch is only applied in the case of +,-,*,/, so that something like
printf("%Lg", 2.0L);
will continue to work correctly.

The patch also includes the patch for 2888; they are very closely related.


-- 



More information about the Digitalmars-d-bugs mailing list