From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 106B73858C20 for ; Tue, 16 Aug 2022 09:28:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 106B73858C20 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 1C13D33B02; Tue, 16 Aug 2022 09:28:39 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (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 146622C143; Tue, 16 Aug 2022 09:28:39 +0000 (UTC) Date: Tue, 16 Aug 2022 09:28:38 +0000 (UTC) From: Richard Biener To: Aldy Hernandez cc: gcc-patches , "MacLeod, Andrew" Subject: Re: [PATCH] Tame path_range_query::compute_imports In-Reply-To: Message-ID: References: <73820.122081107421800679@us-mta-533.us.mimecast.lan> User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Tue, 16 Aug 2022 09:28:41 -0000 On Tue, 16 Aug 2022, Aldy Hernandez wrote: > On Tue, Aug 16, 2022 at 11:08 AM Aldy Hernandez wrote: > > > > On Tue, Aug 16, 2022 at 10:32 AM Richard Biener wrote: > > > > > > On Tue, 16 Aug 2022, Aldy Hernandez wrote: > > > > > > > On Thu, Aug 11, 2022 at 1:42 PM Richard Biener wrote: > > > > > > > > > @@ -599,6 +592,30 @@ path_range_query::compute_imports (bitmap imports, const vec &path) > > > > > worklist.safe_push (arg); > > > > > } > > > > > } > > > > > + else if (gassign *ass = dyn_cast (def_stmt)) > > > > > + { > > > > > + tree ssa[3]; > > > > > + if (range_op_handler (ass)) > > > > > + { > > > > > + ssa[0] = gimple_range_ssa_p (gimple_range_operand1 (ass)); > > > > > + ssa[1] = gimple_range_ssa_p (gimple_range_operand2 (ass)); > > > > > + ssa[2] = NULL_TREE; > > > > > + } > > > > > + else if (gimple_assign_rhs_code (ass) == COND_EXPR) > > > > > + { > > > > > + ssa[0] = gimple_range_ssa_p (gimple_assign_rhs1 (ass)); > > > > > + ssa[1] = gimple_range_ssa_p (gimple_assign_rhs2 (ass)); > > > > > + ssa[2] = gimple_range_ssa_p (gimple_assign_rhs3 (ass)); > > > > > + } > > > > > + else > > > > > + continue; > > > > > + for (unsigned j = 0; j < 3; ++j) > > > > > + { > > > > > + tree rhs = ssa[j]; > > > > > + if (rhs && add_to_imports (rhs, imports)) > > > > > + worklist.safe_push (rhs); > > > > > + } > > > > > + } > > > > > > > > We seem to have 3 copies of this copy now: this one, the > > > > threadbackward one, and the original one. > > > > > > > > Could we abstract this somehow? > > > > > > I've thought about this but didn't find any good solution since the > > > use of the operands is always a bit different. But I was wondering > > > why/if the COND_EXPR special-casing is necessary, that is, why > > > don't we have a range_op_handler for it and if we don't why > > > do we care about it? > > > > I think it's because we don't have a range-op handler for COND_EXPR, > > opting to handle the relational operators instead in range-ops. We > > have similar code in the folder: > > > > if (range_op_handler (s)) > > res = range_of_range_op (r, s, src); > > else if (is_a(s)) > > res = range_of_phi (r, as_a (s), src); > > else if (is_a(s)) > > res = range_of_call (r, as_a (s), src); > > else if (is_a (s) && gimple_assign_rhs_code (s) == COND_EXPR) > > res = range_of_cond_expr (r, as_a (s), src); > > > > Andrew, do you have any suggestions here? > > Hmmm, so thinking about this, perhaps special casing it is the way to go ?? It looks like so. Though a range_op_handler could, for _1 = _2 ? _3 : _4; derive a range for _3 from _1 if _2 is known true?