From patchwork Tue Nov 29 11:59:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 27202 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp288888wrr; Tue, 29 Nov 2022 03:59:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf63dLGguzB4aRcFzCC3GHb9ZX4XO0Ihgj5a4eTeCHihg36gEMWNyEiei+vCOJMaZpNKmFpF X-Received: by 2002:a17:906:1116:b0:7b2:7af1:9958 with SMTP id h22-20020a170906111600b007b27af19958mr47680819eja.288.1669723199439; Tue, 29 Nov 2022 03:59:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669723199; cv=none; d=google.com; s=arc-20160816; b=T1boesXQOAS2rY5DWXYxTecjxyTULk/9UdvY5RSxS4EiW56zOcdRgxviKpFXln++7o mYIdqZe1+mzFp7zuXeTOuTAJaB4YF5vhg4+HpbRqo8rkvr5+EK4CTfz7FDQqwmTX/cnF bsK2n9sJkxAJiLi3Nbne1jkD/+WcAxIVem7rbVi4i4q79SehnXrJI8Zv4xfBLB5e6QUd Gh/hadVkh/C/YKB7O41FoX4W+h1QDBbpXvSDD4vHpYqFMEB/0UQ9bEwg9sIlKYCtEVpK oTjt3n6WSI3/vDuQs8hSiKOEZg4wRWEJ0n+ydYfb5PjVgbBzWY+JYU7K7yUU+LMT18dN 6iiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=noAEqNfaBwTvBAqAteDez+WE/7yaK6zf9uLEU/7AjDM=; b=RpXk1a5ax4jhfuLo5uZcohcunVT1iUj7tgj4JUA+DVPNdU/C4wlrIlq3uzB/3lz5Qk AP2ysuS84ywO6vNk2iaOn4k74VxgFqCz+EDMV2GXR2qgs+q9X5YkJADErDFxefmmYlfS kfsIevaW777AHpwjGVzCOewn9NNnRgfJ6QLFe+9P2tseo3KfYkKV9PniFRmokN2v09IS XtRDJT2q2I1nao+uR0tiQYRehq89XMS+3JL8xRxiSSX4wwouXVWYSwHIJ/ApvgNsUavU uplWmGx6UfgCMWtU/EMRtSN0wBqpON8wtPhnGXkHdASarhwroiRBbLOJgdwNOfcdb65K qNmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=tei56BCX; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id fj27-20020a0564022b9b00b0046a7c877f58si10333456edb.335.2022.11.29.03.59.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 03:59:59 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=tei56BCX; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0DCDF3852C6E for ; Tue, 29 Nov 2022 11:59:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0DCDF3852C6E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669723197; bh=noAEqNfaBwTvBAqAteDez+WE/7yaK6zf9uLEU/7AjDM=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=tei56BCXyzDIpqOZrq774C35MqkpFxUlD/+FCCD1FPq2XTUD6zcBwYQiU5TpYfWxy fK8cIxR2LZA/Lm826/IEzcTjWbvgwUJ0kCNzm3AlFsOegiLm9KQfn+19h8zjz/3wmJ pJynNmIaobMhsLjO/KzCx7ZCXUdw0G6Yk2T2lRy8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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) 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) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/106995 - if-conversion and vanishing loops MIME-Version: 1.0 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 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-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750831673159213052?= X-GMAIL-MSGID: =?utf-8?q?1750831673159213052?= 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");