From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by sourceware.org (Postfix) with ESMTPS id 6C6073833A32 for ; Wed, 14 Dec 2022 08:52:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6C6073833A32 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-lj1-x22f.google.com with SMTP id l8so5944588ljh.13 for ; Wed, 14 Dec 2022 00:52:30 -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=2P+kksKFDgmJAFyUvY4YeOJ9yWhqMd428lUxmTUtNnM=; b=nLXeckSsKsyrUeZLSTJ9U7PNyczPLe076o/Dr6T9gn0qv99cOX9i1Bxgq29HO7+FVU hKkYjgjUdQ7v62XFhLe5BmV2tgkqPmFxBzsV7NvaNKOe4uo14fOhOYgHyAPHcSsuDhNa NLd3NOFCPH5bK8qulwnRHblW9ABij7RgOn0Nmh+LwD01AyppMT3SWOn7aS81RSELQ90e 73Q7s5SJhTt0tCNYxBKTaqtnWhEY97U6idpIYRFRPzgkcAXZou/PsFs6SI+XUtO4i/NE AolUsZIkWLS4SV0KAqMoxeZp7ut+JoSc7sjfyJzXdEVHyVyEh//0w4NgGZ1mF1a4gM1N yFkg== 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=2P+kksKFDgmJAFyUvY4YeOJ9yWhqMd428lUxmTUtNnM=; b=KZze1D3/zaslY11mB43yoe4WSDvY/t8JyhxB6LlJHEPvMn6QhEWIpMrIKZ3awuhvw+ B3FyzTttB4PDQ/jyleuMx+e9X0KQvHyZpNa2ZIAGr5ofwlIY5ACqMiuDZUhaJUM2IOci nWJKFPSkQHO9jL1X+kOM80dZeBq7YtoEcJC4mRolWxNvJrwk3/Mc694inbUkp3re6Laq l1p4eKz8Uid+TorhIjTgiNi6RT7Q3IUI+Aqx6OkwMx7o67KUdbiDJuEmq3Mx7T8zsTxT nNlCMWZRxDfcvw/PaxZjR4QdlKorO7WpymcLlKEOa9xhajKhTYcUYLONQwVnEpopiw6q Yn5A== X-Gm-Message-State: ANoB5pkHHtNCGAW3NSDbtyhEYHCyPShK6V1UYY6UiFNXqdvIZOOmXYrW CM3Ld0kgDQYOoKNEgEavo7blZDNSnAQde1+wPN8= X-Google-Smtp-Source: AA0mqf7mOhx6psCj5h1LzIAEh0gldbzyUsVidtkl57dBSISMN1NDOzAQx2j+VQir1iTuAI/MBadMIX+GAnLq0BaS+mM= X-Received: by 2002:a2e:b5b3:0:b0:279:86ec:a686 with SMTP id f19-20020a2eb5b3000000b0027986eca686mr20800395ljn.399.1671007948711; Wed, 14 Dec 2022 00:52:28 -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:52:16 +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: "Liu, Hongtao" Cc: Jakub Jelinek , "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.4 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: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. 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 > > >