From patchwork Sat Sep 3 22:39:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 113260 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 D9F86B6F77 for ; Sun, 4 Sep 2011 08:39:33 +1000 (EST) Received: (qmail 13210 invoked by alias); 3 Sep 2011 22:39:31 -0000 Received: (qmail 13187 invoked by uid 22791); 3 Sep 2011 22:39:30 -0000 X-SWARE-Spam-Status: No, hits=-3.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 03 Sep 2011 22:39:16 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id D5CE08980B; Sun, 4 Sep 2011 00:39:15 +0200 (CEST) Date: Sun, 4 Sep 2011 00:39:15 +0200 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: [PATCH] Better comparison of BINFOs in IPA-CP Message-ID: <20110903223915.GA8174@virgil.arch.suse.de> Mail-Followup-To: GCC Patches , Jan Hubicka 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, the patch below improves the comparisons of BINFOs in IPA-CP. The problem is that we can read different BINFOs for the same type (or a base type component) from the LTO summaries because BINFOs coming from different compilation units are not unified. Because we now have the BINFO_VTABLE available, we can compare those instead since the VMT variables are unified. Bootstrapped and tested on x86_64-linux, also tested by LTO-building Firefox and 483.xalancbmk on the same platform (I lost the actual numbers but the new test returned true hundreds of times in both these cases). OK for trunk? Thanks, Martin 2011-09-02 Martin Jambor * ipa-cp.c (values_equal_for_ipcp_p): When comparing BINFOs, compare their BINFO_VTABLE, Index: src/gcc/ipa-cp.c =================================================================== --- src.orig/gcc/ipa-cp.c +++ src/gcc/ipa-cp.c @@ -800,6 +800,33 @@ values_equal_for_ipcp_p (tree x, tree y) if (x == y) return true; + if (TREE_CODE (x) == TREE_BINFO && TREE_CODE (y) == TREE_BINFO) + { + unsigned HOST_WIDE_INT ox, oy; + tree vx = BINFO_VTABLE (x); + tree vy = BINFO_VTABLE (y); + + if (!vx || !vy + || TREE_CODE (vx) != POINTER_PLUS_EXPR + || TREE_CODE (vy) != POINTER_PLUS_EXPR) + return false; + + ox = tree_low_cst (TREE_OPERAND (vx, 1), 1); + oy = tree_low_cst (TREE_OPERAND (vx, 1), 1); + + if (ox != oy) + return false; + + vx = TREE_OPERAND (vx, 0); + vy = TREE_OPERAND (vy, 0); + if (TREE_CODE (vx) != ADDR_EXPR + || TREE_CODE (vy) != ADDR_EXPR) + return false; + + if (TREE_OPERAND (vx, 0) == TREE_OPERAND (vy, 0)) + return true; + } + if (TREE_CODE (x) == TREE_BINFO || TREE_CODE (y) == TREE_BINFO) return false;