From patchwork Tue Dec 14 09:48:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 75479 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 B6BCBB6F10 for ; Tue, 14 Dec 2010 20:49:00 +1100 (EST) Received: (qmail 13688 invoked by alias); 14 Dec 2010 09:48:58 -0000 Received: (qmail 13680 invoked by uid 22791); 14 Dec 2010 09:48:58 -0000 X-SWARE-Spam-Status: No, hits=-6.3 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; Tue, 14 Dec 2010 09:48:52 +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 oBE9mpeA018459 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 14 Dec 2010 04:48:51 -0500 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 oBE9mo4F006779 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 14 Dec 2010 04:48:50 -0500 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 oBE9mogX017650; Tue, 14 Dec 2010 10:48:50 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id oBE9mnTk017648; Tue, 14 Dec 2010 10:48:49 +0100 Date: Tue, 14 Dec 2010 10:48:49 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Cc: Alexandre Oliva Subject: [PATCH] Fix -g ICE from iv increment insertion (PR debug/46885) Message-ID: <20101214094849.GF27214@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! Half a year ago Alex changed canonicalize_loop_ivs (and another place) to use gsi_last_nondebug_bb instead of gsi_last_bb. The problem with that is that in bump_in_latch case create_iv isn't adding stmts before the given stmt (in which case we really want to insert before last non-debug stmt), but after the last stmt, and in that case if the bb is non-empty, but contains only DEBUG stmts, we ICE because gsi will be gsi_end_p and trying to insert after it in non-emtpy bb is invalid. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2010-12-14 Jakub Jelinek PR debug/46885 * tree-ssa-loop-manip.c (canonicalize_loop_ivs): Use gsi_last_bb instead of gsi_last_nondebug_bb if bump_in_latch. * gcc.dg/autopar/pr46885.c: New test. Jakub --- gcc/tree-ssa-loop-manip.c.jj 2010-11-19 20:56:54.000000000 +0100 +++ gcc/tree-ssa-loop-manip.c 2010-12-13 16:35:18.000000000 +0100 @@ -1221,7 +1221,10 @@ canonicalize_loop_ivs (struct loop *loop gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts); } - gsi = gsi_last_nondebug_bb (bump_in_latch ? loop->latch : loop->header); + if (bump_in_latch) + gsi = gsi_last_bb (loop->latch); + else + gsi = gsi_last_nondebug_bb (loop->header); create_iv (build_int_cst_type (type, 0), build_int_cst (type, 1), NULL_TREE, loop, &gsi, bump_in_latch, &var_before, NULL); --- gcc/testsuite/gcc.dg/autopar/pr46885.c.jj 2010-12-13 16:43:28.000000000 +0100 +++ gcc/testsuite/gcc.dg/autopar/pr46885.c 2010-12-13 16:43:08.000000000 +0100 @@ -0,0 +1,23 @@ +/* PR debug/46885 */ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-parallelize-loops=4 -fcompare-debug -fno-tree-dominator-opts -funswitch-loops" } */ + +static inline void +bar (int i) +{ + (void) i; +} + +int +foo (int *begin, int *end) +{ + int s = 0; + int *i; + for (i = begin; i != end; ++i) + { + bar (0); + if (begin) + return s; + } + return 0; +}