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: nob...@puremagic.com ReportedBy: clugd...@yahoo.com.au --- Comment #0 from Don <clugd...@yahoo.com.au> 2010-06-24 05:51:03 PDT --- 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: -------