From patchwork Mon Jan 11 09:30:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 565719 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 E8C131402BD for ; Mon, 11 Jan 2016 20:30:45 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=jdayu1fD; 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=CQShvPkt/K34iZZ5c7kwLLmZ27ADzb1g5uzZ6zvYp1GWa5+gH9 zNtRTxYl6K37zaPTn9fGPo1sPI5KixSqVaoHqhVuBHIScimsvFUdClc053s8IEWt FvL/QNQOv+1nLwhn+kjabEHSRqxS2Hj51hM3YT6A5q9fccHgI3Uc5VUj8= 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=OIh36uXJbD3NNPqdDsR9w659SpE=; b=jdayu1fD7PyPsCVytt10 X3lTAvUyNcaAke+SxAeIaHSFRdE+4KBJdSd76CKEs2sXt9Z2wqjvwpMocWTv4c7R mIz3bZIBe3nzscfI5FLEDDIbWMpfbZrH0DR7n9qGbHhAP2GvqW8oqTTq6AYNJtuE sMW5UO1drKf4clSXNaxssqQ= Received: (qmail 32743 invoked by alias); 11 Jan 2016 09:30:36 -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 32635 invoked by uid 89); 11 Jan 2016 09:30:32 -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-languages-length:2214, UD:is-a.h, isah, is-a.h 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 09:30:30 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55765) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1aIYo0-0000Y9-0X for gcc-patches@gnu.org; Mon, 11 Jan 2016 04:30:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIYnv-0003yE-L1 for gcc-patches@gnu.org; Mon, 11 Jan 2016 04:30:27 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:50582) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIYnv-0003xJ-Fh for gcc-patches@gnu.org; Mon, 11 Jan 2016 04:30:23 -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 1aIYnt-00061J-AX from Tom_deVries@mentor.com ; Mon, 11 Jan 2016 01:30:21 -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 09:30:19 +0000 To: "gcc-patches@gnu.org" , Richard Biener From: Tom de Vries Subject: [Committed, PR69108] Handle case that outer phi res is not used in a phi in gather_scalar_reductions Message-ID: <56937629.5080307@mentor.com> Date: Mon, 11 Jan 2016 10:30:17 +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 interchange-2.c with ftree-parallelize-loops=2 we run into an ICE: ... $ gcc -O2 src/gcc/testsuite/gcc.dg/graphite/interchange-2.c -S -ftree-parallelize-loops=2 interchange-2.c: In function ‘foo.constprop’: interchange-2.c:13:1: internal compiler error: in as_a, at is-a.h:192 foo (int N, int *res) ... The problem is in the double reduction handling code added in r226300: ... bool single_use_p = single_imm_use (res, &use_p, &inner_stmt); gcc_assert (single_use_p); gphi *inner_phi = as_a (inner_stmt); ... The code assumes that inner_stmt is a phi, but the ICE shows that it's possible that that's not the case. The patch fixes the problem conservatively by testing if inner_stmt is a PHI, and handling the non-phi case. Bootstrapped and reg-tested on x86_64. Committed to trunk. Thanks, - Tom Handle case that outer phi res is not used in a phi in gather_scalar_reductions 2016-01-07 Tom de Vries PR tree-optimization/69108 * tree-parloops.c (gather_scalar_reductions): Handle case that outer phi res is not used in a phi. * gcc.dg/autopar/pr69108.c: New test. --- gcc/testsuite/gcc.dg/autopar/pr69108.c | 4 ++++ gcc/tree-parloops.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/gcc/testsuite/gcc.dg/autopar/pr69108.c b/gcc/testsuite/gcc.dg/autopar/pr69108.c new file mode 100644 index 0000000..39fc07e --- /dev/null +++ b/gcc/testsuite/gcc.dg/autopar/pr69108.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-parallelize-loops=2" } */ + +#include "../graphite/interchange-2.c" diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index e05cc47..d683704 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -2474,6 +2474,8 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list gimple *inner_stmt; bool single_use_p = single_imm_use (res, &use_p, &inner_stmt); gcc_assert (single_use_p); + if (gimple_code (inner_stmt) != GIMPLE_PHI) + continue; gphi *inner_phi = as_a (inner_stmt); if (simple_iv (loop->inner, loop->inner, PHI_RESULT (inner_phi), &iv, true))