[Issue 4034] New: double-double functions seem to not pure-optimize
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Mar 31 09:45:48 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4034
Summary: double-double functions seem to not pure-optimize
Product: D
Version: future
Platform: x86
OS/Version: Windows
Status: NEW
Keywords: performance
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2010-03-31 09:45:44 PDT ---
This small D2 program calls two times a function msin that I have tagged as
pure, but in the binary there are two sin instructions, I don't understand:
import std.c.stdio: printf;
import std.c.stdlib: atof;
import std.math: sin;
pure double msin(double x) {
return sin(x);
}
void main() {
double x = atof("0.3");
double y = msin(x) + msin(x);
printf("%f\n", y);
}
Compiled with dmd v2.042:
dmd -O -release -inline bug1.d
Produces:
_D4bug14msinFNadZd:
fld qword ptr 4[ESP]
fsin
ret 8
__Dmain:
L0: sub ESP,01Ch
mov EAX,offset FLAT:_DATA
push EAX
call near ptr _atof
mov ECX,offset FLAT:_DATA[4]
fstp qword ptr 8[ESP]
fld qword ptr 8[ESP]
fsin
fld qword ptr 8[ESP]
sub ESP,8
fsin
faddp ST(1),ST
fstp qword ptr [ESP]
push ECX
call near ptr _printf
add ESP,010h
add ESP,01Ch
xor EAX,EAX
ret
Similar code is produced with this line:
double y = sin(x) + sin(x);
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list