An award is due to LDC for sunning code generation. Null points for GCC in comparison.

Cecil Ward cecil at cecilward.com
Sat Aug 1 02:48:20 UTC 2020


An award is due to LDC.

LDC deserves some kind of gold medal for optimising this to just 
a couple of mul instructions and the trimmings and no loop at 
all! Incredible job from LDC. with -O3

uint foo( in uint x ) { if (x ==0) return 0 else return x + foo( 
x - 1 );}

  Since the answer is n(n+1)/2 I’m not sure why there are two mul 
instructions.

Golden onion for GDC, does tail-end recursion but then with -O3 
-march=native -frelease it generations an evil-looking brew of 
SIMD and a loop with some unrolling. GDC just doesn’t grok the 
algorithmic intent like LDC does. I’m assuming that induction 
variable analysis is the key that gives LDC the superb win?


More information about the digitalmars-d-ldc mailing list