From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 345F93858D38 for ; Wed, 6 Dec 2023 08:22:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 345F93858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 345F93858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701850937; cv=none; b=COd+y1TBUsEe6CjpqnbYdqYS1i6OTncEnZ+7SEY8OjxHtPDnIHfCkk5gt/k9BbdFXv12ROubWtVYJl1ENo5m6TkP9CjY4u3+6mOSlB1IlGvxG6aCmnkMnh0PPKRmMbBF3bkirsNDCddbHdzyI7Uc7x2xdgdbUeCfb3lBypQc4n0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701850937; c=relaxed/simple; bh=M7uaJjuGeD3jv9ieXMh6aPHu1h4Cpp3EMF9ZJ7o+PC4=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=exP/IZgcjwWAugECXGieLQn7fTkD6fEYvyTJOQxxBFZVO36JapH+FzKNv2rNzXxkEFOctjxLX7E2NXiyXOOUBhcNuO1ZHz/yvY7qUOtDbi9sMbN2oJJjKCNTYa1nYZh5KdbLmhtjJCJGVFan2VYz9IWN4/2hmRM7bqeODz4DKQ4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.4.150] (unknown [10.168.4.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id BC5301FB8D; Wed, 6 Dec 2023 08:22:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1701850928; h=from:from:reply-to: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=mlT9fXarA4tAs//7C9cJrB4Cz3BZWXhEe50imBpD8Ho=; b=xDZzNkeMEe9xoqMpQ20roFKjseTx/Xm7VyvXIXSsKzqFD4DYhYj7TST754cyAHCEZh/VX2 LC7ywDiI3+JKCXs9Jb4MZuYZt0Yy0jlMTPctLxtIUMX3l/IcETTq1qGQePiFb4PLcEPm18 1w42CaIoFkQbkV1ihUDtvC6n8h28ejs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1701850928; h=from:from:reply-to: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=mlT9fXarA4tAs//7C9cJrB4Cz3BZWXhEe50imBpD8Ho=; b=TJQslMiDlnRjJ+6Glrkf3Z2h5mumEjd6yK3kF6Ndvt5Mk0LMV47RbNFe2kQ8+6/URwH2Cw Drd1hxyp1tXATFCQ== Date: Wed, 6 Dec 2023 09:18:23 +0100 (CET) From: Richard Biener To: Tamar Christina cc: gcc-patches@gcc.gnu.org, nd@arm.com, jlaw@ventanamicro.com Subject: Re: [PATCH 13/21]middle-end: Update loop form analysis to support early break In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -0.10 X-Spamd-Result: default: False [-0.10 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_SPAM_SHORT(3.00)[1.000]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[tree-vect-loop.cc:url]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-3.00)[100.00%] X-Spam-Status: No, score=-11.6 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,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 List-Id: On Mon, 6 Nov 2023, Tamar Christina wrote: > Hi All, > > This sets LOOP_VINFO_EARLY_BREAKS and does some misc changes so the other > patches are self contained. > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > Ok for master? > > Thanks, > Tamar > > gcc/ChangeLog: > > * tree-vect-loop.cc (vect_analyze_loop_form): Analyse all exits. > (vect_create_loop_vinfo): Set LOOP_VINFO_EARLY_BREAKS. > (vect_transform_loop): Use it. > > --- inline copy of patch -- > diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc > index 51a054c5b035ac80dfbbf3b5ba2f6da82fda91f6..f9483eff6e9606e835906fb991f07cd6052491d0 100644 > --- a/gcc/tree-vect-loop.cc > +++ b/gcc/tree-vect-loop.cc > @@ -1700,12 +1700,12 @@ vect_compute_single_scalar_iteration_cost (loop_vec_info loop_vinfo) > loop_vinfo->scalar_costs->finish_cost (nullptr); > } > > - > /* Function vect_analyze_loop_form. > > Verify that certain CFG restrictions hold, including: > - the loop has a pre-header > - - the loop has a single entry and exit > + - the loop has a single entry > + - nested loops can have only a single exit. > - the loop exit condition is simple enough > - the number of iterations can be analyzed, i.e, a countable loop. The > niter could be analyzed under some assumptions. */ > @@ -1841,10 +1841,14 @@ vect_analyze_loop_form (class loop *loop, vect_loop_form_info *info) > "not vectorized: latch block not empty.\n"); > > /* Make sure the exit is not abnormal. */ > - if (exit_e->flags & EDGE_ABNORMAL) > - return opt_result::failure_at (vect_location, > - "not vectorized:" > - " abnormal loop exit edge.\n"); > + auto_vec exits = get_loop_exit_edges (loop); > + for (edge e : exits) Seeing this multiple times, this isn't the most efficient way to iterate over all exits with LOOPS_HAVE_RECORDED_EXITS. Note to myself: fix (add to) the API. > + { > + if (e->flags & EDGE_ABNORMAL) > + return opt_result::failure_at (vect_location, > + "not vectorized:" > + " abnormal loop exit edge.\n"); > + } > > info->conds > = vect_get_loop_niters (loop, exit_e, &info->assumptions, > @@ -1920,6 +1924,10 @@ vect_create_loop_vinfo (class loop *loop, vec_info_shared *shared, > > LOOP_VINFO_IV_EXIT (loop_vinfo) = info->loop_exit; > > + /* Check to see if we're vectorizing multiple exits. */ > + LOOP_VINFO_EARLY_BREAKS (loop_vinfo) > + = !LOOP_VINFO_LOOP_CONDS (loop_vinfo).is_empty (); > + Seeing this, s/LOOP_VINFO_LOOP_CONDS/LOOP_VINFO_LOOP_EXIT_CONDS/g might be good, if we in future avoid if-conversion in a separate pass we will have other CONDs as well. > if (info->inner_loop_cond) > { > stmt_vec_info inner_loop_cond_info > @@ -11577,7 +11585,7 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple *loop_vectorized_call) > /* Make sure there exists a single-predecessor exit bb. Do this before > versioning. */ > edge e = LOOP_VINFO_IV_EXIT (loop_vinfo); > - if (! single_pred_p (e->dest)) > + if (! single_pred_p (e->dest) && !LOOP_VINFO_EARLY_BREAKS (loop_vinfo)) > { > split_loop_exit_edge (e, true); Note this splitting is done to fulfil versioning constraints on CFG update. Do you have test coverage with alias versioning and early breaks? Otherwise OK. Thanks, Richard.