Inherent code performance advantages of D over C?

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Dec 6 15:58:15 PST 2013


On Sat, Dec 07, 2013 at 12:40:35AM +0100, bearophile wrote:
[...]
> Regarding Java performance matters, from my experience another
> significant source of optimization in the JavaVM that is often
> overlooked is that the JavaVM is able to partially unroll even loops
> with a statically-unknown number of cycles. Currently I think
> GCC/DMD/LDC2 are not able or willing to do this.
[...]

Really? I've seen gcc/gdc unroll loops with unknown number of
iterations, esp. when you're using -O3. It just unrolls into something
like:

	loop_start:
		if (!loopCondition) goto end;
		loopBody();
		if (!loopCondition) goto end;
		loopBody();
		if (!loopCondition) goto end;
		loopBody();
		if (!loopCondition) goto end;
		loopBody();
		goto loop_start;
	end:	...

I'm pretty sure I've seen gcc/gdc do this before.


T

-- 
Windows 95 was a joke, and Windows 98 was the punchline.


More information about the Digitalmars-d mailing list