From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52101 invoked by alias); 2 Oct 2015 06:43:40 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 52091 invoked by uid 89); 2 Oct 2015 06:43:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 02 Oct 2015 06:43:37 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id B4C0A54546E; Fri, 2 Oct 2015 08:43:33 +0200 (CEST) Date: Fri, 02 Oct 2015 06:43:00 -0000 From: Jan Hubicka To: Richard Biener Cc: Jan Hubicka , gcc-patches@gcc.gnu.org Subject: Re: Do not use TYPE_CANONICAL in useless_type_conversion Message-ID: <20151002064333.GA7903@kam.mff.cuni.cz> References: <20150930211235.GB30640@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2015-10/txt/msg00153.txt.bz2 > There must be a reason why I allowed modes to differ there btw ;) Thinking about it, I guess reason is that incomplete types do not have resonable modes set, so requiring modes to match will prevent complete and incomplete types to match. Here is updated patch which uses the earlier mode check and adjust it to skip modes only for incomplete types. Bootstrapped/regtested ppc64-linux, OK? * gimple-expr.c (useless_type_conversion_p): Do not use TYPE_CANONICAL for defining useless conversions; make structure compatible if size and mode are. Index: gimple-expr.c =================================================================== --- gimple-expr.c (revision 228267) +++ gimple-expr.c (working copy) @@ -87,15 +87,11 @@ useless_type_conversion_p (tree outer_ty if (inner_type == outer_type) return true; - /* If we know the canonical types, compare them. */ - if (TYPE_CANONICAL (inner_type) - && TYPE_CANONICAL (inner_type) == TYPE_CANONICAL (outer_type)) - return true; - /* Changes in machine mode are never useless conversions unless we deal with aggregate types in which case we defer to later checks. */ if (TYPE_MODE (inner_type) != TYPE_MODE (outer_type) - && !AGGREGATE_TYPE_P (inner_type)) + && (!AGGREGATE_TYPE_P (inner_type) + || COMPLETE_TYPE_P (outer_type))) return false; /* If both the inner and outer types are integral types, then the @@ -270,12 +266,23 @@ useless_type_conversion_p (tree outer_ty return true; } - /* For aggregates we rely on TYPE_CANONICAL exclusively and require - explicit conversions for types involving to be structurally - compared types. */ + /* For aggregates compare only the size and mode. Accesses to fields do have + a type information by themselves and thus we only care if we can i.e. + use the types in move operations. */ else if (AGGREGATE_TYPE_P (inner_type) && TREE_CODE (inner_type) == TREE_CODE (outer_type)) - return false; + return (!TYPE_SIZE (outer_type) + || (TYPE_SIZE (inner_type) + && operand_equal_p (TYPE_SIZE (inner_type), + TYPE_SIZE (outer_type), 0))); + + else if (TREE_CODE (inner_type) == OFFSET_TYPE + && TREE_CODE (inner_type) == TREE_CODE (outer_type)) + return useless_type_conversion_p (TREE_TYPE (outer_type), + TREE_TYPE (inner_type)) + && useless_type_conversion_p + (TYPE_OFFSET_BASETYPE (outer_type), + TYPE_OFFSET_BASETYPE (inner_type)); return false; }