From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 71667 invoked by alias); 13 Jun 2019 17:26:41 -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 71659 invoked by uid 89); 13 Jun 2019 17:26:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1560 X-HELO: EUR03-AM5-obe.outbound.protection.outlook.com Received: from mail-eopbgr30081.outbound.protection.outlook.com (HELO EUR03-AM5-obe.outbound.protection.outlook.com) (40.107.3.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jun 2019 17:26:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PqgGo54IG+vFUutg2f6zQ0y+XOCsLyuBQa+ZGxQ8gNI=; b=ceOjOXdN9Rxd1gtWIPuMWqrWe6YG3i1GRX6uRgbXfFBWsSt9zgttuzQymTP07K3HTaYevxDUwxSX61+hQv1oRFLTucabruO/U2myMTITAPuR399gg2Krupb6Pdu8IXxbRRDl7kjhggdRfOqtStdgz7EVCqOyopBIJ8mRZ4KFCpI= Received: from VI1PR0801MB2127.eurprd08.prod.outlook.com (10.168.62.22) by VI1PR0801MB2112.eurprd08.prod.outlook.com (10.173.75.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1965.15; Thu, 13 Jun 2019 17:26:35 +0000 Received: from VI1PR0801MB2127.eurprd08.prod.outlook.com ([fe80::54a8:e98d:2986:5cb5]) by VI1PR0801MB2127.eurprd08.prod.outlook.com ([fe80::54a8:e98d:2986:5cb5%4]) with mapi id 15.20.1987.010; Thu, 13 Jun 2019 17:26:35 +0000 From: Wilco Dijkstra To: Joel Hutton CC: nd , GCC Patches Subject: Re: [AArch64] Use scvtf fbits option where appropriate Date: Thu, 13 Jun 2019 17:26:00 -0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; x-ms-oob-tlc-oobclassifiers: OLM:7691; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Wilco.Dijkstra@arm.com X-SW-Source: 2019-06/txt/msg00785.txt.bz2 Hi Joel, A few comments below: +/* If X is a positive CONST_DOUBLE with a value that is the reciprocal of a + power of 2 (i.e 1/2^n) return the number of float bits. e.g. for x=3D= =3D(1/2^n) + return log2 (n). Otherwise return 0. */ +int +aarch64_fpconst_pow2_recip (rtx x) +{ + REAL_VALUE_TYPE r0; + + if (!CONST_DOUBLE_P (x)) + return 0; + + r0 =3D *CONST_DOUBLE_REAL_VALUE (x); + if (exact_real_inverse (DFmode, &r0) + && !REAL_VALUE_NEGATIVE (r0)) + { + if (exact_real_truncate (DFmode, &r0)) Truncate to double? That doesn't do anything... + { + HOST_WIDE_INT value =3D real_to_integer (&r0); + value =3D value & 0xffffffff; + if ((value !=3D 0) && ( (value & (value - 1)) =3D=3D 0)) + { + int ret =3D exact_log2 (value); + gcc_assert (IN_RANGE (ret, 0, 31)); + return ret; + } Wouldn't it be easier to just do exact_log2 (real_to_integer (&r0)) and then check the range is in 1..31? --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -6016,6 +6016,40 @@ [(set_attr "type" "f_cvtf2i")] ) =20 +(define_insn "*aarch64_cvtf__2_mult" + [(set (match_operand:GPF 0 "register_operand" "=3Dw,w") + (mult:GPF (FLOATUORS:GPF + (match_operand: 1 "register_operand" "w,?r")) + (match_operand 2 "aarch64_fp_pow2_recip""Dt,Dt")))] We should add a comment before both define_insn similar to the other conversions, explaining what they do and why there are 2 separate patterns (the default versions of the conversions appear to be missing a comment too= ). Wilco