Re: [pure-lang-users] Proposed syntax changes
Status: Beta
Brought to you by:
agraef
From: Eddie R. <er...@bm...> - 2008-08-18 20:50:02
|
Use to be, 0.5*x produced faster code than x/2.0. Well, I was pleasantly surprised with the assembly output of "gcc -S -O2 test.c" produced exactly the same output. test.c: ------------------------------ #include <stdio.h> int main(void) { double a, b, c; printf("Enter first num:"); scanf("%g", &a); printf("Enter second num:"); scanf("%g", &b); c = a/2.0; printf("%g\n", c); c = 0.5*b; printf("%g\n", c); return 0; } ----------------------------- Portion of the assembly: ----------------------------- call scanf movsd .LC3(%rip), %xmm0 movl $.LC4, %edi movl $1, %eax mulsd 16(%rsp), %xmm0 call printf movsd .LC3(%rip), %xmm0 movl $.LC4, %edi movl $1, %eax mulsd 8(%rsp), %xmm0 call printf e.r. |