From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by sourceware.org (Postfix) with ESMTPS id D23B43834C14 for ; Wed, 14 Dec 2022 08:23:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D23B43834C14 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-x136.google.com with SMTP id q6so9163506lfm.10 for ; Wed, 14 Dec 2022 00:23:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=j8ZTiKZkgzgkNikxGjGq1qZBWBf8RrAmDZzhlWe+vqU=; b=l9/e2jRGbbZXqNLFBZyjQgaP+VHEmS58aquV3b6Xyf4bKiv8BlsA2pwCo4zfzVSADT iRz00TJE/yGLsKV5dsxNpFXz72UtF+7U7uJTcbuiTKtb1I0+/ZCH3+rsvJ3+r+Wih6ZJ LLHCjXeLoj+UiDpTmRKd2+YnCnND28jlIddIpy7Y+fTuMC+bm+1tB1LdiPeA6Ac6QUa4 /JlGTyXZ0Lf5Z1L9Qv3mO8OLMPE/PaOQaRGrJG5Q5Ppe7ZFS6l6Ubd+tfmqk6fPNCdvM Ahx1XfRJfxqtYFwjXdFvm+TwCOAWNGv8Lk8q3Q73e2p9VjzyBkt4Low65FfxAsbpnn/e sLCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=j8ZTiKZkgzgkNikxGjGq1qZBWBf8RrAmDZzhlWe+vqU=; b=QSKXqb12+7ir8J3x7Ggvpw9DJSlMb+pL1BcxLqtFJNq9y7w55rMQ1w+3hNJUq7Rgfk qLQejCXMn11BBGOwTZdrvBl+ygbRKWnYiULkqPHglKOIe9rYvu7wokpyLYez7XANoOo8 4fyiEpU1YPWVbOrR1MyufcQ3bZOUYst9CuP96OEhX4dKyFwvvcsMLhv2Zrl0hgW3CDzw +OPcGIdlr8F/jTfs2bEyTnwLDmgBDlQ/9N4k29clVLR3rukLp+RFhOYGcWyFHWQbKqqb n70hFtbw2rHjOpiqUHzQpDSkOW3XJRdgnrB1E2HITFyvCpkMwzqKTnElVuUakkNpO2xA lhqw== X-Gm-Message-State: ANoB5pn4x4wAiBNyT5bfSLE1wpb0xcZYL3iAjZxRiaOxkm/6XtH5wDA7 iQmBXgXFrPX1yPWTseWgIueKeoBmeufjtcNGPkY= X-Google-Smtp-Source: AA0mqf6imiWIHJ7zcd+StP+eYNjjomzOwKbkq0EOiHGINz03RZ/s3B9xLSxqtz8QujWpguJy326StuhII9Hz5tLlslQ= X-Received: by 2002:a05:6512:3a96:b0:4b4:f5da:fb28 with SMTP id q22-20020a0565123a9600b004b4f5dafb28mr21861862lfu.169.1671006210313; Wed, 14 Dec 2022 00:23:30 -0800 (PST) MIME-Version: 1.0 References: <20221214021842.1015348-1-hongtao.liu@intel.com> In-Reply-To: From: Richard Biener Date: Wed, 14 Dec 2022 09:23:18 +0100 Message-ID: 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. To: Jakub Jelinek Cc: liuhongt , gcc-patches@gcc.gnu.org, crazylht@gmail.com, hjl.tools@gmail.com, ubizjak@gmail.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, Dec 14, 2022 at 9:16 AM Jakub Jelinek 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 > > 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 >