From patchwork Tue Jan 3 14:03:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 134006 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 24D161007D5 for ; Wed, 4 Jan 2012 01:03:40 +1100 (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=1326204222; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Subject:Message-ID:User-Agent:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=yeUBtWsH7UP3DnJqPy4t I3Vq5fE=; b=UpSxpKD0abU+D926iK8n87mVTPRqIcdyloo2vlbNawCyy/AB1ThX v9qhSfaLnCuNDi01L/TgVSpwnHTpWViMF82QPuwY8e+4ikj9aLlkqmUMavcxNz7N XXseYHylwulSt1UyjJRyi9ldgpxNIMv3lkjuUQ1FrJiUpQCWbe6M4zY= 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:Date:From:To:Subject:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=yPIqDDX8aDDtcnUMfnRnOt7WE+6eCw1S8KLKGR3HsZDq6KHldaMC+y+HXCLhSe pFmTI+YpPkhs5lS1ORb4Kvr6A/64KplcF4qugr3bzu8J2UjViNFZNJV6VCjPQJZU 3jqWETFhTMH1A3JdC4iSIaCa3Rv9v1xy4SdMdtW4hI/iU=; Received: (qmail 11753 invoked by alias); 3 Jan 2012 14:03:34 -0000 Received: (qmail 11715 invoked by uid 22791); 3 Jan 2012 14:03:32 -0000 X-SWARE-Spam-Status: No, hits=-4.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD 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; Tue, 03 Jan 2012 14:03:19 +0000 Received: from relay2.suse.de (nat.nue.novell.com [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 3A8178D40D for ; Tue, 3 Jan 2012 15:03:18 +0100 (CET) Date: Tue, 3 Jan 2012 15:03:18 +0100 (CET) From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix fallout from fix for PR49651 Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) 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 The fix for PR49651 was too conservative as I noticed when trying to backport it to the 4.5 branch. The following adjusts it to preserve the optimization cases we have in the tree-ssa testsuite. Bootstrap / regtest pending on x86_64-unknown-linux-gnu. Richard. 2012-01-03 Richard Guenther PR tree-optimization/49651 * tree-ssa-structalias.c (type_can_have_subvars): New function. (var_can_have_subvars): Use it. (get_constraint_for_1): Only consider subfields if there can be any. * gcc.dg/tree-ssa/pta-ptrarith-1.c: Adjust. * gcc.dg/tree-ssa/pta-ptrarith-2.c: Likewise. Index: gcc/tree-ssa-structalias.c =================================================================== --- gcc/tree-ssa-structalias.c (revision 182838) +++ gcc/tree-ssa-structalias.c (working copy) @@ -303,6 +303,7 @@ static varinfo_t first_vi_for_offset (va static varinfo_t first_or_preceding_vi_for_offset (varinfo_t, unsigned HOST_WIDE_INT); static varinfo_t lookup_vi_for_tree (tree); +static inline bool type_can_have_subvars (const_tree); /* Pool of variable info structures. */ static alloc_pool variable_info_pool; @@ -3275,7 +3276,8 @@ get_constraint_for_1 (tree t, VEC (ce_s, return; cs = *VEC_last (ce_s, *results); - if (cs.type == DEREF) + if (cs.type == DEREF + && type_can_have_subvars (TREE_TYPE (t))) { /* For dereferences this means we have to defer it to solving time. */ @@ -5043,6 +5045,15 @@ sort_fieldstack (VEC(fieldoff_s,heap) *f VEC_qsort (fieldoff_s, fieldstack, fieldoff_compare); } +/* Return true if T is a type that can have subvars. */ + +static inline bool +type_can_have_subvars (const_tree t) +{ + /* Aggregates without overlapping fields can have subvars. */ + return TREE_CODE (t) == RECORD_TYPE; +} + /* Return true if V is a tree that we can have subvars for. Normally, this is any aggregate type. Also complex types which are not gimple registers can have subvars. */ @@ -5058,11 +5069,7 @@ var_can_have_subvars (const_tree v) if (!DECL_P (v)) return false; - /* Aggregates without overlapping fields can have subvars. */ - if (TREE_CODE (TREE_TYPE (v)) == RECORD_TYPE) - return true; - - return false; + return type_can_have_subvars (TREE_TYPE (v)); } /* Return true if T is a type that does contain pointers. */ Index: gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-1.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-1.c (revision 182838) +++ gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-1.c (working copy) @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fno-tree-ccp -fdump-tree-ealias" } */ +/* { dg-options "-O2 -fno-tree-forwprop -fno-tree-ccp -fdump-tree-ealias" } */ extern void abort (void); struct X { Index: gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-2.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-2.c (revision 182838) +++ gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-2.c (working copy) @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fno-tree-ccp -fdump-tree-ealias" } */ +/* { dg-options "-O2 -fno-tree-forwprop -fno-tree-ccp -fdump-tree-ealias" } */ extern void abort (void); struct X {