From patchwork Fri Nov 20 15:57:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 546960 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 16B311402A9 for ; Sat, 21 Nov 2015 02:58:06 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=TUs5MWYz; 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 :subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=Eu0bg9HZ4khSFEdTV dgRnxIYos6gqvwBLNjGtAh8oZ/U+t0PqPVKA1tyukMIc3GARHvbJCv24G4BQ1eiD 4zCDJmvPZG7MoMzTIiI+Wc2W1i4Vo0htGXB4pAuHg1iragg8lAl68F41vlY1/C0L cFG3uhr8FuBBJuOHyz8b7PBfag= 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 :subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=VmXkl557i2Rqm75NrdPoaLN RTkI=; b=TUs5MWYz8lcL8wFofKgdXjpcRc4r5ZSuePNSoxaAhsMVdtRcpGeQElg lreP8Shf6Gsm7jl7BG5oEKRcpWLN3lHXNDJQqayMivpFqPzbkS3mGLDIhQ9X7kqM ICOhwvw+QMDBys/6rlEiP9E+rhTQVTmH5Gb8HZCvMuusUChpJEQ8= Received: (qmail 106408 invoked by alias); 20 Nov 2015 15:57:58 -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 106396 invoked by uid 89); 20 Nov 2015 15:57:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 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; Fri, 20 Nov 2015 15:57:52 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57010) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1Zzo4L-0007yB-V2 for gcc-patches@gnu.org; Fri, 20 Nov 2015 10:57:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zzo4I-0001NK-9X for gcc-patches@gnu.org; Fri, 20 Nov 2015 10:57:49 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:45904) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zzo4I-0001NF-3Z for gcc-patches@gnu.org; Fri, 20 Nov 2015 10:57:46 -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 1Zzo4G-0002Cp-Av from Tom_deVries@mentor.com for gcc-patches@gnu.org; Fri, 20 Nov 2015 07:57:44 -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; Fri, 20 Nov 2015 15:57:42 +0000 Subject: [PATCH, PR68460] Always call free_stmt_vec_info_vec in gather_scalar_reductions To: "gcc-patches@gnu.org" References: <56182D1D.2060106@mentor.com> From: Tom de Vries Message-ID: <564F42CC.8090609@mentor.com> Date: Fri, 20 Nov 2015 16:57:00 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <56182D1D.2060106@mentor.com> X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 [ was: Re: [PATCH] Fix parloops gimple_uid usage ] On 09/10/15 23:09, Tom de Vries wrote: > @@ -2392,6 +2397,9 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list > loop_vec_info simple_inner_loop_info = NULL; > bool allow_double_reduc = true; > > + if (!stmt_vec_info_vec.exists ()) > + init_stmt_vec_info_vec (); > + > simple_loop_info = vect_analyze_loop_form (loop); > if (simple_loop_info == NULL) > return; > @@ -2453,9 +2461,16 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list > destroy_loop_vec_info (simple_loop_info, true); > destroy_loop_vec_info (simple_inner_loop_info, true); > > + /* Release the claim on gimple_uid. */ > + free_stmt_vec_info_vec (); > + With the src/libgomp/testsuite/libgomp.c/pr46886.c testcase, compiled in addition with -ftree-vectorize, I ran into an ICE: ... src/libgomp/testsuite/libgomp.c/pr46886.c:8:5: internal compiler error: in init_stmt_vec_info_vec, at tree-vect-stmts.c:8250 int foo (void) ^~~ 0x1196082 init_stmt_vec_info_vec() src/gcc/tree-vect-stmts.c:8250 0x11c3ed4 vectorize_loops() src/gcc/tree-vectorizer.c:510 0x10a7ea5 execute src/gcc/tree-ssa-loop.c:276 ... The ICE is caused by the fact that init_stmt_vec_info_vec is called at the start of vectorize_loops, while stmt_vec_info_vec is not empty. I traced this back to gather_scalar_reduction, where we call init_stmt_vec_info_vec, but we skip free_stmt_vec_info_vec if we take the early-out for simple_loop_info == NULL. This patch fixes the ICE by making sure we always call free_stmt_vec_info_vec in gather_scalar_reduction. Passes cc1/f951 rebuild and autopar testing. OK for stage3 trunk if bootstrap and regtest succeeds? Thanks, - Tom Always call free_stmt_vec_info_vec in gather_scalar_reductions 2015-11-20 Tom de Vries PR tree-optimization/68460 * tree-parloops.c (gather_scalar_reductions): Also call free_stmt_vec_info_vec if simple_loop_info == NULL. * gcc.dg/autopar/pr68460.c: New test. --- gcc/testsuite/gcc.dg/autopar/pr68460.c | 35 ++++++++++++++++++++++++++++++++++ gcc/tree-parloops.c | 6 +++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/autopar/pr68460.c b/gcc/testsuite/gcc.dg/autopar/pr68460.c new file mode 100644 index 0000000..0c00065 --- /dev/null +++ b/gcc/testsuite/gcc.dg/autopar/pr68460.c @@ -0,0 +1,35 @@ +/* { dg-do "compile" } */ +/* { dg-options "-O -ftree-parallelize-loops=2 -ftree-vectorize -fno-tree-ch -fno-tree-dominator-opts" } */ + +void abort (void); + +int d[1024], e[1024]; + +int +foo (void) +{ + int s = 0; + int i; + + for (i = 0; i < 1024; i++) + s += d[i] - e[i]; + + return s; +} + +int +main () +{ + int i; + + for (i = 0; i < 1024; i++) + { + d[i] = i * 2; + e[i] = i; + } + + if (foo () != 1023 * 1024 / 2) + abort (); + + return 0; +} diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index 8d7912d..85cc78d 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -2433,7 +2433,7 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list simple_loop_info = vect_analyze_loop_form (loop); if (simple_loop_info == NULL) - return; + goto gather_done; for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi)) { @@ -2492,9 +2492,13 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list destroy_loop_vec_info (simple_loop_info, true); destroy_loop_vec_info (simple_inner_loop_info, true); + gather_done: /* Release the claim on gimple_uid. */ free_stmt_vec_info_vec (); + if (reduction_list->elements () == 0) + return; + /* As gimple_uid is used by the vectorizer in between vect_analyze_loop_form and free_stmt_vec_info_vec, we can set gimple_uid of reduc_phi stmts only now. */