From patchwork Wed Nov 10 23:29:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 70730 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 DE2A0B710E for ; Thu, 11 Nov 2010 10:30:09 +1100 (EST) Received: (qmail 22297 invoked by alias); 10 Nov 2010 23:30:05 -0000 Received: (qmail 22177 invoked by uid 22791); 10 Nov 2010 23:30:04 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD 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; Wed, 10 Nov 2010 23:29:58 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAANTvLT026403 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 10 Nov 2010 18:29:57 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oAANTuQJ023628 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 10 Nov 2010 18:29:56 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id oAANTuBn009832 for ; Thu, 11 Nov 2010 00:29:56 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id oAANTtGx009830 for gcc-patches@gcc.gnu.org; Thu, 11 Nov 2010 00:29:55 +0100 Date: Thu, 11 Nov 2010 00:29:55 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix -fcompare-debug issue in ivopts (PR debug/46150) Message-ID: <20101110232955.GB29412@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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 Hi! As explained in the PR, the testcase from the PR (which I haven't managed to reduce enough even after 5 days of delta treatments) results in -fcompare-debug failure, starting in ivopts. The problem is that ivopts uses a iterative_hash_expr as hash functions for expressions (which uses TYPE_UID/DECL_UID, so is not identical between -g/-g0) together with the very lax operand_equal_p predicate as equality function. Depending on how things end up layed out in the hash table (which depends on the exact hash values of course and thus on -g/-g0) it can or doesn't call operand_equal_p on expressions which have different hash value and just happened to have hash % size the same (or be somewhere where it searches) and it can sometimes succeed. If it succeeds for -g and not for -g0 or vice versa, it affects ivopts behavior and results in -fcompare-debug failures. Ideally we'd either have some less lax function that would basically compare what is iterative_hash_expr hashing, or have a hash function that would match operand_equal_p, but for the time being I think the following patch should be enough (and certainly fixes the testcase). Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2010-11-10 Jakub Jelinek PR debug/46150 * tree-ssa-loop-ivopts.c (htab_inv_expr_eq): Don't return true if expr1->hash != expr2->hash. Jakub --- gcc/tree-ssa-loop-ivopts.c.jj 2010-11-09 13:58:30.000000000 +0100 +++ gcc/tree-ssa-loop-ivopts.c 2010-11-10 21:36:54.000000000 +0100 @@ -834,7 +834,8 @@ htab_inv_expr_eq (const void *ent1, cons const struct iv_inv_expr_ent *expr2 = (const struct iv_inv_expr_ent *)ent2; - return operand_equal_p (expr1->expr, expr2->expr, 0); + return expr1->hash == expr2->hash + && operand_equal_p (expr1->expr, expr2->expr, 0); } /* Hash function for loop invariant expressions. */