From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 49670 invoked by alias); 17 Aug 2017 13:56:39 -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 47881 invoked by uid 89); 17 Aug 2017 13:56:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=Cx X-HELO: EUR03-AM5-obe.outbound.protection.outlook.com Received: from mail-eopbgr30089.outbound.protection.outlook.com (HELO EUR03-AM5-obe.outbound.protection.outlook.com) (40.107.3.89) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 Aug 2017 13:56:35 +0000 Received: from DB6PR0801MB2053.eurprd08.prod.outlook.com (10.168.86.22) by DB6PR0801MB2055.eurprd08.prod.outlook.com (10.168.86.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Thu, 17 Aug 2017 13:56:32 +0000 Received: from DB6PR0801MB2053.eurprd08.prod.outlook.com ([fe80::2d78:6ac0:142:cc9a]) by DB6PR0801MB2053.eurprd08.prod.outlook.com ([fe80::2d78:6ac0:142:cc9a%18]) with mapi id 15.01.1341.024; Thu, 17 Aug 2017 13:56:32 +0000 From: Wilco Dijkstra To: Richard Biener , Alexander Monakov CC: GCC Patches , nd Subject: Re: [PATCH v2] Simplify pow with constant Date: Thu, 17 Aug 2017 14:19:00 -0000 Message-ID: References: ,, In-Reply-To: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DB6PR0801MB2055;6:g4z03r2w7AscMqzX4thilbZeR6rJHJFofYZbixL2F4cTavdBOyJ10Ahy2DCGD+xVo9xdYxeWw1AI/iolnVuV/XpSEwC50bEFPZzDMLoVKg8AOqaT05aGAWnsm6KIVXD41E6HGds0dQtS5RWugksTyo8LpPhgGk/nim5QqR3cr3NIlw8Gz6z820WAxv+wrgGd/kVvw2us55cO10D+/viexY6uv377iuo0SUVext8PRQvGmOfrpIWpnCLtaW3wkqm30BO8mM/+OhPV5DXB3+cFB/JGnEk1IY1/fheWKeCpWOl/+Iqg/r//CENl/P2XdOHfiNPv+3H+1d+Ubq017x1Mvg==;5:bUn38T79yHTI+9nmnRP36glaIwvTih9rp2cOFxSQ15Iu9iKjPwRiKIxyZfUWE2UjDkqOgbyuP/B1WYqq4Q+2b+O5HPoDDJOOVm3nNWmwh5/WVCMpA9/HpyCOmYadOVKB6bh5jD7sh9pNzWc+L58HdQ==;24:nkTqX3YBOmf5iuK1jEcQPMXE17kD75YngQxl29mw4GY/yesXOuctmqh9hrWJ5/8qy4kViJijw459h2iz5LK1SZYD+JZ0N7NKBKv7pOAeylY=;7:bXyQJtRvLURt5TZdqnnJl36v6nylUr5Zv+e70Sd1B4aG4uum1ykX57di+MNWRZoywFcD5SH3n+jgsHD107ZE+Cv0CHZ9AX4dFe9iYj9Ne0RaUu4tSxG1JdYT+L5Kqso7muPgsGaiIFf9Ob+Uaj0lsb2B87cuvn+q2MVDrENfGfhYbzAAGAwrXrHEMxSdaJdZZ5pnMHIiKeEGPAXgebTCOTDjwFTDSzm2Xgh9b2TUwJk= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 769bf6ae-1d07-406e-6cd5-08d4e577c41c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:DB6PR0801MB2055; x-ms-traffictypediagnostic: DB6PR0801MB2055: nodisclaimer: True x-exchange-antispam-report-test: UriScan:(180628864354917); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(100000703101)(100105400095)(10201501046)(93006095)(93001095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123558100)(20161123562025)(20161123564025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DB6PR0801MB2055;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DB6PR0801MB2055; x-forefront-prvs: 0402872DA1 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(979002)(6009001)(39860400002)(377424004)(189002)(199003)(54534003)(72206003)(14454004)(3660700001)(8936002)(478600001)(6246003)(53936002)(76176999)(54356999)(50986999)(86362001)(101416001)(39060400002)(74316002)(4326008)(106356001)(189998001)(33656002)(2900100001)(7696004)(105586002)(305945005)(25786009)(2906002)(7736002)(6116002)(8676002)(2950100002)(81166006)(5660300001)(81156014)(102836003)(3846002)(68736007)(9686003)(5250100002)(54906002)(66066001)(93886005)(97736004)(99286003)(55016002)(229853002)(3280700002)(6506006)(6436002)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR0801MB2055;H:DB6PR0801MB2053.eurprd08.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Aug 2017 13:56:31.8586 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB2055 X-SW-Source: 2017-08/txt/msg01075.txt.bz2 This patch simplifies pow (C, x) into exp (x * C1) if C > 0, C1 =3D log (C). Do this only for fast-math as accuracy is reduced. This is much faster since pow is more complex than exp - with current GLIBC the speedup is more than 7 times for this transformation. The worst-case ULP error of the transformation for powf (10.0, x) in SPEC was 2.5. If we allow use of exp10 in match.pd, the ULP error would be lowe= r. OK for commit? ChangeLog: 2017-08-17 Wilco Dijkstra * match.pd: Add pow (C, x) simplification. -- diff --git a/gcc/match.pd b/gcc/match.pd index 0e36f46b914bc63c257cef47152ab1aa507963e5..a614917c8c9f24bba20c521e9b5= f558be4886813 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3622,6 +3622,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (logs (pows @0 @1)) (mult @1 (logs @0)))) =20 + /* pow(C,x) -> exp(log(C)*x) if C > 0. */ + (for pows (POW) + exps (EXP) + logs (LOG) + (simplify + (pows REAL_CST@0 @1) + (if (real_compare (GT_EXPR, TREE_REAL_CST_PTR (@0), &dconst0)) + (exps (mult (logs @0) @1))))) + (for sqrts (SQRT) cbrts (CBRT) pows (POW)