From patchwork Mon Oct 11 13:05:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 67419 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 A4B10B6EF7 for ; Tue, 12 Oct 2010 00:05:50 +1100 (EST) Received: (qmail 30417 invoked by alias); 11 Oct 2010 13:05:40 -0000 Received: (qmail 30395 invoked by uid 22791); 11 Oct 2010 13:05:31 -0000 X-SWARE-Spam-Status: No, hits=-5.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 Oct 2010 13:05:27 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9BD5P4K030429 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 11 Oct 2010 09:05:25 -0400 Received: from freie.oliva.athome.lsd.ic.unicamp.br (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id o9BD5NB4032426 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 11 Oct 2010 09:05:25 -0400 Received: from livre.localdomain (livre.oliva.athome.lsd.ic.unicamp.br [172.31.160.2]) by freie.oliva.athome.lsd.ic.unicamp.br (8.14.4/8.14.4) with ESMTP id o9BD5N5V000634 for ; Mon, 11 Oct 2010 10:05:23 -0300 Received: from livre.localdomain (aoliva@localhost [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id o9BD5MYJ032632; Mon, 11 Oct 2010 10:05:22 -0300 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id o9BD5LBx032630; Mon, 11 Oct 2010 10:05:21 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Subject: stabilize switch labels for -fcompare-debug in vrp Date: Mon, 11 Oct 2010 10:05:21 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 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 i386.c fails -fcompare-debug at -O3 because label half: in ix86_expand_vector_init_general gets the DECL_UIDs of labels sorted differently by the tree-vrp sort function. As a result, different SSA_NAMEs are used for the assert variables in different cases of the switch. At the end of VRP, they're released, and put in the freelist in different order. At a later pass, the SSA_NAME nodes are reused in a different order, and we go down the hill from there, because different version numbers cause other optimization differences. Using LABEL_DECL_UIDs instead of DECL_UIDs gets us a stable sort. I haven't figured out why the named label got a different UID. I only observed this in the 4.5 branch, but the same patch applies cleanly in the trunk, and I regstrapped the patch on both trees, on x86 and on x86_64. Ok to install? for gcc/ChangeLog from Alexandre Oliva * tree-vrp.c (compare_case_labels): Use LABEL_DECL_UID. Index: gcc/tree-vrp.c =================================================================== --- gcc/tree-vrp.c.orig 2010-10-08 07:36:36.668853265 -0300 +++ gcc/tree-vrp.c 2010-10-08 07:42:52.872769933 -0300 @@ -4658,8 +4658,8 @@ compare_case_labels (const void *p1, con { const_tree const case1 = *(const_tree const*)p1; const_tree const case2 = *(const_tree const*)p2; - unsigned int uid1 = DECL_UID (CASE_LABEL (case1)); - unsigned int uid2 = DECL_UID (CASE_LABEL (case2)); + unsigned int uid1 = LABEL_DECL_UID (CASE_LABEL (case1)); + unsigned int uid2 = LABEL_DECL_UID (CASE_LABEL (case2)); if (uid1 < uid2) return -1;