From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2078) id 9F2803858D32; Mon, 26 Dec 2022 01:12:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9F2803858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672017141; bh=SxmvQsDK3vzxdgEYL7DvPcZZ0gygG7dFbBAC/D8N64A=; h=From:To:Subject:Date:From; b=LLtOUyj8NeLH5Ylmtb/sn+a0Pwwam41Ha92WG7TIKsOfXOG3cvn4J6/D17HOfI6QK //8VkgUJYisIbqqHSTEmE79Me3j9yXlZFtl1+iZdebc/bth7YHF/ortgdimjO4QdKq 9UOpizSMBnNUincSsDK9fBnwlijgvxdw9zBlubVw= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: hongtao Liu To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4891] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. X-Act-Checkin: gcc X-Git-Author: liuhongt X-Git-Refname: refs/heads/master X-Git-Oldrev: bc38aee755ddd50496f9a1d517a9cdd86301967d X-Git-Newrev: e54375d85d4aa5889869c2672158083b2106b623 Message-Id: <20221226011221.9F2803858D32@sourceware.org> Date: Mon, 26 Dec 2022 01:12:21 +0000 (GMT) List-Id: https://gcc.gnu.org/g:e54375d85d4aa5889869c2672158083b2106b623 commit r13-4891-ge54375d85d4aa5889869c2672158083b2106b623 Author: liuhongt Date: Mon Dec 12 15:43:58 2022 +0800 x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. if (mdaz-ftz) link crtfastmath.o else if ((Ofast || ffast-math || funsafe-math-optimizations) && !shared && !mno-daz-ftz) link crtfastmath.o else Don't link crtfastmath.o gcc/ChangeLog: PR target/55522 PR target/36821 * config/i386/gnu-user-common.h (GNU_USER_TARGET_MATHFILE_SPEC): Link crtfastmath.o whenever -mdaz-ftz is specified. Don't link crtfastmath.o when -share or -mno-daz-ftz is specified. * config/i386/i386.opt (mdaz-ftz): New option. * doc/invoke.texi (x86 options): Document mftz-daz. Diff: --- gcc/config/i386/gnu-user-common.h | 2 +- gcc/config/i386/i386.opt | 4 ++++ gcc/doc/invoke.texi | 12 +++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gcc/config/i386/gnu-user-common.h b/gcc/config/i386/gnu-user-common.h index 9910cd64363..f910524a6c3 100644 --- a/gcc/config/i386/gnu-user-common.h +++ b/gcc/config/i386/gnu-user-common.h @@ -47,7 +47,7 @@ along with GCC; see the file COPYING3. If not see /* Similar to standard GNU userspace, but adding -ffast-math support. */ #define GNU_USER_TARGET_MATHFILE_SPEC \ - "%{Ofast|ffast-math|funsafe-math-optimizations:%{!shared:crtfastmath.o%s}} \ + "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!shared:%{!mno-daz-ftz:crtfastmath.o%s}}} \ %{mpc32:crtprec32.o%s} \ %{mpc64:crtprec64.o%s} \ %{mpc80:crtprec80.o%s}" diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt index fb4e57ada7c..0b7df429734 100644 --- a/gcc/config/i386/i386.opt +++ b/gcc/config/i386/i386.opt @@ -420,6 +420,10 @@ mpc80 Target RejectNegative Set 80387 floating-point precision to 80-bit. +mdaz-ftz +Target +Set the FTZ and DAZ Flags. + mpreferred-stack-boundary= Target RejectNegative Joined UInteger Var(ix86_preferred_stack_boundary_arg) Attempt to keep stack aligned to this power of 2. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index da9ad1068fb..0bbf709e0e9 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1433,7 +1433,7 @@ See RS/6000 and PowerPC Options. -m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128 @gol -mregparm=@var{num} -msseregparm @gol -mveclibabi=@var{type} -mvect8-ret-in-mem @gol --mpc32 -mpc64 -mpc80 -mstackrealign @gol +-mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign @gol -momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs @gol -mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode} @gol -m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num} @gol @@ -32793,6 +32793,16 @@ are enabled by default; routines in such libraries could suffer significant loss of accuracy, typically through so-called ``catastrophic cancellation'', when this option is used to set the precision to less than extended precision. +@item -mdaz-ftz +@opindex mdaz-ftz + +The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register +are used to control floating-point calculations.SSE and AVX instructions +including scalar and vector instructions could benefit from enabling the FTZ +and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags +when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz} +will set FTZ/DAZ flags even with @option{-shared}. + @item -mstackrealign @opindex mstackrealign Realign the stack at entry. On the x86, the @option{-mstackrealign}