Inherent code performance advantages of D over C?

deadalnix deadalnix at gmail.com
Fri Dec 6 16:09:24 PST 2013


On Friday, 6 December 2013 at 23:59:46 UTC, H. S. Teoh wrote:
> 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

LLVM is also able to generate Duff's device on the fly for loops 
where it make sense.


More information about the Digitalmars-d mailing list