Summary: Poor optimisation of x*x, where x is real
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: performance
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Don <> 2010-06-24 03:02:44 PDT ---
int main(string[] args) {
    real x = args.length == 2 ? 6.0 : 4.0; // just to defeat the optimiser
    real y = x*x;
    return cast(int)y;  

With double x, produces:
                fstp    qword ptr [ESP] // store x
                fld     qword ptr [ESP]
                fmul    ST,ST(0)
Does the same for float x.

With real x, produces                
                fstp    tbyte ptr [ESP] // store x
                fld     tbyte ptr [ESP]
                fld     tbyte ptr [ESP] // Why is it loading this twice???
                fmulp   ST(1),ST

The last two lines should just be fmul ST, ST(0)

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to