Aucbvax.6857 fa.info-vax utzoo!decvax!ucbvax!info-vax Thu Apr 22 09:30:57 1982 unix cc and float registers >From dove@mit-dspg@mit-mc Thu Apr 22 09:22:29 1982 The following results were obtained from mit-vax (berkeley 4.1 I think). The adb files were taken from a.out. The only compiler switch was -O. ---junkc.c--- main() { register double z=0, x=1; register int i=100000; while(i-->0) { z += x; z += x; z += x; z += x; z += x; z += x; z += x; z += x; z += x; z += x; } } ---junkc.adb---- _main: _main: 800 3e: subl2 $10,sp 41: movd _environ+4,-8(fp) 49: movd _environ+c,-10(fp) 51: movl $186a0,r11 58: brb 8c 5a: addd2 -10(fp),-8(fp) 5f: addd2 -10(fp),-8(fp) 64: addd2 -10(fp),-8(fp) 69: addd2 -10(fp),-8(fp) 6e: addd2 -10(fp),-8(fp) 73: addd2 -10(fp),-8(fp) 78: addd2 -10(fp),-8(fp) 7d: addd2 -10(fp),-8(fp) 82: addd2 -10(fp),-8(fp) 87: addd2 -10(fp),-8(fp) 8c: movl r11,r0 8f: decl r11 91: tstl r0 93: bgtr 5a 95: ret 96: halt 97: halt _exit: ---junkp.p--- program junkp (input, output); var z, x :real; i : integer; begin z := 0; x := 1; i := 100000; while i>0 do begin z := z+x; z := z+x; z := z+x; z := z+x; z := z+x; z := z+x; z := z+x; z := z+x; z := z+x; z := z+x; i := i-1 end end. ---junkp.adb--- _program: _program: 0 66: subl2 $10,sp 69: moval _UNWIND,(fp) 70: moval __disply+8,-4(fp) 78: movq __disply+8,-c(fp) 80: movq ap,__disply+8 87: clrq _z 8d: cvtld $1,_x 94: movl $186a0,_i 9f: brb _program+b2 a1: addd2 _x,_z ac: addd2 _x,_z b7: addd2 _x,_z c2: addd2 _x,_z cd: addd2 _x,_z d8: addd2 _x,_z e3: addd2 _x,_z ee: addd2 _x,_z f9: addd2 _x,_z _program+a0: addd2 _x,_z _program+ab: subl2 $1,_i _program+b2: tstl _i _program+b8: bgtr a1 _program+ba: movq -c(fp),__disply+8 _program+c2: ret _program+c3: As you can see, registers don't get used for floating point. Here is an equivalent program with ints instead of doubles, and it does the right thing: ---junkci.c--- main() { register int z=0, x=1; register int i; for(i=0; i<100000; i++) { z += x; z += x; z += x; z += x; z += x; z += x; z += x; z += x; z += x; z += x; } } ---junkci.adb--- _main: _main: e00 3e: clrl r11 40: movl $1,r10 43: clrl r9 45: addl2 r10,r11 48: addl2 r10,r11 4b: addl2 r10,r11 4e: addl2 r10,r11 51: addl2 r10,r11 54: addl2 r10,r11 57: addl2 r10,r11 5a: addl2 r10,r11 5d: addl2 r10,r11 60: addl2 r10,r11 63: incl r9 65: cmpl r9,$186a0 6c: blss 45 6e: ret 6f: halt _exit: Comments? (when will c understand floats!)