From patchwork Sat Jul 7 12:41:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Bosscher X-Patchwork-Id: 169594 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 2CC182C020A for ; Sat, 7 Jul 2012 22:41:42 +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=1342269703; 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=c16VoMn qPc3IpOGWJKiqFbol+9w=; b=DkFvEEF6KQChdlVBKiPu5P7uvCmeZagJnLfv6Qo RGt2JNLHwgyIIsnhao5J3oZeaFM752ipSPtPWm2/Y/aCZq5/cDb4gqm5lrosedUM 465fH5PdqBLHGdMZpwK13xgooOzFMNUh3yisFZ29caiaNWHXelS+mLUe/rP4e5Eg 0wso= 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=vFpW23LW5E2GmG2go4CxEk1tFhNQLOjchJDQAmNlqwK4zRrtKwKmjWTX/GHHmj Gy2pppxgv6t4LYysQ9ZkNTUFsDSGqFQnyX3GOX1W0vp4oA/onkGqa20OCjuGFrb2 zb6wV/gvla6sr6iGBlmuntHIpZ819OU3jdrpPzFE2oTbY=; Received: (qmail 16979 invoked by alias); 7 Jul 2012 12:41:38 -0000 Received: (qmail 16970 invoked by uid 22791); 7 Jul 2012 12:41:36 -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; Sat, 07 Jul 2012 12:41:24 +0000 Received: by lbol5 with SMTP id l5so2169129lbo.20 for ; Sat, 07 Jul 2012 05:41:23 -0700 (PDT) Received: by 10.152.132.233 with SMTP id ox9mr33400905lab.25.1341664882880; Sat, 07 Jul 2012 05:41:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.4.229 with HTTP; Sat, 7 Jul 2012 05:41:02 -0700 (PDT) From: Steven Bosscher Date: Sat, 7 Jul 2012 14:41:02 +0200 Message-ID: Subject: [patch] PR53881 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, I was relying on the assumption that all case labels in a switch vector that jump to the same target block would also have the same CASE_LABEL. This isn't so for the test case of PR53881, where DCE removes a dead statement but preserves a user label. Fortunately, using find_edge in emit_case_bit_tests is cheap because we know that there are very few edges going out of the switch (at most 3) and usually only one incoming edge per case target. Bootstrapped on powerpc64-unknown-linux-gnu. Committed as obvious (r189349). Ciao! Steven gcc/ PR tree-optimization/53881 * tree-switch-conversion.c (emit_case_bit_tests): Do not rely on comparing labels to establish uniqueness of a switch case target, use the CFG instead. testsuite/ PR tree-optimization/53881 * gcc.dg/pr53881.c: New test. Index: gcc/tree-switch-conversion.c --- trunk/gcc/tree-switch-conversion.c 2012/07/07 12:27:33 189348 +++ trunk/gcc/tree-switch-conversion.c 2012/07/07 12:35:44 189349 @@ -329,14 +329,13 @@ unsigned int lo, hi; tree cs = gimple_switch_label (swtch, i); tree label = CASE_LABEL (cs); + edge e = find_edge (switch_bb, label_to_block (label)); for (k = 0; k < count; k++) - if (label == test[k].label) + if (e == test[k].target_edge) break; if (k == count) { - edge e = find_edge (switch_bb, label_to_block (label)); - gcc_assert (e); gcc_checking_assert (count < MAX_CASE_BIT_TESTS); test[k].hi = 0; test[k].lo = 0;