From patchwork Sat May 7 07:14:19 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: 619528 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 3r20Jv69g3z9sRZ for ; Sat, 7 May 2016 17:14:54 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=rPkbPTPo; 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:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=a9MZrPkWsNUupmrhM3ck4m9fw+gxcJzjF0kM73tfBTs1/iGCGo aRCnnRT6VilcQvUtcLsc0R+Hq5jxcc4c6nUrLJ4rrXdRg0MN+mT8EaX9AGyyMRJa /bilR9LqBctVqB3P/c74rlt8UNYh2EZq+m6yhaSHLP1/lfTO0nZwwXJ2g= 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:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=l0e/vn/SH6r5SccsLITSZ1QzoZU=; b=rPkbPTPodkbWXaQH/k/m t8Ha8IRq8dkD9SMyLyUCUmyUiSwF/MgN/LT0Ew3adXMG04HIv6bEbloi+FvcJXUr o6a6ZerbmxfrWGR8sYDeHsyShvO7sp4tOdNv0yTq2QCXCmBRRAg4E5xs465P79iT YJBvq8ssvyl99NJfic5b/AM= Received: (qmail 125014 invoked by alias); 7 May 2016 07:14:44 -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 124994 invoked by uid 89); 7 May 2016 07:14:42 -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, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=2016-05-07 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 07 May 2016 07:14:28 +0000 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 1aywRU-0005vm-Ll from Tom_deVries@mentor.com ; Sat, 07 May 2016 00:14:25 -0700 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; Sat, 7 May 2016 08:14:23 +0100 To: Sebastian Pop , Richard Biener CC: GCC Patches From: Tom de Vries Subject: [Committed, trunk/6] Handle NULL def in build_cross_bb_scalars_def Message-ID: <572D95CB.9020908@mentor.com> Date: Sat, 7 May 2016 09:14:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 Hi, Attached patch fixes a graphite 6/7 regression. [ found regression by doing an fgraphite-identity on-by-default bootstrap and regtest on x86_64. ] When compiling gcc.dg/tree-ssa/vrp66.c with -O2 fgraphite-identity, we arrive at graphite_find_cross_bb_scalar_vars: ... static void graphite_find_cross_bb_scalar_vars (scop_p scop, gimple *stmt, vec *reads, vec *writes) { tree def; if (gimple_code (stmt) == GIMPLE_ASSIGN) def = gimple_assign_lhs (stmt); else if (gimple_code (stmt) == GIMPLE_CALL) def = gimple_call_lhs (stmt); else if (gimple_code (stmt) == GIMPLE_PHI) def = gimple_phi_result (stmt); else return; build_cross_bb_scalars_def (scop, def, gimple_bb (stmt), writes); ... ... with as stmt a resultless call: ... (gdb) call debug_gimple_stmt (stmt) # VUSE <.MEM_10(D)> f2 (_1); ... Consequently, def becomes NULL_TREE and we run into an assert at the start of build_cross_bb_scalars_def that asserts that def is not NULL_TREE. This patch fixes the ICE by handling a NULL_TREE def in build_cross_bb_scalars_def. Bootstrapped and reg-tested on x86_64. Approved at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70956#c2 . Committed to trunk, backported to 6 branch. Thanks, - Tom Handle NULL def in build_cross_bb_scalars_def 2016-05-07 Tom de Vries PR tree-optimization/70956 * graphite-scop-detection.c (build_cross_bb_scalars_def): Handle NULL def. * gcc.dg/graphite/pr70956.c: New test. --- gcc/graphite-scop-detection.c | 3 +-- gcc/testsuite/gcc.dg/graphite/pr70956.c | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c index 7615842..dd50a1e 100644 --- a/gcc/graphite-scop-detection.c +++ b/gcc/graphite-scop-detection.c @@ -1722,8 +1722,7 @@ static void build_cross_bb_scalars_def (scop_p scop, tree def, basic_block def_bb, vec *writes) { - gcc_assert (def); - if (!is_gimple_reg (def)) + if (!def || !is_gimple_reg (def)) return; /* Do not gather scalar variables that can be analyzed by SCEV as they can be diff --git a/gcc/testsuite/gcc.dg/graphite/pr70956.c b/gcc/testsuite/gcc.dg/graphite/pr70956.c new file mode 100644 index 0000000..31fc25f --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr70956.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fgraphite-identity" } */ + +#include "../tree-ssa/vrp66.c"