https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=264941
Bug ID: 264941
Summary: gcc9 and optimize options and inline-assembler and
pointer assignment
Product: Base System
Version: 11.4-RELEASE
Hardware: Any
OS: Any
Status: New
Severity: Affects Some People
Priority: ---
Component: gnu
Assignee: [email protected]
Reporter: [email protected]
C-Source with extended inline-assembler:
-----------------------------------------------------------------------------
STaTIc long double ctop87l(long double x, long double y,
long double *rad, long double *deg)
{
long double r, ld;
if (!rad) rad= &ld;
if (!deg) deg= &ld;
__asm__ ("\n\t"
"fldt %[y] \n\t"
"fldt %[x] \n\t"
"fld %%st(1) \n\t"
"fmul %%st(0), %%st(0) \n\t"
"fld %%st(1) \n\t"
"fmul %%st(0), %%st(0) \n\t"
"faddp \n\t"
"fsqrt \n\t"
"fstpt %[r] \n\t"
"fpatan \n\t"
"fldz \n\t"
"fcomip %%st(1), %%st(0) \n\t"
"jbe CTPp \n\t"
"fldpi \n\t"
"fldpi \n\t"
"faddp \n\t"
"faddp \n\t"
"CTPp:\n\t"
"fld %%st(0) \n\t"
"fstpt %[rad] \n\t"
"fldt %[rtd] \n\t"
"fmulp \n\t"
"fstpt %[deg] \n\t"
"fwait \n\t"
: [r]"=m"(r), [rad]"=m"(*rad), [deg]"=m"(*deg)
: [x]"m"(x), [y]"m"(y), [rtd]"m"(radtodeg)
:
);
return r;
}
-----------------------------------------------------------------------------
Output of gcc9 (with -O1): Gcc -S asm87c.c
-----------------------------------------------------------------------------
.globl ctop87l
.type ctop87l, @function
ctop87l:
.LFB18:
.cfi_startproc
# asm87c.c:428: if (!rad) rad= &ld;
testq %rdi, %rdi # rad
je .L28 #,
# asm87c.c:429: if (!deg) deg= &ld;
testq %rsi, %rsi # deg
je .L30 #,
# asm87c.c:430: __asm__ ("\n\t"
#APP
# 430 "asm87c.c" 1
fldt 24(%rsp) # y
fldt 8(%rsp) # x
fld %st(1)
fmul %st(0), %st(0)
fld %st(1)
fmul %st(0), %st(0)
faddp
fsqrt
fstpt -24(%rsp) # r
fpatan
fldz
fcomip %st(1), %st(0)
jbe CTPp
fldpi
fldpi
faddp
faddp
CTPp:
fld %st(0)
fstpt (%rdi) # *rad_3(D)
fldt radtodeg(%rip) # radtodeg
fmulp
fstpt (%rsi) # *deg_4(D)
fwait
# 0 "" 2
# asm87c.c:459: return r;
#NO_APP
fldt -24(%rsp) # r
ret
.p2align 2
.L28:
# asm87c.c:428: if (!rad) rad= &ld;
leaq -40(%rsp), %rdi #, rad
# asm87c.c:429: if (!deg) deg= &ld;
testq %rsi, %rsi # deg
je .L32 #,
.L29:
# asm87c.c:430: __asm__ ("\n\t"
#APP
# 430 "asm87c.c" 1
fldt 24(%rsp) # y
fldt 8(%rsp) # x
fld %st(1)
fmul %st(0), %st(0)
fld %st(1)
fmul %st(0), %st(0)
faddp
fsqrt
fstpt -24(%rsp) # r
fpatan
fldz
fcomip %st(1), %st(0)
jbe CTPp
fldpi
fldpi
faddp
faddp
CTPp:
fld %st(0)
fstpt (%rdi) # *rad_16
fldt radtodeg(%rip) # radtodeg
fmulp
fstpt (%rsi) # *deg_2
fwait
# 0 "" 2
# asm87c.c:459: return r;
#NO_APP
fldt -24(%rsp) # r
# asm87c.c:460: }
ret
.p2align 2
.L32:
# asm87c.c:429: if (!deg) deg= &ld;
movq %rdi, %rsi # rad, deg
jmp .L29 #
.p2align 2
.L30:
leaq -40(%rsp), %rsi #, deg
jmp .L29 #
.cfi_endproc
.LFE18:
.size ctop87l, .-ctop87l
-----------------------------------------------------------------------------
The code '__asm__ (...);' is doubled!
Therefore 'CTPp:' is doubled, and this is an error.
The reason for this doubling are each of the two lines with '= &ld' above
__asm__.
Without these two lines there is no doubling.
IMO a curiosity.
A doubling too, but without jump-label (no error):
-----------------------------------------------------------------------------
STaTIc long double ptoc87l(int dor, long double degrad, long double r, long
double *x)
{
if (dor!='r' && dor!='R') degrad*= degtorad;
long double y, ld;
if (!x) x= &ld;
__asm__ ("\n\t"
// .......
-----------------------------------------------------------------------------
With options -O0 and -Os there is no doubling.
Clang doubles not.
I mean __asm__(...); should never be doubled --> assembler.
--
You are receiving this mail because:
You are the assignee for the bug.