* [PATCH] [x86] x86: Don't add crtfastmath.o for -shared and add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. @ 2022-12-14 2:18 liuhongt 2022-12-14 8:08 ` Richard Biener 0 siblings, 1 reply; 27+ messages in thread From: liuhongt @ 2022-12-14 2:18 UTC (permalink / raw) To: gcc-patches; +Cc: crazylht, hjl.tools, ubizjak Don't add crtfastmath.o for -shared to avoid changing the MXCSR register when loading a shared library. crtfastmath.o will be used only when building executables. Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. Ok for trunk? gcc/ChangeLog: PR target/55522 PR target/36821 * config/i386/gnu-user-common.h (GNU_USER_TARGET_MATHFILE_SPEC): Link crtfastmath.o when -mdaz-ftz is specified, not link it when -shared is specified. * config/i386/i386.opt (mdaz-ftz): New option. * doc/invoke.texi (x86 options): Document mftz-daz. --- gcc/config/i386/gnu-user-common.h | 2 +- gcc/config/i386/i386.opt | 4 ++++ gcc/doc/invoke.texi | 10 +++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gcc/config/i386/gnu-user-common.h b/gcc/config/i386/gnu-user-common.h index cab9be2bfb7..02e4a2192a4 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:crtfastmath.o%s} \ + "%{Ofast|ffast-math|funsafe-math-optimizations|mdaz-ftz:%{!shared: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..8fd222db857 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 RejectNegative +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 cb40b38b73a..670e3767fbd 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 @@ -32752,6 +32752,14 @@ 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. + @item -mstackrealign @opindex mstackrealign Realign the stack at entry. On the x86, the @option{-mstackrealign} -- 2.27.0 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] [x86] x86: Don't add crtfastmath.o for -shared and add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2022-12-14 2:18 [PATCH] [x86] x86: Don't add crtfastmath.o for -shared and add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR liuhongt @ 2022-12-14 8:08 ` Richard Biener 2022-12-14 8:16 ` Jakub Jelinek 0 siblings, 1 reply; 27+ messages in thread From: Richard Biener @ 2022-12-14 8:08 UTC (permalink / raw) To: liuhongt; +Cc: gcc-patches, crazylht, hjl.tools, ubizjak On Wed, Dec 14, 2022 at 3:21 AM liuhongt via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > Don't add crtfastmath.o for -shared to avoid changing the MXCSR > register when loading a shared library. crtfastmath.o will be used > only when building executables. > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > Ok for trunk? You reject negative -mdaz-ftz but wouldn't that be useful with -Ofast -mno-daz-ftz since there's otherwise no way to avoid that? Richard. > gcc/ChangeLog: > > PR target/55522 > PR target/36821 > * config/i386/gnu-user-common.h (GNU_USER_TARGET_MATHFILE_SPEC): > Link crtfastmath.o when -mdaz-ftz is specified, not link it > when -shared is specified. > * config/i386/i386.opt (mdaz-ftz): New option. > * doc/invoke.texi (x86 options): Document mftz-daz. > --- > gcc/config/i386/gnu-user-common.h | 2 +- > gcc/config/i386/i386.opt | 4 ++++ > gcc/doc/invoke.texi | 10 +++++++++- > 3 files changed, 14 insertions(+), 2 deletions(-) > > diff --git a/gcc/config/i386/gnu-user-common.h b/gcc/config/i386/gnu-user-common.h > index cab9be2bfb7..02e4a2192a4 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:crtfastmath.o%s} \ > + "%{Ofast|ffast-math|funsafe-math-optimizations|mdaz-ftz:%{!shared: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..8fd222db857 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 RejectNegative > +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 cb40b38b73a..670e3767fbd 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 > @@ -32752,6 +32752,14 @@ 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. Maybe say that the MXCSR register is set at program start to achieve this when the flag is specified at _link_ time and say this switch is ignored when -shared is specified? > + > @item -mstackrealign > @opindex mstackrealign > Realign the stack at entry. On the x86, the @option{-mstackrealign} > -- > 2.27.0 > ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] [x86] x86: Don't add crtfastmath.o for -shared and add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2022-12-14 8:08 ` Richard Biener @ 2022-12-14 8:16 ` Jakub Jelinek 2022-12-14 8:23 ` Richard Biener 0 siblings, 1 reply; 27+ messages in thread From: Jakub Jelinek @ 2022-12-14 8:16 UTC (permalink / raw) To: Richard Biener; +Cc: liuhongt, gcc-patches, crazylht, hjl.tools, ubizjak On Wed, Dec 14, 2022 at 09:08:02AM +0100, Richard Biener via Gcc-patches wrote: > On Wed, Dec 14, 2022 at 3:21 AM liuhongt via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > Don't add crtfastmath.o for -shared to avoid changing the MXCSR > > register when loading a shared library. crtfastmath.o will be used > > only when building executables. > > > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > > Ok for trunk? > > You reject negative -mdaz-ftz but wouldn't that be useful with > -Ofast -mno-daz-ftz since there's otherwise no way to avoid that? Agreed. I even wonder if the best wouldn't be to make the option effectively three state, default, no and yes, where if the option isn't specified at all, then crtfastmath.o* is linked as is now except for -shared, if it is -mno-daz-ftz, then it is never linked in regardless of other options and if it is -mdaz-ftz, then it is linked even for -shared. > > --- 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 RejectNegative > > +Set the FTZ and DAZ Flags. As the option is only used in the driver, shouldn't it be marked Driver and not Target? It doesn't need to be saved/restored on every cfun switch etc. > > +@item -mdaz-ftz > > +@opindex mdaz-ftz > > + > > +the flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register Shouldn't description start with capital letter? > > +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. > > Maybe say that the MXCSR register is set at program start to achieve > this when the > flag is specified at _link_ time and say this switch is ignored when > -shared is specified? Jakub ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] [x86] x86: Don't add crtfastmath.o for -shared and add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2022-12-14 8:16 ` Jakub Jelinek @ 2022-12-14 8:23 ` Richard Biener 2022-12-14 8:34 ` Liu, Hongtao 0 siblings, 1 reply; 27+ messages in thread From: Richard Biener @ 2022-12-14 8:23 UTC (permalink / raw) To: Jakub Jelinek; +Cc: liuhongt, gcc-patches, crazylht, hjl.tools, ubizjak On Wed, Dec 14, 2022 at 9:16 AM Jakub Jelinek <jakub@redhat.com> wrote: > > On Wed, Dec 14, 2022 at 09:08:02AM +0100, Richard Biener via Gcc-patches wrote: > > On Wed, Dec 14, 2022 at 3:21 AM liuhongt via Gcc-patches > > <gcc-patches@gcc.gnu.org> wrote: > > > > > > Don't add crtfastmath.o for -shared to avoid changing the MXCSR > > > register when loading a shared library. crtfastmath.o will be used > > > only when building executables. > > > > > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > > > Ok for trunk? > > > > You reject negative -mdaz-ftz but wouldn't that be useful with > > -Ofast -mno-daz-ftz since there's otherwise no way to avoid that? > > Agreed. > I even wonder if the best wouldn't be to make the option effectively > three state, default, no and yes, where if the option isn't specified > at all, then crtfastmath.o* is linked as is now except for -shared, > if it is -mno-daz-ftz, then it is never linked in regardless of other > options and if it is -mdaz-ftz, then it is linked even for -shared. Possibly. I'd also suggest to split the changed -shared handling to a separate patch since people may want to backport this and it should be applicable to all other targets with similar handling. > > > --- 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 RejectNegative > > > +Set the FTZ and DAZ Flags. > > As the option is only used in the driver, shouldn't it be marked Driver > and not Target? It doesn't need to be saved/restored on every cfun switch > etc. > > > > +@item -mdaz-ftz > > > +@opindex mdaz-ftz > > > + > > > +the flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register > > Shouldn't description start with capital letter? > > > > +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. > > > > Maybe say that the MXCSR register is set at program start to achieve > > this when the > > flag is specified at _link_ time and say this switch is ignored when > > -shared is specified? > > Jakub > ^ permalink raw reply [flat|nested] 27+ messages in thread
* RE: [PATCH] [x86] x86: Don't add crtfastmath.o for -shared and add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2022-12-14 8:23 ` Richard Biener @ 2022-12-14 8:34 ` Liu, Hongtao 2022-12-14 8:52 ` Richard Biener 0 siblings, 1 reply; 27+ messages in thread From: Liu, Hongtao @ 2022-12-14 8:34 UTC (permalink / raw) To: Richard Biener, Jakub Jelinek; +Cc: gcc-patches, crazylht, hjl.tools, ubizjak > -----Original Message----- > From: Richard Biener <richard.guenther@gmail.com> > Sent: Wednesday, December 14, 2022 4:23 PM > To: Jakub Jelinek <jakub@redhat.com> > Cc: Liu, Hongtao <hongtao.liu@intel.com>; gcc-patches@gcc.gnu.org; > crazylht@gmail.com; hjl.tools@gmail.com; ubizjak@gmail.com > Subject: Re: [PATCH] [x86] x86: Don't add crtfastmath.o for -shared and add a > new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. > > On Wed, Dec 14, 2022 at 9:16 AM Jakub Jelinek <jakub@redhat.com> wrote: > > > > On Wed, Dec 14, 2022 at 09:08:02AM +0100, Richard Biener via Gcc-patches > wrote: > > > On Wed, Dec 14, 2022 at 3:21 AM liuhongt via Gcc-patches > > > <gcc-patches@gcc.gnu.org> wrote: > > > > > > > > Don't add crtfastmath.o for -shared to avoid changing the MXCSR > > > > register when loading a shared library. crtfastmath.o will be > > > > used only when building executables. > > > > > > > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > > > > Ok for trunk? > > > > > > You reject negative -mdaz-ftz but wouldn't that be useful with > > > -Ofast -mno-daz-ftz since there's otherwise no way to avoid that? > > > > Agreed. > > I even wonder if the best wouldn't be to make the option effectively > > three state, default, no and yes, where if the option isn't specified > > at all, then crtfastmath.o* is linked as is now except for -shared, if > > it is -mno-daz-ftz, then it is never linked in regardless of other > > options and if it is -mdaz-ftz, then it is linked even for -shared. > > Possibly. I'd also suggest to split the changed -shared handling to a separate > patch since people may want to backport this and it should be applicable to > all other targets with similar handling. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55522#c26 So patch in the upper link is ok for trunk? I'll change -mdaz-ftz part as a separate patch. > > > > > --- 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 RejectNegative > > > > +Set the FTZ and DAZ Flags. > > > > As the option is only used in the driver, shouldn't it be marked > > Driver and not Target? It doesn't need to be saved/restored on every > > cfun switch etc. > > > > > > +@item -mdaz-ftz > > > > +@opindex mdaz-ftz > > > > + > > > > +the flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the > > > > +MXCSR register > > > > Shouldn't description start with capital letter? > > > > > > +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. > > > > > > Maybe say that the MXCSR register is set at program start to achieve > > > this when the flag is specified at _link_ time and say this switch > > > is ignored when -shared is specified? > > > > Jakub > > ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] [x86] x86: Don't add crtfastmath.o for -shared and add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2022-12-14 8:34 ` Liu, Hongtao @ 2022-12-14 8:52 ` Richard Biener 2022-12-14 9:07 ` Uros Bizjak 0 siblings, 1 reply; 27+ messages in thread From: Richard Biener @ 2022-12-14 8:52 UTC (permalink / raw) To: Liu, Hongtao; +Cc: Jakub Jelinek, gcc-patches, crazylht, hjl.tools, ubizjak On Wed, Dec 14, 2022 at 9:34 AM Liu, Hongtao <hongtao.liu@intel.com> wrote: > > > > > -----Original Message----- > > From: Richard Biener <richard.guenther@gmail.com> > > Sent: Wednesday, December 14, 2022 4:23 PM > > To: Jakub Jelinek <jakub@redhat.com> > > Cc: Liu, Hongtao <hongtao.liu@intel.com>; gcc-patches@gcc.gnu.org; > > crazylht@gmail.com; hjl.tools@gmail.com; ubizjak@gmail.com > > Subject: Re: [PATCH] [x86] x86: Don't add crtfastmath.o for -shared and add a > > new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. > > > > On Wed, Dec 14, 2022 at 9:16 AM Jakub Jelinek <jakub@redhat.com> wrote: > > > > > > On Wed, Dec 14, 2022 at 09:08:02AM +0100, Richard Biener via Gcc-patches > > wrote: > > > > On Wed, Dec 14, 2022 at 3:21 AM liuhongt via Gcc-patches > > > > <gcc-patches@gcc.gnu.org> wrote: > > > > > > > > > > Don't add crtfastmath.o for -shared to avoid changing the MXCSR > > > > > register when loading a shared library. crtfastmath.o will be > > > > > used only when building executables. > > > > > > > > > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > > > > > Ok for trunk? > > > > > > > > You reject negative -mdaz-ftz but wouldn't that be useful with > > > > -Ofast -mno-daz-ftz since there's otherwise no way to avoid that? > > > > > > Agreed. > > > I even wonder if the best wouldn't be to make the option effectively > > > three state, default, no and yes, where if the option isn't specified > > > at all, then crtfastmath.o* is linked as is now except for -shared, if > > > it is -mno-daz-ftz, then it is never linked in regardless of other > > > options and if it is -mdaz-ftz, then it is linked even for -shared. > > > > Possibly. I'd also suggest to split the changed -shared handling to a separate > > patch since people may want to backport this and it should be applicable to > > all other targets with similar handling. > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55522#c26 > So patch in the upper link is ok for trunk? It needs target maintainer approval but yes, I think that's what we want. Richard. > I'll change -mdaz-ftz part as a separate patch. > > > > > > > --- 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 RejectNegative > > > > > +Set the FTZ and DAZ Flags. > > > > > > As the option is only used in the driver, shouldn't it be marked > > > Driver and not Target? It doesn't need to be saved/restored on every > > > cfun switch etc. > > > > > > > > +@item -mdaz-ftz > > > > > +@opindex mdaz-ftz > > > > > + > > > > > +the flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the > > > > > +MXCSR register > > > > > > Shouldn't description start with capital letter? > > > > > > > > +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. > > > > > > > > Maybe say that the MXCSR register is set at program start to achieve > > > > this when the flag is specified at _link_ time and say this switch > > > > is ignored when -shared is specified? > > > > > > Jakub > > > ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] [x86] x86: Don't add crtfastmath.o for -shared and add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2022-12-14 8:52 ` Richard Biener @ 2022-12-14 9:07 ` Uros Bizjak 2022-12-15 6:21 ` [PATCH V2 1/2] x86: Don't add crtfastmath.o for -shared liuhongt 0 siblings, 1 reply; 27+ messages in thread From: Uros Bizjak @ 2022-12-14 9:07 UTC (permalink / raw) To: Richard Biener Cc: Liu, Hongtao, Jakub Jelinek, gcc-patches, crazylht, hjl.tools On Wed, Dec 14, 2022 at 9:52 AM Richard Biener <richard.guenther@gmail.com> wrote: > > On Wed, Dec 14, 2022 at 9:34 AM Liu, Hongtao <hongtao.liu@intel.com> wrote: > > > > > > > > > -----Original Message----- > > > From: Richard Biener <richard.guenther@gmail.com> > > > Sent: Wednesday, December 14, 2022 4:23 PM > > > To: Jakub Jelinek <jakub@redhat.com> > > > Cc: Liu, Hongtao <hongtao.liu@intel.com>; gcc-patches@gcc.gnu.org; > > > crazylht@gmail.com; hjl.tools@gmail.com; ubizjak@gmail.com > > > Subject: Re: [PATCH] [x86] x86: Don't add crtfastmath.o for -shared and add a > > > new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. > > > > > > On Wed, Dec 14, 2022 at 9:16 AM Jakub Jelinek <jakub@redhat.com> wrote: > > > > > > > > On Wed, Dec 14, 2022 at 09:08:02AM +0100, Richard Biener via Gcc-patches > > > wrote: > > > > > On Wed, Dec 14, 2022 at 3:21 AM liuhongt via Gcc-patches > > > > > <gcc-patches@gcc.gnu.org> wrote: > > > > > > > > > > > > Don't add crtfastmath.o for -shared to avoid changing the MXCSR > > > > > > register when loading a shared library. crtfastmath.o will be > > > > > > used only when building executables. > > > > > > > > > > > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > > > > > > Ok for trunk? > > > > > > > > > > You reject negative -mdaz-ftz but wouldn't that be useful with > > > > > -Ofast -mno-daz-ftz since there's otherwise no way to avoid that? > > > > > > > > Agreed. > > > > I even wonder if the best wouldn't be to make the option effectively > > > > three state, default, no and yes, where if the option isn't specified > > > > at all, then crtfastmath.o* is linked as is now except for -shared, if > > > > it is -mno-daz-ftz, then it is never linked in regardless of other > > > > options and if it is -mdaz-ftz, then it is linked even for -shared. > > > > > > Possibly. I'd also suggest to split the changed -shared handling to a separate > > > patch since people may want to backport this and it should be applicable to > > > all other targets with similar handling. > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55522#c26 > > So patch in the upper link is ok for trunk? > > It needs target maintainer approval but yes, I think that's what we want. Yes, the one-liner is OK. Perhaps it also needs a corresponding documentation change (haven't checked the documentation). Uros. > > Richard. > > > I'll change -mdaz-ftz part as a separate patch. > > > > > > > > > --- 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 RejectNegative > > > > > > +Set the FTZ and DAZ Flags. > > > > > > > > As the option is only used in the driver, shouldn't it be marked > > > > Driver and not Target? It doesn't need to be saved/restored on every > > > > cfun switch etc. > > > > > > > > > > +@item -mdaz-ftz > > > > > > +@opindex mdaz-ftz > > > > > > + > > > > > > +the flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the > > > > > > +MXCSR register > > > > > > > > Shouldn't description start with capital letter? > > > > > > > > > > +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. > > > > > > > > > > Maybe say that the MXCSR register is set at program start to achieve > > > > > this when the flag is specified at _link_ time and say this switch > > > > > is ignored when -shared is specified? > > > > > > > > Jakub > > > > ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH V2 1/2] x86: Don't add crtfastmath.o for -shared 2022-12-14 9:07 ` Uros Bizjak @ 2022-12-15 6:21 ` liuhongt 2022-12-15 6:21 ` [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR liuhongt 2022-12-16 9:50 ` [PATCH V2 1/2] x86: Don't add crtfastmath.o for -shared Uros Bizjak 0 siblings, 2 replies; 27+ messages in thread From: liuhongt @ 2022-12-15 6:21 UTC (permalink / raw) To: gcc-patches; +Cc: crazylht, hjl.tools, ubizjak Update in V2: Split -shared change into a separate commit and add some documentation for it. Bootstrapped and regtested on x86_64-pc-linu-gnu{-m32,}. Ok of trunk? Don't add crtfastmath.o for -shared to avoid changing the MXCSR register when loading a shared library. crtfastmath.o will be used only when building executables. PR target/55522 * config/i386/gnu-user-common.h (GNU_USER_TARGET_MATHFILE_SPEC): Don't add crtfastmath.o for -shared. * doc/invoke.texi (-shared): Add related documentation. --- gcc/config/i386/gnu-user-common.h | 2 +- gcc/doc/invoke.texi | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/config/i386/gnu-user-common.h b/gcc/config/i386/gnu-user-common.h index cab9be2bfb7..9910cd64363 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:crtfastmath.o%s} \ + "%{Ofast|ffast-math|funsafe-math-optimizations:%{!shared:crtfastmath.o%s}} \ %{mpc32:crtprec32.o%s} \ %{mpc64:crtprec64.o%s} \ %{mpc80:crtprec80.o%s}" diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index cb40b38b73a..cba4f19f4f4 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -17656,7 +17656,8 @@ needs to build supplementary stub code for constructors to work. On multi-libbed systems, @samp{gcc -shared} must select the correct support libraries to link against. Failing to supply the correct flags may lead to subtle defects. Supplying them in cases where they are not necessary -is innocuous.} +is innocuous. For x86, crtfastmath.o will not be added when +@option{-shared} is specified. } @item -shared-libgcc @itemx -static-libgcc -- 2.27.0 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2022-12-15 6:21 ` [PATCH V2 1/2] x86: Don't add crtfastmath.o for -shared liuhongt @ 2022-12-15 6:21 ` liuhongt 2022-12-15 7:39 ` Jakub Jelinek 2022-12-16 9:50 ` [PATCH V2 1/2] x86: Don't add crtfastmath.o for -shared Uros Bizjak 1 sibling, 1 reply; 27+ messages in thread From: liuhongt @ 2022-12-15 6:21 UTC (permalink / raw) To: gcc-patches; +Cc: crazylht, hjl.tools, ubizjak Update in v2: 1. Support -mno-daz-ftz, and make the the option effectively three state as: 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 2. Still make the option Target since a. cc1: error: command-line option ‘-mdaz-ftz’ is valid for the driver but not for C b. Since there's no real variable speicified by mdaz-ftz, I saw in options.h, it's marked as #ifndef GENERATOR_FILE int x_VAR_mdaz_ftz; #define x_VAR_mdaz_ftz do_not_use #endif and not be saved and restored in cl_target_option_save and cl_target_option_restore(am I missing something?) 3. Capital the first letter and add more descriptions about -mdaz-ftz and -shared. 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. --- 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 cba4f19f4f4..7f1d002f228 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 @@ -32753,6 +32753,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} -- 2.27.0 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2022-12-15 6:21 ` [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR liuhongt @ 2022-12-15 7:39 ` Jakub Jelinek 2022-12-15 7:45 ` Hongtao Liu 0 siblings, 1 reply; 27+ messages in thread From: Jakub Jelinek @ 2022-12-15 7:39 UTC (permalink / raw) To: liuhongt; +Cc: gcc-patches, crazylht, hjl.tools, ubizjak On Thu, Dec 15, 2022 at 02:21:37PM +0800, liuhongt via Gcc-patches wrote: > --- 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 s/Target/Driver/ > +Set the FTZ and DAZ Flags. Jakub ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2022-12-15 7:39 ` Jakub Jelinek @ 2022-12-15 7:45 ` Hongtao Liu 2022-12-20 4:51 ` Hongtao Liu 0 siblings, 1 reply; 27+ messages in thread From: Hongtao Liu @ 2022-12-15 7:45 UTC (permalink / raw) To: Jakub Jelinek; +Cc: liuhongt, gcc-patches, hjl.tools, ubizjak On Thu, Dec 15, 2022 at 3:39 PM Jakub Jelinek <jakub@redhat.com> wrote: > > On Thu, Dec 15, 2022 at 02:21:37PM +0800, liuhongt via Gcc-patches wrote: > > --- 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 > > s/Target/Driver/ Change to Driver and Got error like:cc1: error: command-line option ‘-mdaz-ftz’ is valid for the driver but not for C. > > > +Set the FTZ and DAZ Flags. > > Jakub > -- BR, Hongtao ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2022-12-15 7:45 ` Hongtao Liu @ 2022-12-20 4:51 ` Hongtao Liu 2022-12-21 20:20 ` H.J. Lu 0 siblings, 1 reply; 27+ messages in thread From: Hongtao Liu @ 2022-12-20 4:51 UTC (permalink / raw) To: Jakub Jelinek; +Cc: liuhongt, gcc-patches, hjl.tools, ubizjak On Thu, Dec 15, 2022 at 3:45 PM Hongtao Liu <crazylht@gmail.com> wrote: > > On Thu, Dec 15, 2022 at 3:39 PM Jakub Jelinek <jakub@redhat.com> wrote: > > > > On Thu, Dec 15, 2022 at 02:21:37PM +0800, liuhongt via Gcc-patches wrote: > > > --- 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 > > > > s/Target/Driver/ > Change to Driver and Got error like:cc1: error: command-line option > ‘-mdaz-ftz’ is valid for the driver but not for C. Hi Jakub: I didn't find a good solution to handle this error after changing *Target* to *Driver*, Could you give some hints how to solve this problem? Or is it ok for you to mark this as *Target*(there won't be any save and restore in cfun since there's no variable defined here.) > > > > > +Set the FTZ and DAZ Flags. > > > > Jakub > > > > > -- > BR, > Hongtao -- BR, Hongtao ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2022-12-20 4:51 ` Hongtao Liu @ 2022-12-21 20:20 ` H.J. Lu 2022-12-21 22:35 ` Jakub Jelinek 0 siblings, 1 reply; 27+ messages in thread From: H.J. Lu @ 2022-12-21 20:20 UTC (permalink / raw) To: Hongtao Liu; +Cc: Jakub Jelinek, liuhongt, gcc-patches, ubizjak On Mon, Dec 19, 2022 at 8:52 PM Hongtao Liu <crazylht@gmail.com> wrote: > > On Thu, Dec 15, 2022 at 3:45 PM Hongtao Liu <crazylht@gmail.com> wrote: > > > > On Thu, Dec 15, 2022 at 3:39 PM Jakub Jelinek <jakub@redhat.com> wrote: > > > > > > On Thu, Dec 15, 2022 at 02:21:37PM +0800, liuhongt via Gcc-patches wrote: > > > > --- 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 > > > > > > s/Target/Driver/ > > Change to Driver and Got error like:cc1: error: command-line option > > ‘-mdaz-ftz’ is valid for the driver but not for C. > Hi Jakub: > I didn't find a good solution to handle this error after changing > *Target* to *Driver*, Could you give some hints how to solve this > problem? > Or is it ok for you to mark this as *Target*(there won't be any save > and restore in cfun since there's no variable defined here.) Since all -m* options are passed to cc1, -mdaz-ftz can't be marked as Driver. We need to give it a different name to mark it as Driver. -- H.J. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2022-12-21 20:20 ` H.J. Lu @ 2022-12-21 22:35 ` Jakub Jelinek 2022-12-21 22:43 ` H.J. Lu 0 siblings, 1 reply; 27+ messages in thread From: Jakub Jelinek @ 2022-12-21 22:35 UTC (permalink / raw) To: H.J. Lu; +Cc: Hongtao Liu, liuhongt, gcc-patches, ubizjak On Wed, Dec 21, 2022 at 12:20:23PM -0800, H.J. Lu wrote: > On Mon, Dec 19, 2022 at 8:52 PM Hongtao Liu <crazylht@gmail.com> wrote: > > > > On Thu, Dec 15, 2022 at 3:45 PM Hongtao Liu <crazylht@gmail.com> wrote: > > > > > > On Thu, Dec 15, 2022 at 3:39 PM Jakub Jelinek <jakub@redhat.com> wrote: > > > > > > > > On Thu, Dec 15, 2022 at 02:21:37PM +0800, liuhongt via Gcc-patches wrote: > > > > > --- 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 > > > > > > > > s/Target/Driver/ > > > Change to Driver and Got error like:cc1: error: command-line option > > > ‘-mdaz-ftz’ is valid for the driver but not for C. > > Hi Jakub: > > I didn't find a good solution to handle this error after changing > > *Target* to *Driver*, Could you give some hints how to solve this > > problem? > > Or is it ok for you to mark this as *Target*(there won't be any save > > and restore in cfun since there's no variable defined here.) > > Since all -m* options are passed to cc1, -mdaz-ftz can't be marked > as Driver. We need to give it a different name to mark it as Driver. It is ok like that. Jakub ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2022-12-21 22:35 ` Jakub Jelinek @ 2022-12-21 22:43 ` H.J. Lu 2022-12-21 22:46 ` Jakub Jelinek 0 siblings, 1 reply; 27+ messages in thread From: H.J. Lu @ 2022-12-21 22:43 UTC (permalink / raw) To: Jakub Jelinek; +Cc: Hongtao Liu, liuhongt, gcc-patches, ubizjak [-- Attachment #1: Type: text/plain, Size: 1681 bytes --] On Wed, Dec 21, 2022 at 2:35 PM Jakub Jelinek <jakub@redhat.com> wrote: > > On Wed, Dec 21, 2022 at 12:20:23PM -0800, H.J. Lu wrote: > > On Mon, Dec 19, 2022 at 8:52 PM Hongtao Liu <crazylht@gmail.com> wrote: > > > > > > On Thu, Dec 15, 2022 at 3:45 PM Hongtao Liu <crazylht@gmail.com> wrote: > > > > > > > > On Thu, Dec 15, 2022 at 3:39 PM Jakub Jelinek <jakub@redhat.com> wrote: > > > > > > > > > > On Thu, Dec 15, 2022 at 02:21:37PM +0800, liuhongt via Gcc-patches wrote: > > > > > > --- 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 > > > > > > > > > > s/Target/Driver/ > > > > Change to Driver and Got error like:cc1: error: command-line option > > > > ‘-mdaz-ftz’ is valid for the driver but not for C. > > > Hi Jakub: > > > I didn't find a good solution to handle this error after changing > > > *Target* to *Driver*, Could you give some hints how to solve this > > > problem? > > > Or is it ok for you to mark this as *Target*(there won't be any save > > > and restore in cfun since there's no variable defined here.) > > > > Since all -m* options are passed to cc1, -mdaz-ftz can't be marked > > as Driver. We need to give it a different name to mark it as Driver. > > It is ok like that. > > Jakub > The GCC driver handles -mno-XXX automatically for -mXXX. Use a different name needs to handle the negation. Or we can do something like this to check for CL_DRIVER before passing it to cc1. -- H.J. [-- Attachment #2: p.diff --] [-- Type: text/x-patch, Size: 1594 bytes --] diff --git a/gcc/gcc.cc b/gcc/gcc.cc index 2568d541196..87cbea11ae1 100644 --- a/gcc/gcc.cc +++ b/gcc/gcc.cc @@ -3851,7 +3851,7 @@ alloc_switch (void) static void save_switch (const char *opt, size_t n_args, const char *const *args, - bool validated, bool known) + bool validated, bool known, bool driver = false) { alloc_switch (); switches[n_switches].part1 = opt + 1; @@ -3868,6 +3868,7 @@ save_switch (const char *opt, size_t n_args, const char *const *args, switches[n_switches].validated = validated; switches[n_switches].known = known; switches[n_switches].ordering = 0; + switches[n_switches].driver = driver; n_switches++; } @@ -4575,7 +4576,8 @@ driver_handle_option (struct gcc_options *opts, if (do_save) save_switch (decoded->canonical_option[0], decoded->canonical_option_num_elements - 1, - &decoded->canonical_option[1], validated, true); + &decoded->canonical_option[1], validated, true, + cl_options[opt_index].flags == CL_DRIVER); return true; } @@ -7465,7 +7467,8 @@ check_live_switch (int switchnum, int prefix_length) static void give_switch (int switchnum, int omit_first_word) { - if ((switches[switchnum].live_cond & SWITCH_IGNORE) != 0) + if ((switches[switchnum].live_cond & SWITCH_IGNORE) != 0 + || switches[switchnum].driver) return; if (!omit_first_word) diff --git a/gcc/opts.h b/gcc/opts.h index ce4fd5c39b9..2900f0d9168 100644 --- a/gcc/opts.h +++ b/gcc/opts.h @@ -561,6 +561,7 @@ struct switchstr bool known; bool validated; bool ordering; + bool driver; }; #endif ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2022-12-21 22:43 ` H.J. Lu @ 2022-12-21 22:46 ` Jakub Jelinek 2022-12-22 4:40 ` Hongtao Liu 0 siblings, 1 reply; 27+ messages in thread From: Jakub Jelinek @ 2022-12-21 22:46 UTC (permalink / raw) To: H.J. Lu; +Cc: Hongtao Liu, liuhongt, gcc-patches, ubizjak On Wed, Dec 21, 2022 at 02:43:43PM -0800, H.J. Lu wrote: > > > > > > > Target RejectNegative > > > > > > > Set 80387 floating-point precision to 80-bit. > > > > > > > > > > > > > > +mdaz-ftz > > > > > > > +Target > > > > > > > > > > > > s/Target/Driver/ > > > > > Change to Driver and Got error like:cc1: error: command-line option > > > > > ‘-mdaz-ftz’ is valid for the driver but not for C. > > > > Hi Jakub: > > > > I didn't find a good solution to handle this error after changing > > > > *Target* to *Driver*, Could you give some hints how to solve this > > > > problem? > > > > Or is it ok for you to mark this as *Target*(there won't be any save > > > > and restore in cfun since there's no variable defined here.) > > > > > > Since all -m* options are passed to cc1, -mdaz-ftz can't be marked > > > as Driver. We need to give it a different name to mark it as Driver. > > > > It is ok like that. > > > > Jakub > > > > The GCC driver handles -mno-XXX automatically for -mXXX. Use > a different name needs to handle the negation. Or we can do something > like this to check for CL_DRIVER before passing it to cc1. I meant I'm ok with -m{,no-}daz-ftz option being Target rather than Driver. Jakub ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2022-12-21 22:46 ` Jakub Jelinek @ 2022-12-22 4:40 ` Hongtao Liu 2022-12-22 8:04 ` Uros Bizjak 0 siblings, 1 reply; 27+ messages in thread From: Hongtao Liu @ 2022-12-22 4:40 UTC (permalink / raw) To: ubizjak; +Cc: H.J. Lu, gcc-patches, Jakub Jelinek On Thu, Dec 22, 2022 at 6:46 AM Jakub Jelinek <jakub@redhat.com> wrote: > > On Wed, Dec 21, 2022 at 02:43:43PM -0800, H.J. Lu wrote: > > > > > > > > Target RejectNegative > > > > > > > > Set 80387 floating-point precision to 80-bit. > > > > > > > > > > > > > > > > +mdaz-ftz > > > > > > > > +Target > > > > > > > > > > > > > > s/Target/Driver/ > > > > > > Change to Driver and Got error like:cc1: error: command-line option > > > > > > ‘-mdaz-ftz’ is valid for the driver but not for C. > > > > > Hi Jakub: > > > > > I didn't find a good solution to handle this error after changing > > > > > *Target* to *Driver*, Could you give some hints how to solve this > > > > > problem? > > > > > Or is it ok for you to mark this as *Target*(there won't be any save > > > > > and restore in cfun since there's no variable defined here.) > > > > > > > > Since all -m* options are passed to cc1, -mdaz-ftz can't be marked > > > > as Driver. We need to give it a different name to mark it as Driver. > > > > > > It is ok like that. > > > > > > Jakub > > > > > > > The GCC driver handles -mno-XXX automatically for -mXXX. Use > > a different name needs to handle the negation. Or we can do something > > like this to check for CL_DRIVER before passing it to cc1. > > I meant I'm ok with -m{,no-}daz-ftz option being Target rather than Driver. > Thanks. Uros, Is the patch for you? > Jakub > -- BR, Hongtao ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2022-12-22 4:40 ` Hongtao Liu @ 2022-12-22 8:04 ` Uros Bizjak 2023-05-04 5:35 ` Hongtao Liu 0 siblings, 1 reply; 27+ messages in thread From: Uros Bizjak @ 2022-12-22 8:04 UTC (permalink / raw) To: Hongtao Liu; +Cc: H.J. Lu, gcc-patches, Jakub Jelinek On Thu, Dec 22, 2022 at 5:40 AM Hongtao Liu <crazylht@gmail.com> wrote: > > On Thu, Dec 22, 2022 at 6:46 AM Jakub Jelinek <jakub@redhat.com> wrote: > > > > On Wed, Dec 21, 2022 at 02:43:43PM -0800, H.J. Lu wrote: > > > > > > > > > Target RejectNegative > > > > > > > > > Set 80387 floating-point precision to 80-bit. > > > > > > > > > > > > > > > > > > +mdaz-ftz > > > > > > > > > +Target > > > > > > > > > > > > > > > > s/Target/Driver/ > > > > > > > Change to Driver and Got error like:cc1: error: command-line option > > > > > > > ‘-mdaz-ftz’ is valid for the driver but not for C. > > > > > > Hi Jakub: > > > > > > I didn't find a good solution to handle this error after changing > > > > > > *Target* to *Driver*, Could you give some hints how to solve this > > > > > > problem? > > > > > > Or is it ok for you to mark this as *Target*(there won't be any save > > > > > > and restore in cfun since there's no variable defined here.) > > > > > > > > > > Since all -m* options are passed to cc1, -mdaz-ftz can't be marked > > > > > as Driver. We need to give it a different name to mark it as Driver. > > > > > > > > It is ok like that. > > > > > > > > Jakub > > > > > > > > > > The GCC driver handles -mno-XXX automatically for -mXXX. Use > > > a different name needs to handle the negation. Or we can do something > > > like this to check for CL_DRIVER before passing it to cc1. > > > > I meant I'm ok with -m{,no-}daz-ftz option being Target rather than Driver. > > > Thanks. > Uros, Is the patch for you? The original patch is then OK. Thanks, Uros. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2022-12-22 8:04 ` Uros Bizjak @ 2023-05-04 5:35 ` Hongtao Liu 2023-05-04 5:36 ` Hongtao Liu 0 siblings, 1 reply; 27+ messages in thread From: Hongtao Liu @ 2023-05-04 5:35 UTC (permalink / raw) To: Uros Bizjak; +Cc: H.J. Lu, gcc-patches, Jakub Jelinek On Thu, Dec 22, 2022 at 4:04 PM Uros Bizjak <ubizjak@gmail.com> wrote: > > On Thu, Dec 22, 2022 at 5:40 AM Hongtao Liu <crazylht@gmail.com> wrote: > > > > On Thu, Dec 22, 2022 at 6:46 AM Jakub Jelinek <jakub@redhat.com> wrote: > > > > > > On Wed, Dec 21, 2022 at 02:43:43PM -0800, H.J. Lu wrote: > > > > > > > > > > Target RejectNegative > > > > > > > > > > Set 80387 floating-point precision to 80-bit. > > > > > > > > > > > > > > > > > > > > +mdaz-ftz > > > > > > > > > > +Target > > > > > > > > > > > > > > > > > > s/Target/Driver/ > > > > > > > > Change to Driver and Got error like:cc1: error: command-line option > > > > > > > > ‘-mdaz-ftz’ is valid for the driver but not for C. > > > > > > > Hi Jakub: > > > > > > > I didn't find a good solution to handle this error after changing > > > > > > > *Target* to *Driver*, Could you give some hints how to solve this > > > > > > > problem? > > > > > > > Or is it ok for you to mark this as *Target*(there won't be any save > > > > > > > and restore in cfun since there's no variable defined here.) > > > > > > > > > > > > Since all -m* options are passed to cc1, -mdaz-ftz can't be marked > > > > > > as Driver. We need to give it a different name to mark it as Driver. > > > > > > > > > > It is ok like that. > > > > > > > > > > Jakub > > > > > > > > > > > > > The GCC driver handles -mno-XXX automatically for -mXXX. Use > > > > a different name needs to handle the negation. Or we can do something > > > > like this to check for CL_DRIVER before passing it to cc1. > > > > > > I meant I'm ok with -m{,no-}daz-ftz option being Target rather than Driver. > > > > > Thanks. > > Uros, Is the patch for you? > > The original patch is then OK. Some users found the -mdaz-ftz option to be very useful, and want it to be backport to GCC12 and GCC11. But the patch is not a bugfix one, so i'd like to ask options from other maintainers, if the patch is suitable for backport? The backport patches include both this one and [1] which apply -mdaz-ftz to all other x86 targets. [1] https://gcc.gnu.org/pipermail/gcc-patches/2023-January/610053.html > > Thanks, > Uros. -- BR, Hongtao ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2023-05-04 5:35 ` Hongtao Liu @ 2023-05-04 5:36 ` Hongtao Liu 2023-05-04 9:49 ` Richard Biener 0 siblings, 1 reply; 27+ messages in thread From: Hongtao Liu @ 2023-05-04 5:36 UTC (permalink / raw) To: Uros Bizjak; +Cc: H.J. Lu, gcc-patches, Jakub Jelinek On Thu, May 4, 2023 at 1:35 PM Hongtao Liu <crazylht@gmail.com> wrote: > > On Thu, Dec 22, 2022 at 4:04 PM Uros Bizjak <ubizjak@gmail.com> wrote: > > > > On Thu, Dec 22, 2022 at 5:40 AM Hongtao Liu <crazylht@gmail.com> wrote: > > > > > > On Thu, Dec 22, 2022 at 6:46 AM Jakub Jelinek <jakub@redhat.com> wrote: > > > > > > > > On Wed, Dec 21, 2022 at 02:43:43PM -0800, H.J. Lu wrote: > > > > > > > > > > > Target RejectNegative > > > > > > > > > > > Set 80387 floating-point precision to 80-bit. > > > > > > > > > > > > > > > > > > > > > > +mdaz-ftz > > > > > > > > > > > +Target > > > > > > > > > > > > > > > > > > > > s/Target/Driver/ > > > > > > > > > Change to Driver and Got error like:cc1: error: command-line option > > > > > > > > > ‘-mdaz-ftz’ is valid for the driver but not for C. > > > > > > > > Hi Jakub: > > > > > > > > I didn't find a good solution to handle this error after changing > > > > > > > > *Target* to *Driver*, Could you give some hints how to solve this > > > > > > > > problem? > > > > > > > > Or is it ok for you to mark this as *Target*(there won't be any save > > > > > > > > and restore in cfun since there's no variable defined here.) > > > > > > > > > > > > > > Since all -m* options are passed to cc1, -mdaz-ftz can't be marked > > > > > > > as Driver. We need to give it a different name to mark it as Driver. > > > > > > > > > > > > It is ok like that. > > > > > > > > > > > > Jakub > > > > > > > > > > > > > > > > The GCC driver handles -mno-XXX automatically for -mXXX. Use > > > > > a different name needs to handle the negation. Or we can do something > > > > > like this to check for CL_DRIVER before passing it to cc1. > > > > > > > > I meant I'm ok with -m{,no-}daz-ftz option being Target rather than Driver. > > > > > > > Thanks. > > > Uros, Is the patch for you? > > > > The original patch is then OK. > Some users found the -mdaz-ftz option to be very useful, and want it > to be backport to GCC12 and GCC11. > But the patch is not a bugfix one, so i'd like to ask options from s/options/opinions/g > other maintainers, if the patch is suitable for backport? > > The backport patches include both this one and [1] which apply > -mdaz-ftz to all other x86 targets. > > [1] https://gcc.gnu.org/pipermail/gcc-patches/2023-January/610053.html > > > > > Thanks, > > Uros. > > > > -- > BR, > Hongtao -- BR, Hongtao ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2023-05-04 5:36 ` Hongtao Liu @ 2023-05-04 9:49 ` Richard Biener 2023-05-10 1:41 ` Hongtao Liu 0 siblings, 1 reply; 27+ messages in thread From: Richard Biener @ 2023-05-04 9:49 UTC (permalink / raw) To: Hongtao Liu; +Cc: Uros Bizjak, H.J. Lu, gcc-patches, Jakub Jelinek On Thu, May 4, 2023 at 7:37 AM Hongtao Liu via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > On Thu, May 4, 2023 at 1:35 PM Hongtao Liu <crazylht@gmail.com> wrote: > > > > On Thu, Dec 22, 2022 at 4:04 PM Uros Bizjak <ubizjak@gmail.com> wrote: > > > > > > On Thu, Dec 22, 2022 at 5:40 AM Hongtao Liu <crazylht@gmail.com> wrote: > > > > > > > > On Thu, Dec 22, 2022 at 6:46 AM Jakub Jelinek <jakub@redhat.com> wrote: > > > > > > > > > > On Wed, Dec 21, 2022 at 02:43:43PM -0800, H.J. Lu wrote: > > > > > > > > > > > > Target RejectNegative > > > > > > > > > > > > Set 80387 floating-point precision to 80-bit. > > > > > > > > > > > > > > > > > > > > > > > > +mdaz-ftz > > > > > > > > > > > > +Target > > > > > > > > > > > > > > > > > > > > > > s/Target/Driver/ > > > > > > > > > > Change to Driver and Got error like:cc1: error: command-line option > > > > > > > > > > ‘-mdaz-ftz’ is valid for the driver but not for C. > > > > > > > > > Hi Jakub: > > > > > > > > > I didn't find a good solution to handle this error after changing > > > > > > > > > *Target* to *Driver*, Could you give some hints how to solve this > > > > > > > > > problem? > > > > > > > > > Or is it ok for you to mark this as *Target*(there won't be any save > > > > > > > > > and restore in cfun since there's no variable defined here.) > > > > > > > > > > > > > > > > Since all -m* options are passed to cc1, -mdaz-ftz can't be marked > > > > > > > > as Driver. We need to give it a different name to mark it as Driver. > > > > > > > > > > > > > > It is ok like that. > > > > > > > > > > > > > > Jakub > > > > > > > > > > > > > > > > > > > The GCC driver handles -mno-XXX automatically for -mXXX. Use > > > > > > a different name needs to handle the negation. Or we can do something > > > > > > like this to check for CL_DRIVER before passing it to cc1. > > > > > > > > > > I meant I'm ok with -m{,no-}daz-ftz option being Target rather than Driver. > > > > > > > > > Thanks. > > > > Uros, Is the patch for you? > > > > > > The original patch is then OK. > > Some users found the -mdaz-ftz option to be very useful, and want it > > to be backport to GCC12 and GCC11. > > But the patch is not a bugfix one, so i'd like to ask options from > s/options/opinions/g > > other maintainers, if the patch is suitable for backport? > > > > The backport patches include both this one and [1] which apply > > -mdaz-ftz to all other x86 targets. > > > > [1] https://gcc.gnu.org/pipermail/gcc-patches/2023-January/610053.html Please make sure to not backport the -ffast-math linker spec change though. Also note the 12 branch is currently frozen. I'll defer to x86 maintainers on the -mdaz-ftz flag itself. Richard. > > > > > > Thanks, > > > Uros. > > > > > > > > -- > > BR, > > Hongtao > > > > -- > BR, > Hongtao ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2023-05-04 9:49 ` Richard Biener @ 2023-05-10 1:41 ` Hongtao Liu 2023-05-10 6:41 ` Richard Biener 0 siblings, 1 reply; 27+ messages in thread From: Hongtao Liu @ 2023-05-10 1:41 UTC (permalink / raw) To: Richard Biener; +Cc: Uros Bizjak, H.J. Lu, gcc-patches, Jakub Jelinek On Thu, May 4, 2023 at 5:49 PM Richard Biener <richard.guenther@gmail.com> wrote: > > On Thu, May 4, 2023 at 7:37 AM Hongtao Liu via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > On Thu, May 4, 2023 at 1:35 PM Hongtao Liu <crazylht@gmail.com> wrote: > > > > > > On Thu, Dec 22, 2022 at 4:04 PM Uros Bizjak <ubizjak@gmail.com> wrote: > > > > > > > > On Thu, Dec 22, 2022 at 5:40 AM Hongtao Liu <crazylht@gmail.com> wrote: > > > > > > > > > > On Thu, Dec 22, 2022 at 6:46 AM Jakub Jelinek <jakub@redhat.com> wrote: > > > > > > > > > > > > On Wed, Dec 21, 2022 at 02:43:43PM -0800, H.J. Lu wrote: > > > > > > > > > > > > > Target RejectNegative > > > > > > > > > > > > > Set 80387 floating-point precision to 80-bit. > > > > > > > > > > > > > > > > > > > > > > > > > > +mdaz-ftz > > > > > > > > > > > > > +Target > > > > > > > > > > > > > > > > > > > > > > > > s/Target/Driver/ > > > > > > > > > > > Change to Driver and Got error like:cc1: error: command-line option > > > > > > > > > > > ‘-mdaz-ftz’ is valid for the driver but not for C. > > > > > > > > > > Hi Jakub: > > > > > > > > > > I didn't find a good solution to handle this error after changing > > > > > > > > > > *Target* to *Driver*, Could you give some hints how to solve this > > > > > > > > > > problem? > > > > > > > > > > Or is it ok for you to mark this as *Target*(there won't be any save > > > > > > > > > > and restore in cfun since there's no variable defined here.) > > > > > > > > > > > > > > > > > > Since all -m* options are passed to cc1, -mdaz-ftz can't be marked > > > > > > > > > as Driver. We need to give it a different name to mark it as Driver. > > > > > > > > > > > > > > > > It is ok like that. > > > > > > > > > > > > > > > > Jakub > > > > > > > > > > > > > > > > > > > > > > The GCC driver handles -mno-XXX automatically for -mXXX. Use > > > > > > > a different name needs to handle the negation. Or we can do something > > > > > > > like this to check for CL_DRIVER before passing it to cc1. > > > > > > > > > > > > I meant I'm ok with -m{,no-}daz-ftz option being Target rather than Driver. > > > > > > > > > > > Thanks. > > > > > Uros, Is the patch for you? > > > > > > > > The original patch is then OK. > > > Some users found the -mdaz-ftz option to be very useful, and want it > > > to be backport to GCC12 and GCC11. > > > But the patch is not a bugfix one, so i'd like to ask options from > > s/options/opinions/g > > > other maintainers, if the patch is suitable for backport? > > > > > > The backport patches include both this one and [1] which apply > > > -mdaz-ftz to all other x86 targets. > > > > > > [1] https://gcc.gnu.org/pipermail/gcc-patches/2023-January/610053.html > > Please make sure to not backport the -ffast-math linker spec change though. > Also note the 12 branch is currently frozen. You're meaning don't backport -shared part since it will cause different behavior between different backends. ? I'm trying to backport the daz-ftz part, it won't change the existed behavior for fast-math or shared. %{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!mno-daz-ftz:crtfastmath.o%s}} > > I'll defer to x86 maintainers on the -mdaz-ftz flag itself. > > Richard. > > > > > > > > > Thanks, > > > > Uros. > > > > > > > > > > > > -- > > > BR, > > > Hongtao > > > > > > > > -- > > BR, > > Hongtao -- BR, Hongtao ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2023-05-10 1:41 ` Hongtao Liu @ 2023-05-10 6:41 ` Richard Biener 2023-05-10 9:07 ` [PATCH] " liuhongt 0 siblings, 1 reply; 27+ messages in thread From: Richard Biener @ 2023-05-10 6:41 UTC (permalink / raw) To: Hongtao Liu; +Cc: Uros Bizjak, H.J. Lu, gcc-patches, Jakub Jelinek On Wed, May 10, 2023 at 3:41 AM Hongtao Liu <crazylht@gmail.com> wrote: > > On Thu, May 4, 2023 at 5:49 PM Richard Biener > <richard.guenther@gmail.com> wrote: > > > > On Thu, May 4, 2023 at 7:37 AM Hongtao Liu via Gcc-patches > > <gcc-patches@gcc.gnu.org> wrote: > > > > > > On Thu, May 4, 2023 at 1:35 PM Hongtao Liu <crazylht@gmail.com> wrote: > > > > > > > > On Thu, Dec 22, 2022 at 4:04 PM Uros Bizjak <ubizjak@gmail.com> wrote: > > > > > > > > > > On Thu, Dec 22, 2022 at 5:40 AM Hongtao Liu <crazylht@gmail.com> wrote: > > > > > > > > > > > > On Thu, Dec 22, 2022 at 6:46 AM Jakub Jelinek <jakub@redhat.com> wrote: > > > > > > > > > > > > > > On Wed, Dec 21, 2022 at 02:43:43PM -0800, H.J. Lu wrote: > > > > > > > > > > > > > > Target RejectNegative > > > > > > > > > > > > > > Set 80387 floating-point precision to 80-bit. > > > > > > > > > > > > > > > > > > > > > > > > > > > > +mdaz-ftz > > > > > > > > > > > > > > +Target > > > > > > > > > > > > > > > > > > > > > > > > > > s/Target/Driver/ > > > > > > > > > > > > Change to Driver and Got error like:cc1: error: command-line option > > > > > > > > > > > > ‘-mdaz-ftz’ is valid for the driver but not for C. > > > > > > > > > > > Hi Jakub: > > > > > > > > > > > I didn't find a good solution to handle this error after changing > > > > > > > > > > > *Target* to *Driver*, Could you give some hints how to solve this > > > > > > > > > > > problem? > > > > > > > > > > > Or is it ok for you to mark this as *Target*(there won't be any save > > > > > > > > > > > and restore in cfun since there's no variable defined here.) > > > > > > > > > > > > > > > > > > > > Since all -m* options are passed to cc1, -mdaz-ftz can't be marked > > > > > > > > > > as Driver. We need to give it a different name to mark it as Driver. > > > > > > > > > > > > > > > > > > It is ok like that. > > > > > > > > > > > > > > > > > > Jakub > > > > > > > > > > > > > > > > > > > > > > > > > The GCC driver handles -mno-XXX automatically for -mXXX. Use > > > > > > > > a different name needs to handle the negation. Or we can do something > > > > > > > > like this to check for CL_DRIVER before passing it to cc1. > > > > > > > > > > > > > > I meant I'm ok with -m{,no-}daz-ftz option being Target rather than Driver. > > > > > > > > > > > > > Thanks. > > > > > > Uros, Is the patch for you? > > > > > > > > > > The original patch is then OK. > > > > Some users found the -mdaz-ftz option to be very useful, and want it > > > > to be backport to GCC12 and GCC11. > > > > But the patch is not a bugfix one, so i'd like to ask options from > > > s/options/opinions/g > > > > other maintainers, if the patch is suitable for backport? > > > > > > > > The backport patches include both this one and [1] which apply > > > > -mdaz-ftz to all other x86 targets. > > > > > > > > [1] https://gcc.gnu.org/pipermail/gcc-patches/2023-January/610053.html > > > > Please make sure to not backport the -ffast-math linker spec change though. > > Also note the 12 branch is currently frozen. > You're meaning don't backport -shared part since it will cause > different behavior between different backends. ? > I'm trying to backport the daz-ftz part, it won't change the existed > behavior for fast-math or shared. > %{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!mno-daz-ftz:crtfastmath.o%s}} The quoted patch shows -shared in context and you didn't post a backport version to look at. But yes, we shouldn't change -shared behavior on a branch, even less so make it inconsistent between targets. Richard. > > > > I'll defer to x86 maintainers on the -mdaz-ftz flag itself. > > > > Richard. > > > > > > > > > > > > Thanks, > > > > > Uros. > > > > > > > > > > > > > > > > -- > > > > BR, > > > > Hongtao > > > > > > > > > > > > -- > > > BR, > > > Hongtao > > > > -- > BR, > Hongtao ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2023-05-10 6:41 ` Richard Biener @ 2023-05-10 9:07 ` liuhongt 2023-05-12 5:43 ` Hongtao Liu 0 siblings, 1 reply; 27+ messages in thread From: liuhongt @ 2023-05-10 9:07 UTC (permalink / raw) To: gcc-patches; +Cc: crazylht, hjl.tools > The quoted patch shows -shared in context and you didn't post a > backport version > to look at. But yes, we shouldn't change -shared behavior on a > branch, even less so make it > inconsistent between targets. Here's the patch. Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. Ok for GCC 11/12 backport? if (mdaz-ftz) link crtfastmath.o else if ((Ofast || ffast-math || funsafe-math-optimizations) && !mno-daz-ftz) link crtfastmath.o else Don't link crtfastmath.o gcc/ChangeLog: * config/i386/cygwin.h (ENDFILE_SPEC): Link crtfastmath.o whenever -mdaz-ftz is specified. Don't link crtfastmath.o when -mno-daz-ftz is specified. * config/i386/darwin.h (ENDFILE_SPEC): Ditto. * config/i386/gnu-user-common.h (GNU_USER_TARGET_MATHFILE_SPEC): Ditto. * config/i386/mingw32.h (ENDFILE_SPEC): Ditto. * config/i386/i386.opt (mdaz-ftz): New option. * doc/invoke.texi (x86 options): Document mftz-daz. --- gcc/config/i386/cygwin.h | 2 +- gcc/config/i386/darwin.h | 4 ++-- gcc/config/i386/gnu-user-common.h | 2 +- gcc/config/i386/i386.opt | 4 ++++ gcc/config/i386/mingw32.h | 2 +- gcc/doc/invoke.texi | 11 ++++++++++- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/gcc/config/i386/cygwin.h b/gcc/config/i386/cygwin.h index d06eda369cf..5412c5d4479 100644 --- a/gcc/config/i386/cygwin.h +++ b/gcc/config/i386/cygwin.h @@ -57,7 +57,7 @@ along with GCC; see the file COPYING3. If not see #undef ENDFILE_SPEC #define ENDFILE_SPEC \ - "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}\ + "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!mno-daz-ftz:crtfastmath.o%s}} \ %{!shared:%:if-exists(default-manifest.o%s)}\ %{fvtable-verify=none:%s; \ fvtable-verify=preinit:vtv_end.o%s; \ diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h index a55f6b2b874..2f773924d6e 100644 --- a/gcc/config/i386/darwin.h +++ b/gcc/config/i386/darwin.h @@ -109,8 +109,8 @@ along with GCC; see the file COPYING3. If not see "%{!force_cpusubtype_ALL:-force_cpusubtype_ALL} " #undef ENDFILE_SPEC -#define ENDFILE_SPEC \ - "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ +#define ENDFILE_SPEC +\ "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!mno-daz-ftz:crtfastmath.o%s}} \ %{mpc32:crtprec32.o%s} \ %{mpc64:crtprec64.o%s} \ %{mpc80:crtprec80.o%s}" TM_DESTRUCTOR diff --git a/gcc/config/i386/gnu-user-common.h b/gcc/config/i386/gnu-user-common.h index 23b54c5be52..3d2a33f1714 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:crtfastmath.o%s} \ + "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!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 a3675e515bc..5cfb7cdcbc2 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/config/i386/mingw32.h b/gcc/config/i386/mingw32.h index d3ca0cd0279..ddbe6a4054b 100644 --- a/gcc/config/i386/mingw32.h +++ b/gcc/config/i386/mingw32.h @@ -197,7 +197,7 @@ along with GCC; see the file COPYING3. If not see #undef ENDFILE_SPEC #define ENDFILE_SPEC \ - "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ + "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!mno-daz-ftz:crtfastmath.o%s}} \ %{!shared:%:if-exists(default-manifest.o%s)}\ %{fvtable-verify=none:%s; \ fvtable-verify=preinit:vtv_end.o%s; \ diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index cb83dd8a1cc..87eedfffa6c 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1434,7 +1434,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 @@ -32078,6 +32078,15 @@ 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} is specified. + @item -mstackrealign @opindex mstackrealign Realign the stack at entry. On the x86, the @option{-mstackrealign} -- 2.39.1.388.g2fc9e9ca3c ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2023-05-10 9:07 ` [PATCH] " liuhongt @ 2023-05-12 5:43 ` Hongtao Liu 2023-05-15 1:16 ` Hongtao Liu 0 siblings, 1 reply; 27+ messages in thread From: Hongtao Liu @ 2023-05-12 5:43 UTC (permalink / raw) To: liuhongt; +Cc: gcc-patches, hjl.tools On Wed, May 10, 2023 at 5:10 PM liuhongt <hongtao.liu@intel.com> wrote: > > > The quoted patch shows -shared in context and you didn't post a > > backport version > > to look at. But yes, we shouldn't change -shared behavior on a > > branch, even less so make it > > inconsistent between targets. > Here's the patch. > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > Ok for GCC 11/12 backport? I'm going to push the patch next week if there's no objection. > > if (mdaz-ftz) > link crtfastmath.o > else if ((Ofast || ffast-math || funsafe-math-optimizations) > && !mno-daz-ftz) > link crtfastmath.o > else > Don't link crtfastmath.o > > gcc/ChangeLog: > > * config/i386/cygwin.h (ENDFILE_SPEC): Link crtfastmath.o > whenever -mdaz-ftz is specified. Don't link crtfastmath.o > when -mno-daz-ftz is specified. > * config/i386/darwin.h (ENDFILE_SPEC): Ditto. > * config/i386/gnu-user-common.h > (GNU_USER_TARGET_MATHFILE_SPEC): Ditto. > * config/i386/mingw32.h (ENDFILE_SPEC): Ditto. > * config/i386/i386.opt (mdaz-ftz): New option. > * doc/invoke.texi (x86 options): Document mftz-daz. > --- > gcc/config/i386/cygwin.h | 2 +- > gcc/config/i386/darwin.h | 4 ++-- > gcc/config/i386/gnu-user-common.h | 2 +- > gcc/config/i386/i386.opt | 4 ++++ > gcc/config/i386/mingw32.h | 2 +- > gcc/doc/invoke.texi | 11 ++++++++++- > 6 files changed, 19 insertions(+), 6 deletions(-) > > diff --git a/gcc/config/i386/cygwin.h b/gcc/config/i386/cygwin.h > index d06eda369cf..5412c5d4479 100644 > --- a/gcc/config/i386/cygwin.h > +++ b/gcc/config/i386/cygwin.h > @@ -57,7 +57,7 @@ along with GCC; see the file COPYING3. If not see > > #undef ENDFILE_SPEC > #define ENDFILE_SPEC \ > - "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}\ > + "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!mno-daz-ftz:crtfastmath.o%s}} \ > %{!shared:%:if-exists(default-manifest.o%s)}\ > %{fvtable-verify=none:%s; \ > fvtable-verify=preinit:vtv_end.o%s; \ > diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h > index a55f6b2b874..2f773924d6e 100644 > --- a/gcc/config/i386/darwin.h > +++ b/gcc/config/i386/darwin.h > @@ -109,8 +109,8 @@ along with GCC; see the file COPYING3. If not see > "%{!force_cpusubtype_ALL:-force_cpusubtype_ALL} " > > #undef ENDFILE_SPEC > -#define ENDFILE_SPEC \ > - "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ > +#define ENDFILE_SPEC > +\ "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!mno-daz-ftz:crtfastmath.o%s}} \ > %{mpc32:crtprec32.o%s} \ > %{mpc64:crtprec64.o%s} \ > %{mpc80:crtprec80.o%s}" TM_DESTRUCTOR > diff --git a/gcc/config/i386/gnu-user-common.h b/gcc/config/i386/gnu-user-common.h > index 23b54c5be52..3d2a33f1714 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:crtfastmath.o%s} \ > + "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!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 a3675e515bc..5cfb7cdcbc2 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/config/i386/mingw32.h b/gcc/config/i386/mingw32.h > index d3ca0cd0279..ddbe6a4054b 100644 > --- a/gcc/config/i386/mingw32.h > +++ b/gcc/config/i386/mingw32.h > @@ -197,7 +197,7 @@ along with GCC; see the file COPYING3. If not see > > #undef ENDFILE_SPEC > #define ENDFILE_SPEC \ > - "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ > + "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!mno-daz-ftz:crtfastmath.o%s}} \ > %{!shared:%:if-exists(default-manifest.o%s)}\ > %{fvtable-verify=none:%s; \ > fvtable-verify=preinit:vtv_end.o%s; \ > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > index cb83dd8a1cc..87eedfffa6c 100644 > --- a/gcc/doc/invoke.texi > +++ b/gcc/doc/invoke.texi > @@ -1434,7 +1434,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 > @@ -32078,6 +32078,15 @@ 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} is specified. > + > @item -mstackrealign > @opindex mstackrealign > Realign the stack at entry. On the x86, the @option{-mstackrealign} > -- > 2.39.1.388.g2fc9e9ca3c > -- BR, Hongtao ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR. 2023-05-12 5:43 ` Hongtao Liu @ 2023-05-15 1:16 ` Hongtao Liu 0 siblings, 0 replies; 27+ messages in thread From: Hongtao Liu @ 2023-05-15 1:16 UTC (permalink / raw) To: liuhongt; +Cc: gcc-patches, hjl.tools On Fri, May 12, 2023 at 1:43 PM Hongtao Liu <crazylht@gmail.com> wrote: > > On Wed, May 10, 2023 at 5:10 PM liuhongt <hongtao.liu@intel.com> wrote: > > > > > The quoted patch shows -shared in context and you didn't post a > > > backport version > > > to look at. But yes, we shouldn't change -shared behavior on a > > > branch, even less so make it > > > inconsistent between targets. > > Here's the patch. > > > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > > Ok for GCC 11/12 backport? > I'm going to push the patch next week if there's no objection. pushed to gcc-11/gcc-12 branch. > > > > if (mdaz-ftz) > > link crtfastmath.o > > else if ((Ofast || ffast-math || funsafe-math-optimizations) > > && !mno-daz-ftz) > > link crtfastmath.o > > else > > Don't link crtfastmath.o > > > > gcc/ChangeLog: > > > > * config/i386/cygwin.h (ENDFILE_SPEC): Link crtfastmath.o > > whenever -mdaz-ftz is specified. Don't link crtfastmath.o > > when -mno-daz-ftz is specified. > > * config/i386/darwin.h (ENDFILE_SPEC): Ditto. > > * config/i386/gnu-user-common.h > > (GNU_USER_TARGET_MATHFILE_SPEC): Ditto. > > * config/i386/mingw32.h (ENDFILE_SPEC): Ditto. > > * config/i386/i386.opt (mdaz-ftz): New option. > > * doc/invoke.texi (x86 options): Document mftz-daz. > > --- > > gcc/config/i386/cygwin.h | 2 +- > > gcc/config/i386/darwin.h | 4 ++-- > > gcc/config/i386/gnu-user-common.h | 2 +- > > gcc/config/i386/i386.opt | 4 ++++ > > gcc/config/i386/mingw32.h | 2 +- > > gcc/doc/invoke.texi | 11 ++++++++++- > > 6 files changed, 19 insertions(+), 6 deletions(-) > > > > diff --git a/gcc/config/i386/cygwin.h b/gcc/config/i386/cygwin.h > > index d06eda369cf..5412c5d4479 100644 > > --- a/gcc/config/i386/cygwin.h > > +++ b/gcc/config/i386/cygwin.h > > @@ -57,7 +57,7 @@ along with GCC; see the file COPYING3. If not see > > > > #undef ENDFILE_SPEC > > #define ENDFILE_SPEC \ > > - "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}\ > > + "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!mno-daz-ftz:crtfastmath.o%s}} \ > > %{!shared:%:if-exists(default-manifest.o%s)}\ > > %{fvtable-verify=none:%s; \ > > fvtable-verify=preinit:vtv_end.o%s; \ > > diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h > > index a55f6b2b874..2f773924d6e 100644 > > --- a/gcc/config/i386/darwin.h > > +++ b/gcc/config/i386/darwin.h > > @@ -109,8 +109,8 @@ along with GCC; see the file COPYING3. If not see > > "%{!force_cpusubtype_ALL:-force_cpusubtype_ALL} " > > > > #undef ENDFILE_SPEC > > -#define ENDFILE_SPEC \ > > - "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ > > +#define ENDFILE_SPEC > > +\ "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!mno-daz-ftz:crtfastmath.o%s}} \ > > %{mpc32:crtprec32.o%s} \ > > %{mpc64:crtprec64.o%s} \ > > %{mpc80:crtprec80.o%s}" TM_DESTRUCTOR > > diff --git a/gcc/config/i386/gnu-user-common.h b/gcc/config/i386/gnu-user-common.h > > index 23b54c5be52..3d2a33f1714 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:crtfastmath.o%s} \ > > + "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!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 a3675e515bc..5cfb7cdcbc2 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/config/i386/mingw32.h b/gcc/config/i386/mingw32.h > > index d3ca0cd0279..ddbe6a4054b 100644 > > --- a/gcc/config/i386/mingw32.h > > +++ b/gcc/config/i386/mingw32.h > > @@ -197,7 +197,7 @@ along with GCC; see the file COPYING3. If not see > > > > #undef ENDFILE_SPEC > > #define ENDFILE_SPEC \ > > - "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ > > + "%{mdaz-ftz:crtfastmath.o%s;Ofast|ffast-math|funsafe-math-optimizations:%{!mno-daz-ftz:crtfastmath.o%s}} \ > > %{!shared:%:if-exists(default-manifest.o%s)}\ > > %{fvtable-verify=none:%s; \ > > fvtable-verify=preinit:vtv_end.o%s; \ > > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > > index cb83dd8a1cc..87eedfffa6c 100644 > > --- a/gcc/doc/invoke.texi > > +++ b/gcc/doc/invoke.texi > > @@ -1434,7 +1434,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 > > @@ -32078,6 +32078,15 @@ 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} is specified. > > + > > @item -mstackrealign > > @opindex mstackrealign > > Realign the stack at entry. On the x86, the @option{-mstackrealign} > > -- > > 2.39.1.388.g2fc9e9ca3c > > > > > -- > BR, > Hongtao -- BR, Hongtao ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH V2 1/2] x86: Don't add crtfastmath.o for -shared 2022-12-15 6:21 ` [PATCH V2 1/2] x86: Don't add crtfastmath.o for -shared liuhongt 2022-12-15 6:21 ` [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR liuhongt @ 2022-12-16 9:50 ` Uros Bizjak 1 sibling, 0 replies; 27+ messages in thread From: Uros Bizjak @ 2022-12-16 9:50 UTC (permalink / raw) To: liuhongt; +Cc: gcc-patches, crazylht, hjl.tools On Thu, Dec 15, 2022 at 7:23 AM liuhongt <hongtao.liu@intel.com> wrote: > > Update in V2: > Split -shared change into a separate commit and add some documentation > for it. > Bootstrapped and regtested on x86_64-pc-linu-gnu{-m32,}. > Ok of trunk? > > Don't add crtfastmath.o for -shared to avoid changing the MXCSR register > when loading a shared library. crtfastmath.o will be used only when > building executables. > > PR target/55522 > * config/i386/gnu-user-common.h (GNU_USER_TARGET_MATHFILE_SPEC): > Don't add crtfastmath.o for -shared. > * doc/invoke.texi (-shared): Add related documentation. OK. Thanks, Uros. > --- > gcc/config/i386/gnu-user-common.h | 2 +- > gcc/doc/invoke.texi | 3 ++- > 2 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/gcc/config/i386/gnu-user-common.h b/gcc/config/i386/gnu-user-common.h > index cab9be2bfb7..9910cd64363 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:crtfastmath.o%s} \ > + "%{Ofast|ffast-math|funsafe-math-optimizations:%{!shared:crtfastmath.o%s}} \ > %{mpc32:crtprec32.o%s} \ > %{mpc64:crtprec64.o%s} \ > %{mpc80:crtprec80.o%s}" > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > index cb40b38b73a..cba4f19f4f4 100644 > --- a/gcc/doc/invoke.texi > +++ b/gcc/doc/invoke.texi > @@ -17656,7 +17656,8 @@ needs to build supplementary stub code for constructors to work. On > multi-libbed systems, @samp{gcc -shared} must select the correct support > libraries to link against. Failing to supply the correct flags may lead > to subtle defects. Supplying them in cases where they are not necessary > -is innocuous.} > +is innocuous. For x86, crtfastmath.o will not be added when > +@option{-shared} is specified. } > > @item -shared-libgcc > @itemx -static-libgcc > -- > 2.27.0 > ^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2023-05-15 1:17 UTC | newest] Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-12-14 2:18 [PATCH] [x86] x86: Don't add crtfastmath.o for -shared and add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR liuhongt 2022-12-14 8:08 ` Richard Biener 2022-12-14 8:16 ` Jakub Jelinek 2022-12-14 8:23 ` Richard Biener 2022-12-14 8:34 ` Liu, Hongtao 2022-12-14 8:52 ` Richard Biener 2022-12-14 9:07 ` Uros Bizjak 2022-12-15 6:21 ` [PATCH V2 1/2] x86: Don't add crtfastmath.o for -shared liuhongt 2022-12-15 6:21 ` [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR liuhongt 2022-12-15 7:39 ` Jakub Jelinek 2022-12-15 7:45 ` Hongtao Liu 2022-12-20 4:51 ` Hongtao Liu 2022-12-21 20:20 ` H.J. Lu 2022-12-21 22:35 ` Jakub Jelinek 2022-12-21 22:43 ` H.J. Lu 2022-12-21 22:46 ` Jakub Jelinek 2022-12-22 4:40 ` Hongtao Liu 2022-12-22 8:04 ` Uros Bizjak 2023-05-04 5:35 ` Hongtao Liu 2023-05-04 5:36 ` Hongtao Liu 2023-05-04 9:49 ` Richard Biener 2023-05-10 1:41 ` Hongtao Liu 2023-05-10 6:41 ` Richard Biener 2023-05-10 9:07 ` [PATCH] " liuhongt 2023-05-12 5:43 ` Hongtao Liu 2023-05-15 1:16 ` Hongtao Liu 2022-12-16 9:50 ` [PATCH V2 1/2] x86: Don't add crtfastmath.o for -shared Uros Bizjak
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).