From patchwork Fri Nov 25 07:59:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 61099 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 A0DCE3945C26 for ; Fri, 25 Nov 2022 07:59:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0DCE3945C26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669363193; bh=m9WsUACd97yvWqkW35xIr9Bmdy6Ijy0c4Vo9VRWZZBY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=WEDL6+8Wl3VQDNoJto7fJFoQfMCxg65faTBe6FGVkRc90DurSPWA8ZY/usB4GkvYq yxVNlZVOE+PxcSGgEzDlPmIsfx9CmPFlW94CjxQ4mmhJ5U3LdkOOFWz+EM6IpfGti5 UPAYjPvuim95jwUY8VcrRtkPuLfDKiepAfLbVtQc= 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 1CBD6385841E for ; Fri, 25 Nov 2022 07:59:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1CBD6385841E 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 1989F21875 for ; Fri, 25 Nov 2022 07:59:21 +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 0706813A08 for ; Fri, 25 Nov 2022 07:59:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id igmqANl1gGPvGQAAMHmgww (envelope-from ) for ; Fri, 25 Nov 2022 07:59:21 +0000 Date: Fri, 25 Nov 2022 08:59:20 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/107865 - ICE with outlining of loops MIME-Version: 1.0 Message-Id: <20221125075921.0706813A08@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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" The following makes sure to clear loops number of iterations when outlining them as part of a SESE region as can happen with auto-parallelization. The referenced SSA names become stale otherwise. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. PR tree-optimization/107865 * tree-cfg.cc (move_sese_region_to_fn): Free the number of iterations of moved loops. * gfortran.dg/graphite/pr107865.f90: New testcase. --- .../gfortran.dg/graphite/pr107865.f90 | 18 ++++++++++++++++++ gcc/tree-cfg.cc | 2 ++ 2 files changed, 20 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/graphite/pr107865.f90 diff --git a/gcc/testsuite/gfortran.dg/graphite/pr107865.f90 b/gcc/testsuite/gfortran.dg/graphite/pr107865.f90 new file mode 100644 index 00000000000..6bddb17a1be --- /dev/null +++ b/gcc/testsuite/gfortran.dg/graphite/pr107865.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! { dg-options "-O1 -floop-parallelize-all -ftree-parallelize-loops=2" } + + SUBROUTINE FNC (F) + + IMPLICIT REAL (A-H) + DIMENSION F(N) + + DO I = 1, 6 + DO J = 1, 6 + IF (J .NE. I) THEN + F(I) = F(I) + 1 + END IF + END DO + END DO + + RETURN + END diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc index 28175312afc..0c409b435fb 100644 --- a/gcc/tree-cfg.cc +++ b/gcc/tree-cfg.cc @@ -7859,6 +7859,8 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb, if (bb->loop_father->header == bb) { class loop *this_loop = bb->loop_father; + /* Avoid the need to remap SSA names used in nb_iterations. */ + free_numbers_of_iterations_estimates (this_loop); class loop *outer = loop_outer (this_loop); if (outer == loop /* If the SESE region contains some bbs ending with