한다고 가정 내가 가진 :곱하기
double f(const double *r) {
return 0*(r[0]*r[1]);
}
경우 값이 INF 또는 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
는 없습니까?
아하 :
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
괜찮 았어,'-phast-math'로 펑키 수학을 강제해야만했다. – Anycorn
그것은 NaN이 아니다. IEEE 754에서'0.0 * x'의 결과는'x'의 부호에 의존합니다. –
@R .. 감사합니다. 이것은 나를 위해 정말로 중요한 정보입니다. – Anycorn