From nobody Tue Jun 28 13:43:58 2022 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2B150875EA5 for ; Tue, 28 Jun 2022 13:43:59 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LXQmZ5w85z4Sj3 for ; Tue, 28 Jun 2022 13:43:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AAFBF1E284 for ; Tue, 28 Jun 2022 13:43:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 25SDhwJ4047675 for ; Tue, 28 Jun 2022 13:43:58 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 25SDhwWm047674 for bugs@FreeBSD.org; Tue, 28 Jun 2022 13:43:58 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 264941] gcc9 and optimize options and inline-assembler and pointer assignment Date: Tue, 28 Jun 2022 13:43:58 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: gnu X-Bugzilla-Version: 11.4-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: var@schellong.biz X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656423838; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=B2xiXzsH/9FpCVuilu0vb90Q09pwVfOiq1AtPJQ95QY=; b=LyBwFJ6d37SVK0qq3EBMWgEyJ/2qrgjtCQ9p2lqP5MTgksZvfafxHM0QmDVn0Lc97QgP7r xYtcqVOBJOpD0NO5p6aBgfVvaFj/e/a2lpG6l/jIM7txmPoIoziF/9aiESs8lguYXfrYuU //WtiU1X+xLCXrIWAp6uTJtt8ACZj28wIKQnHCA3iWn9o1DBGdXV3/Wa3km7B8vcUgYYiC GMC8DRd6320g0YsJGD0cjK/WH0XVqvMvmKqHRexODC506ivRsQXKsEgetYjAf7lVJUmje6 YIxz/5wfU3Bb7ksBcmvZOWHzvbOJWIJOQjBMcDDxCIXXISqomcXYbb2/ng699g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656423838; a=rsa-sha256; cv=none; b=u61b/WSoCLoAKwvCk2Y4Fy8XgOUQ2Hfq5ocWN0ZCzTzZBNUYPHeWUy4z114R8msR3hSJkt vg90hpFKHD8Xm7KRzRelPgR99LLI+FVDJfGLt0SOAGqO/O7VmLJASbUTtCuTTZ0h8/Z4TD jAFgsSAfHUV+Fe3fXFJ3V9zU1EbE7BPxdS5o70cz1nJMe3EINSmgSg/HTfGvEWCNBFMRYr iuErsGAkh8lwLf4/rcKweFND97IWnlYBXPIqOPGxBZaEZ2bTkm89H0F/3nKTBguS/RNOb6 MB/GmvnXPuFUCTu3OWVwSG3//0J53Kl4EDI5ohQX0z8G31deUtBHFWlZO8YVpQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D264941 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: bugs@FreeBSD.org Reporter: var@schellong.biz 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=3D &ld; if (!deg) deg=3D &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]"=3Dm"(r), [rad]"=3Dm"(*rad), [deg]"=3Dm"(*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=3D &ld; testq %rdi, %rdi # rad je .L28 #, # asm87c.c:429: if (!deg) deg=3D &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)=20 fmul %st(0), %st(0)=20 fld %st(1)=20 fmul %st(0), %st(0)=20 faddp=20 fsqrt=20 fstpt -24(%rsp) # r fpatan=20 fldz=20 fcomip %st(1), %st(0)=20 jbe CTPp=20 fldpi=20 fldpi=20 faddp=20 faddp=20 CTPp: fld %st(0)=20 fstpt (%rdi) # *rad_3(D) fldt radtodeg(%rip) # radtodeg fmulp=20 fstpt (%rsi) # *deg_4(D) fwait=20 # 0 "" 2 # asm87c.c:459: return r; #NO_APP fldt -24(%rsp) # r ret=20=20=20=20=20 .p2align 2 .L28: # asm87c.c:428: if (!rad) rad=3D &ld; leaq -40(%rsp), %rdi #, rad # asm87c.c:429: if (!deg) deg=3D &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)=20 fmul %st(0), %st(0)=20 fld %st(1)=20 fmul %st(0), %st(0)=20 faddp=20 fsqrt=20 fstpt -24(%rsp) # r fpatan=20 fldz=20 fcomip %st(1), %st(0)=20 jbe CTPp=20 fldpi=20 fldpi=20 faddp=20 faddp=20 CTPp: fld %st(0)=20 fstpt (%rdi) # *rad_16 fldt radtodeg(%rip) # radtodeg fmulp=20 fstpt (%rsi) # *deg_2 fwait=20 # 0 "" 2 # asm87c.c:459: return r; #NO_APP fldt -24(%rsp) # r # asm87c.c:460: } ret=20=20=20=20=20 .p2align 2 .L32: # asm87c.c:429: if (!deg) deg=3D &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 '=3D &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!=3D'r' && dor!=3D'R') degrad*=3D degtorad; long double y, ld; if (!x) x=3D &ld; __asm__ ("\n\t" // ....... ---------------------------------------------------------------------------= -- With options -O0 and -Os there is no doubling. Clang doubles not. I mean __asm__(...); should never be doubled --> assembler. --=20 You are receiving this mail because: You are the assignee for the bug.=