From patchwork Tue Oct 25 12:15:29 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: 121633 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 E95451007DB for ; Tue, 25 Oct 2011 23:16:18 +1100 (EST) Received: (qmail 15263 invoked by alias); 25 Oct 2011 12:16:08 -0000 Received: (qmail 15235 invoked by uid 22791); 25 Oct 2011 12:16:02 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 25 Oct 2011 12:15:47 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1RIfv1-00052Q-93 from Tom_deVries@mentor.com ; Tue, 25 Oct 2011 05:15:47 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 25 Oct 2011 05:15:47 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Tue, 25 Oct 2011 13:15:44 +0100 Message-ID: <4EA6A861.9090107@mentor.com> Date: Tue, 25 Oct 2011 15:15:29 +0300 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Lightning/1.0b2 Thunderbird/3.1.15 MIME-Version: 1.0 To: Richard Guenther CC: "gcc-patches@gcc.gnu.org" Subject: [PATCH,PR50763] Follow-up patch to fix i686 bootstrap failure 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 Richard, I have a patch for the i686 bootstrap problem reported in PR50763 comment 10. pr50763-2.c looks like this before tail_merge_optimize: ... std_canonical_va_list_type (union tree_node * typeD.1608) { _BoolD.1576 pretmp.6D.2739; union tree_node * pretmp.5D.2738; _BoolD.1576 pretmp.4D.2737; union tree_node * pretmp.3D.2736; intD.6 D.2734; _BoolD.1576 D.2733; union tree_node * D.2725; intD.6 D.2722; intD.6 D.2717; # BLOCK 2 freq:10000 # PRED: ENTRY [100.0%] (fallthru,exec) # VUSE <.MEMD.2730_12(D)> D.2717_4 = typeD.1608_3(D)->baseD.1605.codeD.1597; if (D.2717_4 != 0) goto ; else goto ; # SUCC: 3 [50.0%] (true,exec) 4 [50.0%] (false,exec) # BLOCK 3 freq:5000 # PRED: 2 [50.0%] (true,exec) # VUSE <.MEMD.2730_12(D)> # PT = anything typeD.1608_5 = typeD.1608_3(D)->typedD.1606.typeD.1600; goto ; # SUCC: 6 [100.0%] (fallthru,exec) # BLOCK 4 freq:5000 # PRED: 2 [50.0%] (false,exec) # VUSE <.MEMD.2730_12(D)> # PT = anything typeD.1608_6 = typeD.1608_3(D)->typedD.1606.typeD.1600; # VUSE <.MEMD.2730_12(D)> D.2722_7 = typeD.1608_6->baseD.1605.codeD.1597; if (D.2722_7 != 0) goto ; else goto ; # SUCC: 5 [50.0%] (true,exec) 7 [50.0%] (false,exec) # BLOCK 7 freq:2500 # PRED: 4 [50.0%] (false,exec) goto ; # SUCC: 6 [100.0%] (fallthru) # BLOCK 5 freq:2500 # PRED: 4 [50.0%] (true,exec) # SUCC: 6 [100.0%] (fallthru,exec) # BLOCK 6 freq:10000 # PRED: 3 [100.0%] (fallthru,exec) 7 [100.0%] (fallthru) 5 [100.0%] (fallthru,exec) # PT = anything # typeD.1608_1 = PHI # VUSE <.MEMD.2730_12(D)> # PT = anything D.2725_9 = typeD.1608_1->type_commonD.1607.main_variantD.1604; D.2733_15 = D.2725_9 != 0B; D.2734_14 = (intD.6) D.2733_15; # VUSE <.MEMD.2730_12(D)> return D.2734_14; # SUCC: EXIT [100.0%] } ... tail_merge_optimize discovers that block 3 and 5 are identical, and removes block 5. In replace_block_by, we end up with phi_vuse1 == NULL_TREE and phi_vuse2 == .MEMD.2730_12(D). After the original fix to PR50763, this forces us to update the vuses, while that is not necessary. Attached patch fixes this problem by determining more precisely when the vuses need to be updated. bootstrapped and reg-tested on x86_64 and i686. OK for trunk? Thanks, - Tom 2011-10-25 Tom de Vries PR tree-optimization/50763 * tree-ssa-tail-merge.c (replace_block_by): Update vops if phi_vuse1 or phi_vuse2 is NULL_TREE only if bb1 dominates or is dominated by bb2. * gcc.dg/pr50763-2.c: New test. Index: gcc/tree-ssa-tail-merge.c =================================================================== --- gcc/tree-ssa-tail-merge.c (revision 180375) +++ gcc/tree-ssa-tail-merge.c (working copy) @@ -1551,7 +1551,12 @@ replace_block_by (basic_block bb1, basic phi_vuse1 = vop_at_entry (bb1); /* If both are not found, it means there's no need to update. */ - update_vops = phi_vuse1 != NULL_TREE || phi_vuse2 != NULL_TREE; + if (phi_vuse1 == NULL_TREE && phi_vuse2 == NULL_TREE) + update_vops = false; + else if (phi_vuse1 == NULL_TREE) + update_vops = dominated_by_p (CDI_DOMINATORS, bb1, bb2); + else if (phi_vuse2 == NULL_TREE) + update_vops = dominated_by_p (CDI_DOMINATORS, bb2, bb1); } if (phi_vuse1 && gimple_bb (SSA_NAME_DEF_STMT (phi_vuse1)) == bb1) Index: gcc/testsuite/gcc.dg/pr50763-2.c =================================================================== --- /dev/null (new file) +++ gcc/testsuite/gcc.dg/pr50763-2.c (revision 0) @@ -0,0 +1,46 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef union tree_node *tree; + +struct tree_base +{ + int code; +}; + +struct tree_typed +{ + struct tree_base base; + tree type; +}; + +struct tree_common +{ + struct tree_typed typed; +}; + +struct tree_type_common +{ + tree main_variant; +}; + +union tree_node +{ + struct tree_base base; + struct tree_typed typed; + struct tree_type_common type_common; +}; + +int std_canonical_va_list_type (tree type) +{ + if (type->base.code) + type = type->typed.type; + else + if (type->typed.type->base.code) + type = type->typed.type; + + if (type->type_common.main_variant) + return 1; + + return 0; +}