From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 951673858D34 for ; Mon, 26 Jul 2021 16:09:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 951673858D34 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 5F55521FC6; Mon, 26 Jul 2021 16:09:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1627315745; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2BVvn1dM5iqPrp2YLiACa36htgqV/tICXyXnpbfkm0I=; b=SeCAMJN//ylDUQcU1qi1tP8Mch7/g23gdIvobgxMT9Z/9X8XgkPi3xX6Td+cQ5Vu+Lib76 CH+OKQ1M/G8QnHEBEq45g+smFJMRFGtgJUzjJvqqtFhoUTYJqXXOf4bkqyIltClIv0BoBu Fz4TFL+DoZq9bh4PVjt0G9YmZMvLc1Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1627315745; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2BVvn1dM5iqPrp2YLiACa36htgqV/tICXyXnpbfkm0I=; b=foiFFxA8hvRFqPYj3T8/+QjKjlgi+/j6+UvAAXo6dFBEVjJS1pFsjOsphvu9AVmSqaY7TI iZKK8627RJF/DQBg== Received: from suse.cz (virgil.suse.cz [10.100.13.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 3FE2FA3B8A; Mon, 26 Jul 2021 16:09:05 +0000 (UTC) From: Martin Jambor To: Qing Zhao Cc: Richard Biener , Richard Sandiford , Jakub Jelinek , kees cook , GCC Patches Subject: Re: [patch][version5]add -ftrivial-auto-var-init and variable attribute "uninitialized" to gcc In-Reply-To: <95FCC810-FF00-4894-B643-6C5823E9C590@oracle.com> References: <95FCC810-FF00-4894-B643-6C5823E9C590@oracle.com> User-Agent: Notmuch/0.32.2 (https://notmuchmail.org) Emacs/27.2 (x86_64-suse-linux-gnu) Date: Mon, 26 Jul 2021 18:09:05 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jul 2021 16:09:08 -0000 Hi, On Mon, Jul 26 2021, Qing Zhao wrote: > HI, Martin, > > Thank you for the comments and suggestions on tree-sra.c changes. > >>> ******Compare with the 4th version, the following are the major changes: >>>=20 >>> 1. delete the code for handling "grp_to_be_debug_replaced" since they a= re not needed per Martin Jambor's suggestion. >>=20 >> sorry if I did not make myself clear in my last email, but the deferred >> init calls should not result into setting any bits in >> cannot_scalarize_away_bitmap in the SRA pass, otherwise you'll get >> different optimization with and without -ftrivial-auto-var-init. > > It=E2=80=99s my bad that I missed this part of your comments=E2=80=A6 > >>=20 >> So you either need to change build_access_from_expr like I described in >> my email > > Is the following the change you suggested previously: > > [opc@qinzhao-ol8u3-x86 gcc]$ git diff tree-sra.c > diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c > index d1280e5f8848..c2597b705169 100644 > --- a/gcc/tree-sra.c > +++ b/gcc/tree-sra.c > @@ -1195,8 +1195,10 @@ build_access_from_expr (tree expr, gimple *stmt, b= ool write) > { > /* This means the aggregate is accesses as a whole in a way other = than an > assign statement and thus cannot be removed even if we had a sca= lar > - replacement for everything. */ > - if (cannot_scalarize_away_bitmap) > + replacement for everything. However, when the STMT is a call to > + DEFERRED_INIT, we should not set this bit. */ > + if (cannot_scalarize_away_bitmap=20 > + && !gimple_call_internal_p (stmt, IFN_DEFERRED_INIT)) > bitmap_set_bit (cannot_scalarize_away_bitmap, DECL_UID (access->b= ase)); > return true; > } > Yes, although I think that the one I wrote today is more efficient as it tests for IFN_DEFERRED_INIT only if we already know stmt is a call and also philosophically more correct as the test is performed only for the LHS of the statement (I don't think either reason matters much in practice, though). > >> or add the following to your patch, which is probably slightly >> mor efficient (but it has been only very mildly tested). >>=20 >>=20 >> diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c >> index d1280e5f884..602b0fb3a2d 100644 >> --- a/gcc/tree-sra.c >> +++ b/gcc/tree-sra.c >> @@ -1395,7 +1395,12 @@ scan_function (void) >>=20 >> t =3D gimple_call_lhs (stmt); >> if (t && !disqualify_if_bad_bb_terminating_stmt (stmt, t, N= ULL)) >> - ret |=3D build_access_from_expr (t, stmt, true); >> + { >> + if (gimple_call_internal_p (stmt, IFN_DEFERRED_INIT)) >> + ret |=3D !!build_access_from_expr_1 (t, stmt, true); >> + else >> + ret |=3D build_access_from_expr (t, stmt, true); >> + } >> break; > > Thanks for the patch, but I don=E2=80=99t quite understand the above chan= ge: > > When the call is IFN_DEFERRED_INIT, you used build_access_from_expr_1 ins= tead of build_access_from_expr to avoid setting =E2=80=9Ccannot_scalarize_a= way_bitmap=E2=80=9D bit. > But why adding =E2=80=9C!=E2=80=9D To this call? Note that it is a double !! which is basically a fancy way to convert a test for non-NULL to a bool. It is equivalent to: + if (gimple_call_internal_p (stmt, IFN_DEFERRED_INIT)) + ret |=3D (build_access_from_expr_1 (t, stmt, true) !=3D= NULL); + else + ret |=3D build_access_from_expr (t, stmt, true); use whichever variant you like better. But the !! trick is used throughout the gcc source already. Martin