From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id D5B0E3857400 for ; Mon, 12 Dec 2022 21:58:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D5B0E3857400 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=none smtp.mailfrom=kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 057F128088F; Mon, 12 Dec 2022 22:58:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1670882324; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tpU7ULP/x4q3QiqaPwWtmpYwpZgq2Vjf7qS6GfJv9y4=; b=SXLDY+oKoe5tranwp3mc5j23Lz9qKHMmWICb3YFNe7B1fNtwaT/l0PgeJQLtwN3E2lHXEU yIE30wSCpOPhhVcqHN2bkcZRFyojNfay7rGBatJGCVWdprA4PWDv5VOuVeV0gkbBFqORQU zCliRKf3DmmY3bFHFPfY7UuJ0S8eGb0= Date: Mon, 12 Dec 2022 22:58:43 +0100 From: Jan Hubicka To: Martin Jambor , rguenther@suse.de Cc: GCC Patches Subject: Re: [PATCH 8/9] ipa-sra: Make scan_expr_access bail out on uninteresting expressions Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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: > > Hi, > > > > I'm re-posting patches which I have posted at the end of stage 1 but > > which have not passed review yet. > > > > 8<-------------------------------------------------------------------- > > > > I have noticed that scan_expr_access passes all the expressions it > > gets to get_ref_base_and_extent even when we are really only > > interested in memory accesses. So bail out when the expression is > > something clearly uninteresting. > > > > Bootstrapped and tested individually when I originally posted it and > > now bootstrapped and LTO-bootstrapped and tested as part of the whole > > series. OK for master? > > > > > > gcc/ChangeLog: > > > > 2021-12-14 Martin Jambor > > > > * ipa-sra.c (scan_expr_access): Bail out early if expr is something we > > clearly do not need to pass to get_ref_base_and_extent. > > --- > > gcc/ipa-sra.cc | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/gcc/ipa-sra.cc b/gcc/ipa-sra.cc > > index 93fceeafc73..3646d71468c 100644 > > --- a/gcc/ipa-sra.cc > > +++ b/gcc/ipa-sra.cc > > @@ -1748,6 +1748,11 @@ scan_expr_access (tree expr, gimple *stmt, isra_scan_context ctx, > > || TREE_CODE (expr) == REALPART_EXPR) > > expr = TREE_OPERAND (expr, 0); > > > > + if (!handled_component_p (expr) > > + && !DECL_P (expr) > > + && TREE_CODE (expr) != MEM_REF) > > + return; > Is this needed because get_ref_base_and_extend crashes if given SSA_NAME > or something else or is it just optimization? > Perhaps Richi will know if there is better test for this. Looking at: static inline bool gimple_assign_load_p (const gimple *gs) { tree rhs; if (!gimple_assign_single_p (gs)) return false; rhs = gimple_assign_rhs1 (gs); if (TREE_CODE (rhs) == WITH_SIZE_EXPR) return true; rhs = get_base_address (rhs); return (DECL_P (rhs) || TREE_CODE (rhs) == MEM_REF || TREE_CODE (rhs) == TARGET_MEM_REF); } I wonder if we don't want to avoid get_base_address (which is loopy) and use same check and move it into a new predicate that is more convenient to use? Honza > > Honza > > + > > base = get_ref_base_and_extent (expr, &poffset, &psize, &pmax_size, &reverse); > > > > if (TREE_CODE (base) == MEM_REF) > > -- > > 2.38.1 > >