From patchwork Mon Jan 11 10:07:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 565737 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44ED6140BE9 for ; Mon, 11 Jan 2016 21:08:02 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=FsxR10fu; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=XFPB18KVHvq0YQcEISPWKimO62zJDGolDvYfQGCXvqSSiSs8Dk aZfocVKJMp2z93ZSiVvj6w1F3Y3SAsSvzD8wTg+R+8TP6qfqtTwOmoGN835I9Adj 2qNb3pPrejglVjMu2ouhlHmsKrm/TKvowWgbwALSwxJO+VErrXz5c1XQg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=WEcg49+FJ9GK1j0ZgPGfng+mKXs=; b=FsxR10fuQ+reCNRkra6M t60vZXb35lQmmeyQcjCWpk+uooWK23IXblnbqEuYL9CspywXFFN+07q51k0hCRJ/ ddm9XQCVKtmV+kgwxTxoRS/XjubppHXH/uFnQneRu14xjG0bsoRutcMnh5FKXAtt QyryMrRd0T8M80Z9ICjbkFc= Received: (qmail 15770 invoked by alias); 11 Jan 2016 10:07:45 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 15707 invoked by uid 89); 11 Jan 2016 10:07:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=HX-detected-operating-system:Windows X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 11 Jan 2016 10:07:43 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34706) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1aIZO0-0000kS-Nr for gcc-patches@gnu.org; Mon, 11 Jan 2016 05:07:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIZNw-0003oT-Bf for gcc-patches@gnu.org; Mon, 11 Jan 2016 05:07:40 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:54485) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIZNw-0003oN-4r for gcc-patches@gnu.org; Mon, 11 Jan 2016 05:07:36 -0500 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1aIZNu-00056b-6k from Tom_deVries@mentor.com ; Mon, 11 Jan 2016 02:07:34 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Mon, 11 Jan 2016 10:07:29 +0000 To: "gcc-patches@gnu.org" , Richard Biener From: Tom de Vries Subject: [Committed, PR69109] Don't allow latch with phi in try_transform_to_exit_first_loop_alt Message-ID: <56937EDE.4090005@mentor.com> Date: Mon, 11 Jan 2016 11:07:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 Hi, when compiling src/gcc/testsuite/gcc.dg/vect/unswitch-loops-pr26969.c and src/gcc/testsuite/gcc.c-torture/compile/pr32399.c with -O2 -funswitch-loops -ftree-parallelize-loops=2 we run into two different ICEs. In both cases, -funswitch-loops introduces a virtual memory phi in the latch, and transform_to_exit_first_loop_alt assumes there are no phis in the latch, and generates invalid ssa as a result. The patch fixes the problem by testing for phis in the latch in try_transform_to_exit_first_loop_alt. Bootstrapped and reg-tested on x86_64. Committed to trunk. Thanks, - Tom Don't allow latch with phi in try_transform_to_exit_first_loop_alt 2016-01-07 Tom de Vries PR tree-optimization/69109 * tree-parloops.c (try_transform_to_exit_first_loop_alt): Don't allow latch with phi. * gcc.dg/autopar/pr69109-2.c: New test. * gcc.dg/autopar/pr69109.c: New test. --- gcc/testsuite/gcc.dg/autopar/pr69109-2.c | 4 ++++ gcc/testsuite/gcc.dg/autopar/pr69109.c | 4 ++++ gcc/tree-parloops.c | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/gcc/testsuite/gcc.dg/autopar/pr69109-2.c b/gcc/testsuite/gcc.dg/autopar/pr69109-2.c new file mode 100644 index 0000000..0a3154b --- /dev/null +++ b/gcc/testsuite/gcc.dg/autopar/pr69109-2.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-parallelize-loops=2 -funswitch-loops" } */ + +#include "../../gcc.c-torture/compile/pr32399.c" diff --git a/gcc/testsuite/gcc.dg/autopar/pr69109.c b/gcc/testsuite/gcc.dg/autopar/pr69109.c new file mode 100644 index 0000000..58f3a9f --- /dev/null +++ b/gcc/testsuite/gcc.dg/autopar/pr69109.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-parallelize-loops=2 -funswitch-loops" } */ + +#include "../vect/unswitch-loops-pr26969.c" diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index d683704..5afaaf8 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -1769,6 +1769,10 @@ try_transform_to_exit_first_loop_alt (struct loop *loop, if (!gimple_seq_nondebug_singleton_p (bb_seq (loop->latch))) return false; + /* Check whether the latch contains no phis. */ + if (phi_nodes (loop->latch) != NULL) + return false; + /* Check whether the latch contains the loop iv increment. */ edge back = single_succ_edge (loop->latch); edge exit = single_dom_exit (loop);