From patchwork Fri Nov 15 07:20:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 291484 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3339C2C0082 for ; Fri, 15 Nov 2013 18:20:42 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=A5NKhHgoJP8Tfr4Wm073+FfNvalFWTDvi1tQ1CNRjQVBkZ TzSYgEagYD/SnEGmKAZhkF7UyGFPDFVpODRmwNdYZV0iYO5AZKiZsPLhgUui14FU CAE0zTFL0dnjiuj5GY5Dp+UIZBSEBauaKvc5to54opw0pEkNw+pM1KP9XPf0E= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=usqM58Uxn6dDq4wCXmPf2nIQzS8=; b=XV+E384NRbdl0DJ6yJwo OADikfq6Nz7IoJJyGNGsmCH7osshkzuRsz8kz+g9tWr9jVv+dC63tIkK4PL2tufQ IhhPUznIsMB5cR8YPbk+nD7wU0iomkZ+rOzH4lG05mVl5WVOiTfYICfrgXHFFoRR l+7LfhyTLOzpD21SDcj4kAg= Received: (qmail 9651 invoked by alias); 15 Nov 2013 07:20:20 -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 9639 invoked by uid 89); 15 Nov 2013 07:20:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.8 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, SPF_HELO_PASS, SPF_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Nov 2013 07:20:17 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAF7K8VP023146 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 15 Nov 2013 02:20:10 -0500 Received: from stumpy.slc.redhat.com (ovpn-113-161.phx2.redhat.com [10.3.113.161]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rAF7K7t2015021 for ; Fri, 15 Nov 2013 02:20:07 -0500 Message-ID: <5285CB27.50503@redhat.com> Date: Fri, 15 Nov 2013 00:20:07 -0700 From: Jeff Law User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: gcc-patches Subject: [RFA][PATCH] Fix an ia64 Ada bootstrap problem X-IsSubscribed: yes I'm still unable to bootstrap the ia64 port if I back out Kirill's most recent patch. The erroneous-path-isolation code has exposed a latent bug in the RTL if-conversion pass which runs after combine (ie no longer in cfglayout mode). We have this as we leave combine: (insn 107 106 108 10 (set (reg:BI 443) (eq:BI (reg/v/f:DI 399 [ gnu_expr ]) (const_int 0 [0]))) ../../gcc/gcc/ada/gcc-interface/decl.c:6238 311 {*cmpdi_normal} (nil)) (jump_insn 108 107 109 10 (set (pc) (if_then_else (ne (reg:BI 443) (const_int 0 [0])) (label_ref 424) (pc))) ../../gcc/gcc/ada/gcc-interface/decl.c:6238 318 {*br_true} (expr_list:REG_DEAD (reg:BI 443) (int_list:REG_BR_PROB 5359 (nil))) -> 424) [ lots of insns ] (code_label 424 414 425 52 1553 "" [1 uses]) (note 425 424 427 52 [bb 52] NOTE_INSN_BASIC_BLOCK) (insn 427 425 430 52 (set (reg:HI 581 [ MEM[(union tree_node *)0B].base.code ]) (mem/v/j:HI (reg/v/f:DI 399 [ gnu_expr ]) [0 MEM[(union tree_node *)0B].base.code+0 S2 A128])) ../../gcc/gcc/ada/gcc-interface/decl.c:6246 4 {movhi_internal} (expr_list:REG_DEAD (reg/v/f:DI 399 [ gnu_expr ]) (expr_list:REG_UNUSED (reg:HI 581 [ MEM[(union tree_node *)0B].base.code ]) (expr_list:REG_EQUAL (mem/v/j:HI (const_int 0 [0]) [0 MEM[(union tree_node *)0B].base.code+0 S2 A128]) (nil))))) (insn 430 427 476 52 (trap_if (const_int 1 [0x1]) (const_int 0 [0])) 363 {*trap} (nil)) Something deletes/moves insn 427 out of the way (most likely predicated and shoved into bb10). After that point bb52 just contains the trap. We get into ifcvt.c::find_cond_trap. We determine that trap_bb is else_bb, insert the conditional trap into test_bb and cleanup/remove the trap block. All that's left to do is cleanup test_bb. Remember that the THEN edge is canonically the fallthru edge so in this case when the branch was taken it reached the trap. That cleanup code looks like: /* Wire together the blocks again. */ if (current_ir_type () == IR_RTL_CFGLAYOUT) single_succ_edge (test_bb)->flags |= EDGE_FALLTHRU; else { rtx lab, newjump; lab = JUMP_LABEL (jump); newjump = emit_jump_insn_after (gen_jump (lab), jump); LABEL_NUSES (lab) += 1; JUMP_LABEL (newjump) = lab; emit_barrier_after (newjump); } delete_insn (jump); We're running after combine and thus we're not in cfglayout mode. The code creates a new unconditional jump to the label referenced in the original conditional jump. We then emit the new unconditional jump into the IL and delete the conditional jump. That is fine if the trap was in the then (fallthru) block. But that makes *no* sense when the trap is in the else block. The label has been deleted from the insn chain and more importantly, we want to fallthru if we do not trap! Thankfully the the CFG checking code detected this inconsistency. It's been latent since 2002! Clearly we aren't doing a lot of optimizing conditional jumps over/to traps into conditional traps! Anyway, the fix is trivial. When trap_bb == then_bb, run the code as is. When trap_bb == else_bb we only want to remove the conditinoal jump as we want to fallthru if the conditional trap doesn't trigger. With this patch applied and Kirill's patch removed, I can almost bootstrap the ia64 port with Ada enabled (comparison failure that AFAICT is not related to the isolate-erroneous-paths optimization) OK for the trunk if it passes a bootstrap & regtest on x86_64 overnight? Jeff ps. An Itanic with 108 processors is still, well, an Itanic. * ifcvt.c (find_cond_trap): Properly handle case where trap_bb == else_bb. diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index fafff9d..17d26c5 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -3694,7 +3694,7 @@ find_cond_trap (basic_block test_bb, edge then_edge, edge else_edge) /* Wire together the blocks again. */ if (current_ir_type () == IR_RTL_CFGLAYOUT) single_succ_edge (test_bb)->flags |= EDGE_FALLTHRU; - else + else if (trap_bb == then_bb) { rtx lab, newjump;