From patchwork Mon Oct 11 13:05:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: stabilize switch labels for -fcompare-debug in vrp From: Alexandre Oliva X-Patchwork-Id: 67419 Message-Id: To: gcc-patches@gcc.gnu.org Date: Mon, 11 Oct 2010 10:05:21 -0300 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;