From patchwork Tue Sep 6 09:14:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 113514 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 0EDBAB6F6F for ; Tue, 6 Sep 2011 19:15:14 +1000 (EST) Received: (qmail 24877 invoked by alias); 6 Sep 2011 09:15:10 -0000 Received: (qmail 24865 invoked by uid 22791); 6 Sep 2011 09:15:08 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_FAIL, TW_CF X-Spam-Check-By: sourceware.org Received: from smtp-vbr13.xs4all.nl (HELO smtp-vbr13.xs4all.nl) (194.109.24.33) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 06 Sep 2011 09:14:54 +0000 Received: from [192.168.1.68] (teejay.xs4all.nl [213.84.119.160]) (authenticated bits=0) by smtp-vbr13.xs4all.nl (8.13.8/8.13.8) with ESMTP id p869EoRh020420 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 6 Sep 2011 11:14:51 +0200 (CEST) (envelope-from vries@codesourcery.com) Message-ID: <4E65E463.6070004@codesourcery.com> Date: Tue, 06 Sep 2011 11:14:11 +0200 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Lightning/1.0b2 Thunderbird/3.1.13 MIME-Version: 1.0 To: Vladimir Makarov CC: "gcc-patches@gcc.gnu.org" , Maxim Kuvyrkov Subject: [PATCH] check_cfg assert fix 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, During testing the approved-for-commit middle-end patch for bug 43864 on ARM, I ran into a gcc.dg/torture/pr46068.c ICE. The following assert in haifa-sched.c:check_cfg triggered: ... else if (any_condjump_p (head)) gcc_assert (/* Usual case. */ (EDGE_COUNT (bb->succs) > 1 && !BARRIER_P (NEXT_INSN (head))) /* Or jump to the next instruction. */ || (EDGE_COUNT (bb->succs) == 1 && (BB_HEAD (EDGE_I (bb->succs, 0)->dest) == JUMP_LABEL (head)))); ... It triggered on this rtl, a conditional return followed by a barrier: ... (jump_insn 44 43 93 7 (set (pc) (if_then_else (ne (reg:CC 24 cc) (const_int 0 [0])) (return) (pc))) gcc/testsuite/gcc.dg/builtin-unreachable-4.c:13 249 {*cond_return} (expr_list:REG_DEAD (reg:CC 24 cc) (expr_list:REG_BR_PROB (const_int 9996 [0x270c]) (nil))) -> return) (barrier 93 44 92) ... Although this insn sequence is non-optimal (the conditional return can be optimized to an unconditional one, given that it's followed by a barrier), it's not incorrect. The patch fixes this ICE by removing the check for the 'EDGE_COUNT (bb->succs) == 1' case. Bootstrapped and reg-tested on x86_64 and build and reg-tested on arm. OK for trunk? Thanks, - Tom 2011-09-05 Tom de Vries * haifa-sched.c (check_cfg): Remove restriction on conditional jump if the containing block has only 1 outgoing edge. Index: gcc/haifa-sched.c =================================================================== --- gcc/haifa-sched.c (revision 178145) +++ gcc/haifa-sched.c (working copy) @@ -6065,13 +6065,12 @@ check_cfg (rtx head, rtx tail) gcc_assert (EDGE_COUNT (bb->succs) == 1 && BARRIER_P (NEXT_INSN (head))); else if (any_condjump_p (head)) - gcc_assert (/* Usual case. */ - (EDGE_COUNT (bb->succs) > 1 - && !BARRIER_P (NEXT_INSN (head))) - /* Or jump to the next instruction. */ - || (EDGE_COUNT (bb->succs) == 1 - && (BB_HEAD (EDGE_I (bb->succs, 0)->dest) - == JUMP_LABEL (head)))); + gcc_assert (/* Weird case, like jump to the next insn + or use of __builtin_unreachable (). */ + EDGE_COUNT (bb->succs) == 1 + /* Normal case, one path falls through. */ + || !BARRIER_P (NEXT_INSN (head))); + } if (BB_END (bb) == head) {