On 12/31/2011 02:59 AM, so wrote:
On Sat, 31 Dec 2011 03:40:43 +0200, Iain Buclaw <[email protected]> wrote:
Take a pick of any examples posted on this ML. They are far better
fit to use as a test bed. Ideally one that does number crunching and
can't be easily folded away.
Well not them but another dummy function, i didn't think it would differ
this much.
real test() nothrow pure
real test() // test.d
real test() @inline // test_inl.d
{
real a=423123, b=432, c=10, d=100, e=4045, f=123;
a = a / b * c / d + e - f;
b = a / b * c / d + e - f;
c = a / b * c / d + e - f;
d = a / b * c / d + e - f;
e = a / b * c / d + e - f;
f = a / b * c / d + e - f;
a = a / b * c / d + e - f;
b = a / b * c / d + e - f;
c = a / b * c / d + e - f;
d = a / b * c / d + e - f;
e = a / b * c / d + e - f;
f = a / b * c / d + e - f;
a = a / b * c / d + e - f;
b = a / b * c / d + e - f;
c = a / b * c / d + e - f;
d = a / b * c / d + e - f;
e = a / b * c / d + e - f;
f = a / b * c / d + e - f;
return f;
}
void main()
{
for(uint i=0; i<1_000_000_0; ++i)
test();
}
When marking the function as pure and nothrow dmd is able to optimize
the loop:
.text._Dmain segment
assume CS:.text._Dmain
_Dmain:
push RBP
mov RBP,RSP
xor EAX,EAX
L6: inc EAX
cmp EAX,0989680h
jb L6
xor EAX,EAX
pop RBP
ret
.text._Dmain ends
--
Mike Wey