digitalmars.D.bugs - [Issue 4383] New: Optimizer doesn't keep floating point values on the stack if used more than once
- d-bugmail puremagic.com (38/38) Jun 24 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4383
- d-bugmail puremagic.com (8/8) Jun 24 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4383
- d-bugmail puremagic.com (11/11) Jun 24 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4383
- d-bugmail puremagic.com (11/13) Jun 24 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4383
- d-bugmail puremagic.com (9/18) Jun 25 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4383
- d-bugmail puremagic.com (8/24) Jun 25 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4383
- d-bugmail puremagic.com (7/13) Jun 26 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4383
http://d.puremagic.com/issues/show_bug.cgi?id=4383 Summary: Optimizer doesn't keep floating point values on the stack if used more than once Product: D Version: D1 & D2 Platform: Other OS/Version: All Status: NEW Keywords: performance Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: clugdbug yahoo.com.au Consider this example code. int main(string[] args) { real x = args.length == 2 ? 6.0 : 4.0; // just to defeat the optimiser // real y = x * 2; // (1) real y = x + x; // (2) return cast(int)y; } ------------------ After the first line, x is in ST(0). Here's how the compiler calculates y. Case (1) y = x * 2 fadd ST(0),ST Case (2) y = x + x fstp tbyte ptr [ESP] // store x fld tbyte ptr [ESP] // load x fld tbyte ptr [ESP] // load x again faddp ST(1),ST It's very interesting that in the first case, the compiler is able to eliminate the store of x, yet it doesn't do it in the second case. The compiler's inability to do this is the primary cause of DMD's poor floating point performance. -- 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=4383 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=4383 BCS <shro8822 vandals.uidaho.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |shro8822 vandals.uidaho.edu --- Sounds like a prime case for a keyhole optimization. Does DMD have the infrastructure in place to do that? -- 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=4383Sounds like a prime case for a keyhole optimization. Does DMD have the infrastructure in place to do that?Yes, there's pinholeopt() in cod3.c. But this optimisation should be done earlier. Although it seems as though you could replace: fstp XXX; fld XXX; with fst XXX; there's unfortunately no fst instruction for 80-bit reals, and for doubles and floats it can change the rounding. -- 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=4383 ---Agreed, but (done wrong now) + (done right later) > (done right later)Sounds like a prime case for a keyhole optimization. Does DMD have the infrastructure in place to do that?Yes, there's pinholeopt() in cod3.c. But this optimisation should be done earlier.Although it seems as though you could replace: fstp XXX; fld XXX; with fst XXX; there's unfortunately no fst instruction for 80-bit reals, and for doubles and floats it can change the rounding.I was primarily thinking of removing total nop cases (store+load+never used again). Also you could include a speed/accuracy trade-off flag. Or not. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 25 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4383That's why it needs to be done earlier. pinhole doesn't know if values are used again. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------Agreed, but (done wrong now) + (done right later) > (done right later)Sounds like a prime case for a keyhole optimization. Does DMD have the infrastructure in place to do that?Yes, there's pinholeopt() in cod3.c. But this optimisation should be done earlier.Although it seems as though you could replace: fstp XXX; fld XXX; with fst XXX; there's unfortunately no fst instruction for 80-bit reals, and for doubles and floats it can change the rounding.I was primarily thinking of removing total nop cases (store+load+never used again).
Jun 25 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4383 ---So a pinhole optimizer doesn't see enough. Got it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------I was primarily thinking of removing total nop cases (store+load+never used again).That's why it needs to be done earlier. pinhole doesn't know if values are used again.
Jun 26 2010