From patchwork Tue Sep 17 14:33:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1163412 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-509113-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="h+LwHkHB"; dkim-atps=neutral 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 46XlwH31xlz9sCJ for ; Wed, 18 Sep 2019 00:33:34 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=VHWmuZdARrRhK/8zERIM9h3Xgx0q2v8Ipk9fyh3XPH70+ogoghWm7 Cs4A4Elvpex6sRPM2bAgSjfjK+OQKVngIBZydYYZRCETZsSNCU3f8QysWyPdwgZ2 DaNv/6pTiCyATriQYo/sb2I4vof/47auC8u/Ij5CBbGQu7nzOjHfwU= 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 :to:subject:date:message-id:mime-version:content-type; s= default; bh=YSzLLyQl9ZbBINvIQKOUnIBDIUQ=; b=h+LwHkHBVXSI20npCvad egPl63TpPQHvJQcm3FCeWAqWyU8kbR8NzX1bL1T5gpWrL+wYI0FAwRPqu/SnZaoV /fOo+IQOM3XpXXqzH/FBesdWCGX6ikWF7d0RqtU/9vFgGlDhwEYt7CExUdhZRRub 0x5uEMSHJ9mhGOpwVN4bwa0= Received: (qmail 7407 invoked by alias); 17 Sep 2019 14:33:28 -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 7386 invoked by uid 89); 17 Sep 2019 14:33:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 17 Sep 2019 14:33:26 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 67BD328 for ; Tue, 17 Sep 2019 07:33:25 -0700 (PDT) Received: from localhost (dashpi.manchester.arm.com [10.32.98.126]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0F3453F575 for ; Tue, 17 Sep 2019 07:33:24 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Make assemble_real generate canonical CONST_INTs Date: Tue, 17 Sep 2019 15:33:23 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes assemble_real used GEN_INT to create integers directly from the longs returned by real_to_target. assemble_integer then went on to interpret the const_ints as though they had the mode corresponding to the accompanying size parameter: imode = mode_for_size (size * BITS_PER_UNIT, mclass, 0).require (); for (i = 0; i < size; i += subsize) { rtx partial = simplify_subreg (omode, x, imode, i); But in the assemble_real case, X might not be canonical for IMODE. If the interface to assemble_integer is supposed to allow outputting (say) the low 4 bytes of a DImode integer, then the simplify_subreg above is wrong. But if the number of bytes passed to assemble_integer is supposed to be the number of bytes that the integer actually contains, assemble_real is wrong. This patch takes the latter interpretation and makes assemble_real generate const_ints that are canonical for the number of bytes passed. The flip_storage_order handling assumes that each long is a full SImode, which e.g. excludes BITS_PER_UNIT != 8 and float formats whose memory size is not a multiple of 32 bits (which includes HFmode at least). The patch therefore leaves that code alone. If interpreting each integer as SImode is correct, the const_ints that it generates are also correct. Tested on aarch64-linux-gnu and x86_64-linux-gnu. Also tested by making sure that there were no new errors from a range of cross-built targets. OK to install? Richard 2019-09-17 Richard Sandiford gcc/ * varasm.c (assemble_real): Generate canonical const_ints. Index: gcc/varasm.c =================================================================== --- gcc/varasm.c 2019-09-05 08:49:30.829739618 +0100 +++ gcc/varasm.c 2019-09-17 15:30:10.400740515 +0100 @@ -2873,25 +2873,27 @@ assemble_real (REAL_VALUE_TYPE d, scalar real_to_target (data, &d, mode); /* Put out the first word with the specified alignment. */ + unsigned int chunk_nunits = MIN (nunits, units_per); if (reverse) elt = flip_storage_order (SImode, gen_int_mode (data[nelts - 1], SImode)); else - elt = GEN_INT (data[0]); - assemble_integer (elt, MIN (nunits, units_per), align, 1); - nunits -= units_per; + elt = GEN_INT (sext_hwi (data[0], chunk_nunits * BITS_PER_UNIT)); + assemble_integer (elt, chunk_nunits, align, 1); + nunits -= chunk_nunits; /* Subsequent words need only 32-bit alignment. */ align = min_align (align, 32); for (int i = 1; i < nelts; i++) { + chunk_nunits = MIN (nunits, units_per); if (reverse) elt = flip_storage_order (SImode, gen_int_mode (data[nelts - 1 - i], SImode)); else - elt = GEN_INT (data[i]); - assemble_integer (elt, MIN (nunits, units_per), align, 1); - nunits -= units_per; + elt = GEN_INT (sext_hwi (data[i], chunk_nunits * BITS_PER_UNIT)); + assemble_integer (elt, chunk_nunits, align, 1); + nunits -= chunk_nunits; } }