From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58053 invoked by alias); 1 Oct 2015 14:28:31 -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 58043 invoked by uid 89); 1 Oct 2015 14:28:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f48.google.com Received: from mail-pa0-f48.google.com (HELO mail-pa0-f48.google.com) (209.85.220.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 01 Oct 2015 14:28:28 +0000 Received: by pablk4 with SMTP id lk4so75701269pab.3 for ; Thu, 01 Oct 2015 07:28:26 -0700 (PDT) X-Received: by 10.66.122.98 with SMTP id lr2mr12546300pab.146.1443709706454; Thu, 01 Oct 2015 07:28:26 -0700 (PDT) Received: from [192.168.2.74] (76-253-1-90.lightspeed.sntcca.sbcglobal.net. [76.253.1.90]) by smtp.gmail.com with ESMTPSA id tp6sm7023419pbc.81.2015.10.01.07.28.24 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 Oct 2015 07:28:25 -0700 (PDT) References: <1443707835-6888-1-git-send-email-james.greenhalgh@arm.com> Mime-Version: 1.0 (1.0) In-Reply-To: <1443707835-6888-1-git-send-email-james.greenhalgh@arm.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Message-Id: <9593201B-9298-4529-A4DA-41B5DD6DCBFE@gmail.com> Cc: gcc-patches@gcc.gnu.org From: pinskia@gmail.com Subject: Re: [Patch match.pd] Add a simplify rule for x * copysign (1.0, y); Date: Thu, 01 Oct 2015 14:28:00 -0000 To: James Greenhalgh X-IsSubscribed: yes X-SW-Source: 2015-10/txt/msg00075.txt.bz2 >=20 > On Oct 1, 2015, at 6:57 AM, James Greenhalgh w= rote: >=20 >=20 > Hi, >=20 > If it is cheap enough to treat a floating-point value as an integer and > to do bitwise arithmetic on it (as it is for AArch64) we can rewrite: >=20 > x * copysign (1.0, y) >=20 > as: >=20 > x ^ (y & (1 << sign_bit_position)) Why not just convert it to copysign (x, y) instead and let expand chose the= better implementation? Also I think this can only be done for finite and = non trapping types.=20 Thanks, Andrew >=20 > This patch implements that rewriting rule in match.pd, and a testcase > expecting the transform. >=20 > This is worth about 6% in 481.wrf for AArch64. I don't don't know enough > about the x86 microarchitectures to know how productive this transformati= on > is there. In Spec2006FP I didn't see any interesting results in either > direction. Looking at code generation for the testcase I add, I think the > x86 code generation looks worse, but I can't understand why it doesn't use > a vector-side xor and load the mask vector-side. With that fixed up I thi= nk > the code generation would look better - though as I say, I'm not an expert > here... >=20 > Bootstrapped on both aarch64-none-linux-gnu and x86_64 with no issues. >=20 > OK for trunk? >=20 > Thanks, > James >=20 > --- > gcc/ >=20 > 2015-10-01 James Greenhalgh >=20 > * match.pd (mult (COPYSIGN:s real_onep @0) @1): New simplifier. >=20 > gcc/testsuite/ >=20 > 2015-10-01 James Greenhalgh >=20 > * gcc.dg/tree-ssa/copysign.c: New. >=20 > <0001-Patch-match.pd-Add-a-simplify-rule-for-x-copysign-1..patch>