digitalmars.D.bugs - [Issue 4380] New: Poor optimisation of x*x, where x is real
- d-bugmail puremagic.com (35/35) Jun 24 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4380
- d-bugmail puremagic.com (8/8) Jun 24 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4380
- d-bugmail puremagic.com (10/10) Aug 17 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4380
- d-bugmail puremagic.com (30/30) Aug 17 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4380
http://d.puremagic.com/issues/show_bug.cgi?id=4380 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 AssignedTo: nobody puremagic.com ReportedBy: clugdbug yahoo.com.au // TEST CASE 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: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 24 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4380 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 24 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4380 hsteoh quickfur.ath.cx changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hsteoh quickfur.ath.cx This is still happening on git HEAD. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 17 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4380 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yebblies gmail.com In cg87, line 1661 (load87) it has this code: if ((ty == TYldouble || ty == TYildouble) && op != -1 && e->Eoper != OPd_ld) goto Ldefault; op is 0 here (OPvar), and ty == TYldouble, so all the normal var cse checking is skipped. Down at 1887, we have #if 1 /* Do this instead of codelem() to avoid the freenode(e). We also lose CSE capability */ if (e->Eoper == OPconst) { c = load87(e, 0, &retregs, NULL, -1); } else c = (*cdxxx[e->Eoper])(e,&retregs); #else c = codelem(e,&retregs,FALSE); #endif So it looks like this was intentional to avoid some kind of compiler internal bug. Removing both conditions results in the correct code, but who knows what else it breaks. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 17 2013