From patchwork Wed Feb 12 21:48:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Stump X-Patchwork-Id: 319782 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3CA0C2C0081 for ; Thu, 13 Feb 2014 08:49:05 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :content-type:content-transfer-encoding:subject:date:message-id :cc:to:mime-version; q=dns; s=default; b=puw/KtHvNwHBYhPlAW1SFV8 BCbFl2ezjc1/oCRpw5QWaRz7aLyKBxVxVi3dgHM0dItBiKwfGJvwLpZ+BXBH+6m0 wlUomkZ+19wshF5HGsqmDMezAZrv62SBEgvPLD0w9ChyiVFxyxBdF2uSDQzRar7V 9oGzfaSmpGh/5n/GKxxs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :content-type:content-transfer-encoding:subject:date:message-id :cc:to:mime-version; s=default; bh=pXG0+nbd41YikdcGu0GtfN4vwnM=; b= CoSiVZXxEsi2ltbMX/SYrUveo3PuVTbLp1SaBu375gpDqkLI7PiyliQ2eYTFRZV8 HfPSIbJbKZDEc6XgWCGKHykCAxVsDbXOYssnYmppKgSsjdHAgjhfHxwzDRKPgHHb LemGnq6GRme3J/YXYZlLO3Vqbp9e3em2R0OACL8fwus= Received: (qmail 16669 invoked by alias); 12 Feb 2014 21:48:58 -0000 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 Received: (qmail 16618 invoked by uid 89); 12 Feb 2014 21:48:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_PBL, RCVD_IN_SEMBLACK, RCVD_IN_SORBS_DUL, RDNS_DYNAMIC autolearn=no version=3.3.2 X-HELO: mrs.kithrup.com Received: from c-24-4-193-8.hsd1.ca.comcast.net (HELO mrs.kithrup.com) (24.4.193.8) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Feb 2014 21:48:56 +0000 Received: from [10.0.0.2] (c-24-4-193-8.hsd1.ca.comcast.net [24.4.193.8]) by mrs.kithrup.com (Postfix) with ESMTPSA id 8D2672009B96; Wed, 12 Feb 2014 13:48:52 -0800 (PST) From: Mike Stump Subject: wide-int, tree Date: Wed, 12 Feb 2014 13:48:52 -0800 Message-Id: Cc: Kenneth Zadeck , "gcc-patches@gcc.gnu.org Patches" To: Richard Biener Mime-Version: 1.0 (Mac OS X Mail 7.1 \(1827\)) In resolving a recent x86_64 libitm build problem found while trunk merging, I discovered that fold_builtin_memory_op grabs an int whose size is based upon the size of a complex long double, which is 256 bits, and then during type hashing (where it calls type_hash_canon), it wants to check to see if this value fits into a uhwi. to_widest is aborting due to 256 (complex long double) >= 128 (max wide int from i386-modes.def: > /* Keep the OI and XI modes from confusing the compiler into thinking > that these modes could actually be used for computation. They are > only holders for vectors during data movement. */ > #define MAX_BITSIZE_MODE_ANY_INT (128) ) to_widest does this to prevent large values from being truncated into smaller values. The patch below fixes it, however, the question is, is this the right place to fix it. Another fix would be to admit that the compiler does use 256 bit integers on x86 (for the maximum value of the OImode type) and instead change MAX_BITSIZE_MODE_ANY_INT to be 256. Other possibilities exist. This problem is limited to x86, since it is the only port that uses MAX_BITSIZE_MODE_ANY_INT. Thoughts? The chain of how we got here: fold_builtin_3: case BUILT_IN_MEMMOVE: return fold_builtin_memory_op (loc, arg0, arg1, arg2, => type, ignore, /*endp=*/3); fold_builtin_memory_op: if (FLOAT_MODE_P (TYPE_MODE (srctype)) || TREE_CODE (srctype) == BOOLEAN_TYPE || TREE_CODE (srctype) == ENUMERAL_TYPE) { B enum machine_mode mode = int_mode_for_mode (TYPE_MODE (srctype)); if (mode == BLKmode) srctype = NULL_TREE; else srctype = build_nonstandard_integer_type (GET_MODE_BITSIZE (mode), => 1); } build_nonstandard_integer_type: if (unsignedp) fixup_unsigned_type (itype); else B => fixup_signed_type (itype); ret = itype; if (tree_fits_uhwi_p (TYPE_MAX_VALUE (itype))) ret = type_hash_canon (tree_to_uhwi (TYPE_MAX_VALUE (itype)), itype); if (precision <= MAX_INT_CACHED_PREC) nonstandard_integer_type_cache[precision + unsignedp] = ret; return ret; diff --git a/gcc/tree.c b/gcc/tree.c index 2a68b03..8f2891a 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -6970,9 +6970,14 @@ tree_fits_shwi_p (const_tree t) bool tree_fits_uhwi_p (const_tree t) { - return (t != NULL_TREE - && TREE_CODE (t) == INTEGER_CST - && wi::fits_uhwi_p (wi::to_widest (t))); + if (t == NULL_TREE) + return false; + if (TREE_CODE (t) != INTEGER_CST) + return false; + if (TREE_INT_CST_EXT_NUNITS (t) == 1) + return TREE_INT_CST_ELT (t, 0) >= 0; + return (TREE_INT_CST_EXT_NUNITS (t) == 2 + && TREE_INT_CST_ELT (t, 1) == 0); } /* T is an INTEGER_CST whose numerical value (extended according to