From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com [IPv6:2607:f8b0:4864:20::112b]) by sourceware.org (Postfix) with ESMTPS id 29AED3833091 for ; Wed, 14 Dec 2022 09:07:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 29AED3833091 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-yw1-x112b.google.com with SMTP id 00721157ae682-3f15a6f72d0so227830907b3.1 for ; Wed, 14 Dec 2022 01:07:49 -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=zLd9JYyiYTCLRS67Q+J+U1W47nxgT63oox7NYu/GQpI=; b=IPQYoi/elN9YggRdLnHx3XvhPEy/Pp80IZcMxxHzhRu3b4aTTqvdI6rhNrFa2DNJLZ 65jfxPW3aihRJvPX1mEXSDlVNeeK8GYnmzBRAQnNkBdj+0gL5zJCB1w6j62mvOSiiINK 1CzDQBaQ8lJ5x51jNSDjkVty/78SsGOHjcuVXrUjNbncxwHfKAMXaDiXguDrSteNrXrI IsYtezGBvLqmOPbMSiGqPKEVOZc6XeZIIR8FM/1utlYigqe30chDGS1+nuR+Rh1CnyKQ BXTfRMfBUlRBTNqpyIjqv1n3Fh8xJ4VedpWMd7ZN9ErWP0/mXnoq3PALDCTV5Se0wHxz tVdQ== 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=zLd9JYyiYTCLRS67Q+J+U1W47nxgT63oox7NYu/GQpI=; b=Iqx+5t/0omOvv52wN7l01iWUPQCmVLzT0La/FyhcWUv4USkYHn+CAVmqoYiTQDDwUQ kYGWvp3pAlaMCAD3gosug1x5pGXTZ9KBYkn/quMjExnDDo6D1noBqdQJVJdHUOScc1qd LBOOPz5MwRERwbKviSCc/r8kP1j4p/mS9UnQjPq5N4+yK59oKX3nq7IVAcSBWlSHs6n2 TAX/mF3DKDXWqIim8vc8o55macSPxqrG3NA1boIb9eWKP9DrbgmItdPIzdj7UflQxvJC 6B/CdCAj7sGJU1zQK1DWKKClo7n0FXz7D8KTQ8VmPnKbyHF2QxJgy3CMavfDlBVMtbzm icyA== X-Gm-Message-State: ANoB5pl9wXkNnuNnCMeLzkbhEbGjrTXOStqi+cm+x32k4sJuTpVYRcgz qT12hvpJ/IlM7u3mo6++b9JcYrWNkKe1m10q4OE= X-Google-Smtp-Source: AA0mqf5fpcpeqJkje8Bo/Np0IZpw8c/s7ZteMzstY3jGi3XnM+RGDv61vaH9pWORDpRQ3s3BY6lGMYDvHWQVYdttz5s= X-Received: by 2002:a81:1b88:0:b0:360:7f0a:1620 with SMTP id b130-20020a811b88000000b003607f0a1620mr8972089ywb.192.1671008868452; Wed, 14 Dec 2022 01:07:48 -0800 (PST) MIME-Version: 1.0 References: <20221214021842.1015348-1-hongtao.liu@intel.com> In-Reply-To: From: Uros Bizjak Date: Wed, 14 Dec 2022 10:07:37 +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: Richard Biener Cc: "Liu, Hongtao" , Jakub Jelinek , "gcc-patches@gcc.gnu.org" , "crazylht@gmail.com" , "hjl.tools@gmail.com" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,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:52 AM Richard Biener wrote: > > On Wed, Dec 14, 2022 at 9:34 AM Liu, Hongtao wrote: > > > > > > > > > -----Original Message----- > > > From: Richard Biener > > > Sent: Wednesday, December 14, 2022 4:23 PM > > > To: Jakub Jelinek > > > Cc: Liu, Hongtao ; 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 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. > > 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 > > > >