Summary: [PATCH] Faster +-*/ involving a floating-pointing
           Product: D
           Version: 2.029
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: patch, performance
          Severity: enhancement
          Priority: P2
         Component: DMD

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.


Reply via email to