From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122963 invoked by alias); 5 Mar 2015 18:08:21 -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 122953 invoked by uid 89); 5 Mar 2015 18:08:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD autolearn=ham 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; Thu, 05 Mar 2015 18:08:20 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 7DCCE543F32; Thu, 5 Mar 2015 19:08:16 +0100 (CET) Date: Thu, 05 Mar 2015 18:08:00 -0000 From: Jan Hubicka To: Jeff Law Cc: Martin =?iso-8859-2?Q?Li=B9ka?= , Marek Polacek , GCC Patches , "hubi >> Jan Hubicka" Subject: Re: [PATCH] Fix PR ipa/65318 Message-ID: <20150305180816.GB87243@kam.mff.cuni.cz> References: <54F85FE8.2070104@suse.cz> <20150305142915.GB26802@redhat.com> <54F86A28.8040804@suse.cz> <54F88104.6050409@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54F88104.6050409@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2015-03/txt/msg00311.txt.bz2 Hi, this patch sovles the incorrect folding. The very same unification (ignoring signedness by checking that memory representation is the same) is done by constant pool. Some of the other uses of ctor_for_folding therefore already uses VIEW_CONVERT_EXPR, I suppose as a partial fix for past bugs. This particular case is handled by get_symbol_constant_value that does not VCE. Maybe we usually don't drop scalar constant to constant pool that often, so this did not show up. Attached is non-ICF testcase. It is bit questionable if we consider this to be valid, but it is better to be safe than sorry. Mixing signed/unsigned may be more common with LTO. Bootstrap/regtest running in x86_64-linux, seems sane? Honza static short a __attribute__ ((alias ("c"))); short b = -1; static unsigned short c = 0; int main () { if (a <= b) return 1; return 0; } * gimple-fold.c (get_symbol_constant_value): Convert to symbol type. Index: gimple-fold.c =================================================================== --- gimple-fold.c (revision 221170) +++ gimple-fold.c (working copy) @@ -263,7 +263,16 @@ get_symbol_constant_value (tree sym) { val = canonicalize_constructor_val (unshare_expr (val), sym); if (val && is_gimple_min_invariant (val)) - return val; + { + if (!useless_type_conversion_p (TREE_TYPE (sym), TREE_TYPE (val))) + { + if (operand_equal_p (TYPE_SIZE (TREE_TYPE (sym)), + TYPE_SIZE (TREE_TYPE (val)), 0)) + return NULL_TREE; + val = fold_unary (VIEW_CONVERT_EXPR, TREE_TYPE (sym), val); + } + return val; + } else return NULL_TREE; }