From patchwork Sun Jul 22 23:23:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Bosscher X-Patchwork-Id: 172531 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 DBD672C013E for ; Mon, 23 Jul 2012 09:24:27 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1343604268; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: MIME-Version:Received:From:Date:Message-ID:Subject:To: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=kGbbjcS +55pPF3Kdn3KxsV+M8QI=; b=Yc6ST8r2KKJNSjnBsND4oVcMCnR0nn/MV29Gm+C UJHMF4t626UMtwB8zpdV3+12k7j4x1GIC7mw2DjFDfBqQowNEEVBkDrMs82xabxs k7e2rNp2xKqbAyJ4odxP5ch/zOYaoQzVzz7ttoJgGH0zs/0RWneEaGLKA841MAln tzlc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:MIME-Version:Received:From:Date:Message-ID:Subject:To:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=ytXYIph1+bU2ZKPvS8GreYe6uPwLQfuT3jbhBAvIseZ0TKlf9QZNFSdSGt1yws AUzGCdfPTGob+1jW+LbDqPAHLDuP2c6YWpVpipAgzUDRNJmbQePk5oD53qjejsfd yaVrmzgsOjX34fp1uJ5eqeK9fipCnCLERY/fVWaYYyAZw=; Received: (qmail 7988 invoked by alias); 22 Jul 2012 23:24:22 -0000 Received: (qmail 7979 invoked by uid 22791); 22 Jul 2012 23:24:21 -0000 X-SWARE-Spam-Status: No, hits=-4.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-lb0-f175.google.com (HELO mail-lb0-f175.google.com) (209.85.217.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 22 Jul 2012 23:24:09 +0000 Received: by lbol5 with SMTP id l5so9677825lbo.20 for ; Sun, 22 Jul 2012 16:24:07 -0700 (PDT) Received: by 10.152.131.68 with SMTP id ok4mr14350329lab.47.1342999447786; Sun, 22 Jul 2012 16:24:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.4.229 with HTTP; Sun, 22 Jul 2012 16:23:47 -0700 (PDT) From: Steven Bosscher Date: Mon, 23 Jul 2012 01:23:47 +0200 Message-ID: Subject: [patch] PR53881 - again To: GCC Patches 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 Hello, This patch fixes PR53881 by making group_case_labels_stmt look at the CFG instead of relying on label equality. Bootstrapped&tested on powerpc64-unknown-linux-gnu. OK? Ciao! Steven gcc/ PR tree-optimization/53881 * tree-cfg.c (group_case_labels_stmt): Look up the basic block for each label and compare them instead of labels. testsuite/ PR tree-optimization/53881 * gcc.dg/pr53881.c: Renamed to ... * gcc.dg/pr53881-1.c: ... this. * gcc.dg/pr53881-2.c: New test. Index: tree-cfg.c =================================================================== --- tree-cfg.c (revision 189758) +++ tree-cfg.c (working copy) @@ -1332,8 +1332,7 @@ group_case_labels_stmt (gimple stmt) { int old_size = gimple_switch_num_labels (stmt); int i, j, new_size = old_size; - tree default_case = NULL_TREE; - tree default_label = NULL_TREE; + basic_block default_bb = NULL; bool has_default; /* The default label is always the first case in a switch @@ -1342,8 +1341,8 @@ group_case_labels_stmt (gimple stmt) if (!CASE_LOW (gimple_switch_default_label (stmt)) && !CASE_HIGH (gimple_switch_default_label (stmt))) { - default_case = gimple_switch_default_label (stmt); - default_label = CASE_LABEL (default_case); + tree default_case = gimple_switch_default_label (stmt); + default_bb = label_to_block (CASE_LABEL (default_case)); has_default = true; } else @@ -1356,15 +1355,17 @@ group_case_labels_stmt (gimple stmt) i = 0; while (i < old_size) { - tree base_case, base_label, base_high; + tree base_case, base_high; + basic_block base_bb; + base_case = gimple_switch_label (stmt, i); gcc_assert (base_case); - base_label = CASE_LABEL (base_case); + base_bb = label_to_block (CASE_LABEL (base_case)); /* Discard cases that have the same destination as the default case. */ - if (base_label == default_label) + if (base_bb == default_bb) { gimple_switch_set_label (stmt, i, NULL_TREE); i++; @@ -1383,13 +1384,13 @@ group_case_labels_stmt (gimple stmt) while (i < old_size) { tree merge_case = gimple_switch_label (stmt, i); - tree merge_label = CASE_LABEL (merge_case); + basic_block merge_bb = label_to_block (CASE_LABEL (merge_case)); double_int bhp1 = double_int_add (tree_to_double_int (base_high), double_int_one); /* Merge the cases if they jump to the same place, and their ranges are consecutive. */ - if (merge_label == base_label + if (merge_bb == base_bb && double_int_equal_p (tree_to_double_int (CASE_LOW (merge_case)), bhp1)) { Index: testsuite/gcc.dg/pr53881-2.c =================================================================== --- testsuite/gcc.dg/pr53881-2.c (revision 0) +++ testsuite/gcc.dg/pr53881-2.c (revision 0) @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int a,b,c; +void +fn1 () +{ + switch (a) + { + case 0: + case 10: + b=c; +out_bcon: + break; + case 3: + goto out_bcon; + } +}