Supongamos que tengo:0 optimización
double f(const double *r) {
return 0*(r[0]*r[1]);
}
debe compilador capaz de optimizar el segmento, o lo hace todavía tiene que realizar la operación, en caso de que los valores podrían ser inf o nan?
gcc -O3 -S test.c:
.file "test.c"
.text
.p2align 4,,15
.globl f
.type f, @function
f:
.LFB0:
.cfi_startproc
movsd (%rdi), %xmm0
mulsd 8(%rdi), %xmm0
mulsd .LC0(%rip), %xmm0
ret
.cfi_endproc
.LFE0:
.size f, .-f
.section .rodata.cst8,"aM",@progbits,8
.align 8
.LC0:
.long 0
.long 0
.ident "GCC: (Ubuntu 4.4.3-4ubuntu5) 4.4.3"
.section .note.GNU-stack,"",@progbits
parece no eliminación?
AHA:
gcc -O3 -ffast-math -S test.c
.file "test.c"
.text
.p2align 4,,15
.globl f
.type f, @function
f:
.LFB0:
.cfi_startproc
xorpd %xmm0, %xmm0
ret
.cfi_endproc
.LFE0:
.size f, .-f
.ident "GCC: (Ubuntu 4.4.3-4ubuntu5) 4.4.3"
.section .note.GNU-stack,"",@progbits
ok, tuve que forzar funky math con '-ffast-math' – Anycorn
No es solo' NaN'. En IEEE 754, el resultado de '0.0 * x' depende del signo de' x'. –
@R .. gracias. esta es información realmente importante para mí. – Anycorn