From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 83596 invoked by alias); 26 Jun 2017 08:46:22 -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 83577 invoked by uid 89); 26 Jun 2017 08:46:22 -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_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: EUR01-HE1-obe.outbound.protection.outlook.com Received: from mail-he1eur01on0052.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) (104.47.0.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 26 Jun 2017 08:46:19 +0000 Received: from VI1PR0801MB2031.eurprd08.prod.outlook.com (10.173.74.140) by VI1PR0801MB2031.eurprd08.prod.outlook.com (10.173.74.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1199.15; Mon, 26 Jun 2017 08:46:15 +0000 Received: from VI1PR0801MB2031.eurprd08.prod.outlook.com ([fe80::341b:7cb4:66ec:496e]) by VI1PR0801MB2031.eurprd08.prod.outlook.com ([fe80::341b:7cb4:66ec:496e%17]) with mapi id 15.01.1199.017; Mon, 26 Jun 2017 08:46:15 +0000 From: Tamar Christina To: Andrew Pinski CC: GCC Patches , nd , "law@redhat.com" , "ian@airs.com" , "rguenther@suse.de" Subject: Re: [GCC][PATCH][mid-end] Optimize x * copysign (1.0, y) [Patch (1/2)] Date: Mon, 26 Jun 2017 08:46:00 -0000 Message-ID: References: , In-Reply-To: authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1PR0801MB2031;7:d3M0WnYNPtBISlPLduSRgLIU9azsFepkliaX/UoZwuaQ7CVeinkv8v5F9DEeg0ildWMCFGt5M1Fm12kh4OZgvwGR84JKkSrvHJQK40Wx3UcFkkBiRe7lxy9qDDtGzn0KTEJlmCxI4Uj1bCbZ8ShwmrWGRJEe1fLE/PbPTpF/SWW4tTA6zqM1N83OGkDJST/+Ep5P8xAiTNb8DR6OcxMyeh5uVsW49YuAyTsLVHqYQaWw346rmyeP2bPuDExFSObttvYQKQD2bydwNtZdRdhg/B7Eq/3J94sgYzw5Tx+KMdg5UC3Pb2U/J35zgXZl9+wTjnf/qkSJv13Kv4PdbTxU+xApvboBrFmqwXU49fgcNZlFiRA3ShRdYH+CcaXZWw526fUluhJyL7NcHhDAZvN4lAySLkxE4IogsKY8LvPN/Zxgqr0wMB73hQX1eqbDZjVWkvlGB0ZR6PgIDcCyCJ7PrYt6/+xapJZwk2Agan1LJ0q5FMblXNCECyblPVO01To70TB4lxLI/zCPCek6qOVjPBg7+W5Je0az8lWaDuwoWSAXsWZb0341E0fZBl9UT040GnSX6OLLlZhwU2sfrkYjiaPeaBvbFIgmvJGLWZV0D2biH36vZ1RXq40j1brQACsmeKhpEKAsbF98Kdg8XyqxvEr7RiZ8Ddh2PAb9JDHWr38tddCTif2zlbKaVP2Q4eliTYe3akQfBiqDcPUsfDhhWhuMDB+MtjZUcDfMqTKwTJHPF8VsABwricAQ1+4rOKUL9MJsva9vHe/LxzQRfCAneV9MAM252OqRPo61dEeO6HA= x-ms-office365-filtering-correlation-id: dd97fd9e-bdee-4269-9d08-08d4bc6fce77 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254075)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506067)(300135500095);SRVR:VI1PR0801MB2031; x-ms-traffictypediagnostic: VI1PR0801MB2031: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917)(22074186197030)(236129657087228)(48057245064654)(183786458502308)(148574349560750); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(20161123562025)(20161123560025)(20161123564025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:VI1PR0801MB2031;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:VI1PR0801MB2031; x-forefront-prvs: 0350D7A55D x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(39840400002)(39850400002)(39450400003)(39410400002)(39400400002)(377424004)(53754006)(377454003)(24454002)(81166006)(53546010)(2900100001)(5890100001)(76176999)(99286003)(9686003)(55016002)(54906002)(6306002)(53936002)(3660700001)(8936002)(54356999)(6436002)(5660300001)(6506006)(81156014)(8676002)(102836003)(6116002)(3846002)(3280700002)(50986999)(966005)(189998001)(14454004)(72206003)(110136004)(2950100002)(7736002)(478600001)(5250100002)(7696004)(86362001)(229853002)(66066001)(6916009)(4326008)(38730400002)(74316002)(6246003)(25786009)(33656002)(2906002)(39060400002)(1411001)(305945005);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0801MB2031;H:VI1PR0801MB2031.eurprd08.prod.outlook.com;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Jun 2017 08:46:15.5388 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB2031 X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg01889.txt.bz2 Hi Andrew, Thanks! I'll put together the rest today or tomorrow. Sorry for the slow response on this one. Tamar ________________________________________ From: Andrew Pinski Sent: Monday, June 26, 2017 3:09:54 AM To: Tamar Christina Cc: GCC Patches; nd; law@redhat.com; ian@airs.com; rguenther@suse.de Subject: Re: [GCC][PATCH][mid-end] Optimize x * copysign (1.0, y) [Patch (1= /2)] On Sat, Jun 24, 2017 at 4:53 PM, Andrew Pinski wrote: > On Mon, Jun 12, 2017 at 12:56 AM, Tamar Christina > wrote: >> Hi All, >> >> this patch implements a optimization rewriting >> >> x * copysign (1.0, y) and >> x * copysign (-1.0, y) > > > This reminds me: > copysign(-1.0, y) can be just optimized to: > copysign(1.0, y) > > I did that in my patch here: > https://gcc.gnu.org/ml/gcc-patches/2017-06/msg01860.html I updated the patch to handle all constants and not just -1.0. > > This should allow you to reduce the number of patterns needed to match he= re. > Note I still think we could do this in expand without a new > builtin/internal function. > I might go and code that up soonish. Also something like attached (NOTE this is NOT a full patch and needs the xorsign optabs part of your patch) should work for the expand side rather than creating a new builtin. There still needs to handling of the vector based copysign. But you should get the general idea. I would like to see more of these special expand patterns really. NOTE you can remove the target hook part and just check if xorsign optab is there. I don't know if that is what we want to do if not allow for generic expanding of this. Thanks, Andrew Pinski > > Thanks, > Andrew > >> >> to: >> >> x ^ (y & (1 << sign_bit_position)) >> >> This is done by creating a special builtin during matching and generate = the >> appropriate instructions during expand. This new builtin is called XORSI= GN. >> >> The expansion of xorsign depends on if the backend has an appropriate op= tab >> available. If this is not the case then we use a modified version of the= existing >> copysign which does not take the abs value of the first argument as a fa= ll back. >> >> This patch is a revival of a previous patch >> https://gcc.gnu.org/ml/gcc-patches/2015-10/msg00069.html >> >> Bootstrapped on both aarch64-none-linux-gnu and x86_64 with no issues. >> Regression done on aarch64-none-linux-gnu and no regressions. >> >> Ok for trunk? >> >> gcc/ >> 2017-06-07 Tamar Christina >> >> * builtins.def (BUILT_IN_XORSIGN, BUILT_IN_XORSIGNF): New. >> (BUILT_IN_XORSIGNL, BUILT_IN_XORSIGN_FLOAT_NX): Likewise. >> * match.pd (mult (COPYSIGN:s real_onep @0) @1): New simplifier. >> (mult (COPYSIGN:s real_mus_onep @0) @1): Likewise. >> (copysigns @0 (negate @1)): Likewise. >> * builtins.c (expand_builtin_copysign): Promoted local to argume= nt. >> (expand_builtin): Added CASE_FLT_FN_FLOATN_NX (BUILT_IN_XORSIGN)= and >> CASE_FLT_FN (BUILT_IN_XORSIGN). >> (BUILT_IN_COPYSIGN): Updated function call. >> * optabs.h (expand_copysign): New bool. >> (expand_xorsign): New. >> * optabs.def (xorsign_optab): New. >> * optabs.c (expand_copysign): New parameter. >> * fortran/f95-lang.c (xorsignl, xorsign, xorsignf): New. >> * fortran/mathbuiltins.def (XORSIGN): New. >> >> gcc/testsuite/ >> 2017-06-07 Tamar Christina >> >> * gcc.dg/tree-ssa/xorsign.c: New. >> * gcc.dg/xorsign_exec.c: New. >> * gcc.dg/vec-xorsign_exec.c: New. >> * gcc.dg/tree-ssa/reassoc-39.c (f2, f3): Updated constant to 2.