From patchwork Mon Nov 15 10:10:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 47657 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 542F7385800A for ; Mon, 15 Nov 2021 10:10:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 542F7385800A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636971038; bh=VlNSPOmMlmGOXrYi8cJg4vzYlV7BccCLjuPRCEjp2rU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=HxyLNw8q7IbLBAcvPjDCemTf3sMKXmynsBVVdGkw8+y44iIwa0C9VStJbMVWcnI8s M2guxojlO5kawIje2nHLol0bVe8nrBP04HmszTfpQaiyzHS0Ng/ENeZFplMGHwhX9F +XlqB1gVdOGWbEENCzwURLj3JGr5EdppSlA6WPd4= 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 [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id C553F3858405 for ; Mon, 15 Nov 2021 10:10:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C553F3858405 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 92B8F212C5 for ; Mon, 15 Nov 2021 10:10:08 +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 7511213D58 for ; Mon, 15 Nov 2021 10:10:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id So9jGwAykmGQHAAAMHmgww (envelope-from ) for ; Mon, 15 Nov 2021 10:10:08 +0000 Date: Mon, 15 Nov 2021 11:10:08 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/103219 - avoid ICE in unroll-and-jam Message-ID: <8pp1994-6670-4pr3-5op-n434n78sp4p7@fhfr.qr> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" For no particularly good reason unroll-and-jam uses single_dom_exit to determine the exit for the region it wants to run VN on. That happens to ICE because of the dominance restriction. Use single_exit instead. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2021-11-15 Richard Biener PR tree-optimization/103219 * gimple-loop-jam.c (tree_loop_unroll_and_jam): Use single_exit to determine the exit for the VN region. * gcc.dg/torture/pr103219.c: New testcase. --- gcc/gimple-loop-jam.c | 2 +- gcc/testsuite/gcc.dg/torture/pr103219.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr103219.c diff --git a/gcc/gimple-loop-jam.c b/gcc/gimple-loop-jam.c index 611d3805304..666f740f86d 100644 --- a/gcc/gimple-loop-jam.c +++ b/gcc/gimple-loop-jam.c @@ -593,7 +593,7 @@ tree_loop_unroll_and_jam (void) todo |= TODO_cleanup_cfg; auto_bitmap exit_bbs; - bitmap_set_bit (exit_bbs, single_dom_exit (outer)->dest->index); + bitmap_set_bit (exit_bbs, single_exit (outer)->dest->index); todo |= do_rpo_vn (cfun, loop_preheader_edge (outer), exit_bbs); } diff --git a/gcc/testsuite/gcc.dg/torture/pr103219.c b/gcc/testsuite/gcc.dg/torture/pr103219.c new file mode 100644 index 00000000000..cb9023ed8b6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr103219.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ + +int f(); +void g(); +int a, b, c, e; +int d[10]; +int main() +{ + if (c) + if (f()) + { + g(); + if (e) { + a = 0; + for (; a != 6; a = a + 2) + { + b = 0; + for (; b <= 3; b++) + d[b] &= 1; + } + } + } + return 0; +}