From patchwork Fri Dec 17 20:38:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Bosscher X-Patchwork-Id: 75975 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 56D9CB6EE8 for ; Sat, 18 Dec 2010 07:38:42 +1100 (EST) Received: (qmail 15210 invoked by alias); 17 Dec 2010 20:38:39 -0000 Received: (qmail 15104 invoked by uid 22791); 17 Dec 2010 20:38:38 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-qw0-f47.google.com (HELO mail-qw0-f47.google.com) (209.85.216.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 17 Dec 2010 20:38:33 +0000 Received: by qwg5 with SMTP id 5so1089539qwg.20 for ; Fri, 17 Dec 2010 12:38:31 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.212.5 with SMTP id gq5mr1216943qcb.64.1292618311370; Fri, 17 Dec 2010 12:38:31 -0800 (PST) Received: by 10.229.96.18 with HTTP; Fri, 17 Dec 2010 12:38:31 -0800 (PST) Date: Fri, 17 Dec 2010 21:38:31 +0100 Message-ID: Subject: [PATCH] Fix PR rtl-optimization/46755 From: Steven Bosscher To: GCC Patches , Vladimir Makarov 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 Hello, IRA is one of the last passes to recalculate jump labels. With Fortran's ASSIGNed GOTO feature, we apparently can end up making blocks unreachable this way (and probably a C test case can be constructed too). This is something to anticipate when purge_all_dead_edges() is called. So although it would be interesting to find out why the blocks become unreachable so late, I just patched the compiler at the location where the ICE occurs. The solution is simply to remove all unreachable basic blocks if purge_all_dead_edges() nuked some edges. Bootstrapped&tested on x86_64-unknown-linux-gnu. OK for trunk? Ciao! Steven gcc/ PR rtl-optimization/46755 * ira.c (ira): If some dead edges were removed, find and delete any blocks that might have become unreachable. testsuite/ PR rtl-optimization/46755 * gfortran.dg/pr46755.f: New test Index: ira.c =================================================================== --- ira.c (revision 167996) +++ ira.c (working copy) @@ -3158,7 +3158,8 @@ ira (FILE { timevar_push (TV_JUMP); rebuild_jump_labels (get_insns ()); - purge_all_dead_edges (); + if (purge_all_dead_edges ()) + delete_unreachable_blocks (); timevar_pop (TV_JUMP); } } Index: testsuite/gfortran.dg/pr46755.f =================================================================== --- testsuite/gfortran.dg/pr46755.f (revision 0) +++ testsuite/gfortran.dg/pr46755.f (revision 0) @@ -0,0 +1,23 @@ +C { dg-do compile } +C { dg-options "-O" } + IMPLICIT NONE + INTEGER I640,I760,I800 + INTEGER I,ITER,ITMX,LENCM + LOGICAL QDISK,QDW + ASSIGN 801 TO I800 + GOTO I800 + 801 CONTINUE + ASSIGN 761 TO I760 + 761 CONTINUE + DO I=1,LENCM + ENDDO + DO WHILE(ITER.LT.ITMX) + IF(QDW) THEN + ASSIGN 641 to I640 + GOTO I760 + 641 CONTINUE + ENDIF + ENDDO + RETURN + END +