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 5B9213858412 for ; Tue, 29 Nov 2022 11:59:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5B9213858412 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A756D21B7B for ; Tue, 29 Nov 2022 11:59:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1669723150; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=noAEqNfaBwTvBAqAteDez+WE/7yaK6zf9uLEU/7AjDM=; b=fVl2Kz9toUPvInwDRujIoid5zsXqgkE3gvvb47NLrpso9foavQW4atpvu2VPBDrzGrCWQH azqhG/JCwgbFX0kpvdUrqSsabs4dE3ND3NQp5aswscJe5Oq11EWP7YveLyv0FO0Y0l81F4 xJJeIRD7KTKlMutG+I4TKSzh7LrTzG8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1669723150; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=noAEqNfaBwTvBAqAteDez+WE/7yaK6zf9uLEU/7AjDM=; b=5TEg/K/Yt6YUUouin+w8OSDTnBcSXXhTZmrJ3pDg3CaoVXqiJ+TtR10qIWwYw5mZIISx78 cElOGI961KgPvHCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9268213428 for ; Tue, 29 Nov 2022 11:59:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id NuULIQ70hWPEegAAMHmgww (envelope-from ) for ; Tue, 29 Nov 2022 11:59:10 +0000 Date: Tue, 29 Nov 2022 12:59:10 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/106995 - if-conversion and vanishing loops MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20221129115910.9268213428@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.8 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: When we version loops for vectorization during if-conversion it can happen that either loop vanishes because we run some VN and CFG cleanup. If the to-be vectorized part vanishes we already redirect the versioning condition to the original loop. The following does the same in case the original loop vanishes as happened for the testcase in the bug in the past (but no longer). Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/106995 * tree-if-conv.cc (pass_if_conversion::execute): Also redirect the versioning condition to the original loop if this very loop vanished during CFG cleanup. --- gcc/tree-if-conv.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc index 34bb507ff3b..64b20b4a9e1 100644 --- a/gcc/tree-if-conv.cc +++ b/gcc/tree-if-conv.cc @@ -3761,7 +3761,8 @@ pass_if_conversion::execute (function *fun) if (!gimple_bb (g)) continue; unsigned ifcvt_loop = tree_to_uhwi (gimple_call_arg (g, 0)); - if (!get_loop (fun, ifcvt_loop)) + unsigned orig_loop = tree_to_uhwi (gimple_call_arg (g, 1)); + if (!get_loop (fun, ifcvt_loop) || !get_loop (fun, orig_loop)) { if (dump_file) fprintf (dump_file, "If-converted loop vanished\n"); -- 2.35.3