New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[linux vs macos] fails to inline sqrt #3591
Comments
On Mac OS/X, llvm-gcc inlines the call to sqrtd because the mac defaults to -fno-math-errno. |
On the mac, using: Produces: This is substantially better than using the fpstack version of sqrt. 64-bit is even cleaner because of lack of stack traffic: _test: -Chris |
With this patch: This issue only impacts people who explicitly use -fmath-errno. |
This looks to be resolved?
|
I can't tell exactly what the problem was from the description, but yes, this seems fixed 13+ years later. :) |
Extended Description
On this program:
#include <math.h>
double foo(double X) { return sqrt(X); }
GCC will inline the fast path (non-negative X) and produce this:
foo:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
fldl 8(%ebp)
fld %st(0)
fsqrt
fucomi %st(0), %st
jp .L7
je .L8
fstp %st(0)
jmp .L5
.L7:
fstp %st(0)
.p2align 4,,7
.p2align 3
.L5:
fstpl (%esp)
.p2align 4,,5
.p2align 3
call sqrt
.p2align 4,,2
.p2align 3
jmp .L2
.p2align 4,,7
.p2align 3
.L8:
fstp %st(1)
.L2:
leave
.p2align 4,,1
.p2align 3
ret
The text was updated successfully, but these errors were encountered: