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