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 B60483858CDA for ; Wed, 26 Apr 2023 10:30:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B60483858CDA 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 3762728A995; Wed, 26 Apr 2023 12:30:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1682505030; 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=EWrarznvupbqoYvs877avS9UNHDu1ZKT8DBzl5vHmAE=; b=kSO2Tdn4MHQYXDfSVQE56eSKqtvKK5SiDV+1dJC1jScVN7RSczisOKK8A+1p9MOAOFPHwd gyyDDf1sHeqLgdU493K0bDUPFFwXVqmdARKfFgGAkBBtKkyhAs2WR8mArE/nGihOuYDrq+ qBHqp2MlxL9eOBTVNT/27IgEdEAnZDY= Date: Wed, 26 Apr 2023 12:30:30 +0200 From: Jan Hubicka To: Richard Biener Cc: Bernhard Reutner-Fischer , Jan Hubicka via Gcc-patches Subject: Re: Unloop no longer looping loops in loop-ch Message-ID: References: <116D73F6-1281-4378-9F26-E4A47DF46775@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > > - if (precise) > > + if (precise > > + && get_max_loop_iterations_int (loop) == 1) > > + { > > + if (dump_file && (dump_flags & TDF_DETAILS)) > > + fprintf (dump_file, "Loop %d no longer loops.\n", loop->num); > > but max loop iterations is 1 ...? I first check for loops with 0 iterations, push them to unlooping list and avoid any header copying (it is useless). At this patch we already did header duplication and verified that the maximal number of iterations will drop by 1 since there is no way loop can terminate except for the header tests we peeled out. So 1 would turn to 0 in the loop info update and it seems useless to do it. > > > + loops_to_unloop.safe_push (loop); > > + loops_to_unloop_nunroll.safe_push (0); > > + } > > + else if (precise) > > { > > if (dump_file && (dump_flags & TDF_DETAILS)) > > fprintf (dump_file, > > @@ -688,6 +699,12 @@ ch_base::copy_headers (function *fun) > > BITMAP_FREE (exit_bbs); > > } > > } > > + if (loops_to_unloop.length()) > > !loops_to_unloop.is_empty () I updated that in my copy of the patch. > > > + { > > + bool irred_invalidated; > > + unloop_loops (loops_to_unloop, loops_to_unloop_nunroll, NULL, &irred_invalidated); > > + changed = true; > > + } > > free (bbs); > > free (copied_bbs); > > > Since we run VN on the header copies I wonder if, since you remove > edges, we need to run CFG cleanup before this and updating SSA form? > For safety we usually let CFG cleanup do the actual CFG manipulation > and just change cond jumps to if (0) or if (1)? I do unlooping only after the VN so I think I am safe here. Honza