From patchwork Wed Oct 20 19:25:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 68467 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]) by ozlabs.org (Postfix) with SMTP id 999E4B70D0 for ; Thu, 21 Oct 2010 06:26:08 +1100 (EST) Received: (qmail 9038 invoked by alias); 20 Oct 2010 19:26:06 -0000 Received: (qmail 9026 invoked by uid 22791); 20 Oct 2010 19:26:05 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_TM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 20 Oct 2010 19:26:01 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9KJPxxq024235 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 20 Oct 2010 15:26:00 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id o9KJPxJQ007419 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 20 Oct 2010 15:25:59 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o9KJPwW2004365 for ; Wed, 20 Oct 2010 21:25:58 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o9KJPwiS004363 for gcc-patches@gcc.gnu.org; Wed, 20 Oct 2010 21:25:58 +0200 Date: Wed, 20 Oct 2010 21:25:58 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix -ftree-parallelize-loops=N -g (PR tree-optimization/46066) Message-ID: <20101020192558.GO18103@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 Hi! create_parallel_loop assumes the last statement in latch must be def stmt for cvar_next, which is not necessarily true if there are debug stmts after it. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2010-10-20 Jakub Jelinek PR tree-optimization/46066 * tree-parloops.c (create_parallel_loop): Use gsi_last_nondebug_bb instead of gsi_last_bb. * gcc.dg/autopar/pr46066.c: New test. Jakub --- gcc/tree-parloops.c.jj 2010-08-20 16:05:40.000000000 +0200 +++ gcc/tree-parloops.c 2010-10-20 10:49:38.000000000 +0200 @@ -1451,7 +1451,7 @@ create_parallel_loop (struct loop *loop, initvar); cvar_next = PHI_ARG_DEF_FROM_EDGE (phi, loop_latch_edge (loop)); - gsi = gsi_last_bb (loop->latch); + gsi = gsi_last_nondebug_bb (loop->latch); gcc_assert (gsi_stmt (gsi) == SSA_NAME_DEF_STMT (cvar_next)); gsi_remove (&gsi, true); --- gcc/testsuite/gcc.dg/autopar/pr46066.c.jj 2010-10-20 11:24:00.000000000 +0200 +++ gcc/testsuite/gcc.dg/autopar/pr46066.c 2010-10-20 11:04:05.000000000 +0200 @@ -0,0 +1,18 @@ +/* PR tree-optimization/46066 */ +/* { dg-do compile } */ +/* { dg-options "-fcompare-debug -O -ftree-parallelize-loops=4" } */ + +void +parloop (int N) +{ + int i, j, ii; + int x[400][10][400]; + for (ii = 0; ii < N; ii++) + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + x[i][j][ii] = 3; + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + if (x[i][j][0] != 3) + __builtin_abort (); +}