From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 79770 invoked by alias); 24 Jun 2017 23:53:20 -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 78819 invoked by uid 89); 24 Jun 2017 23:53:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=H*Ad:U*ian, revival, christina, Christina X-HELO: mail-yb0-f196.google.com Received: from mail-yb0-f196.google.com (HELO mail-yb0-f196.google.com) (209.85.213.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 24 Jun 2017 23:53:18 +0000 Received: by mail-yb0-f196.google.com with SMTP id g206so3587900yba.2 for ; Sat, 24 Jun 2017 16:53:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ZtEioCPfYhZOjC0kHRagl9//m4qTt26Gsqf0XhFPtkw=; b=JpTbtlRJwXxOibDxFo4/86FrfNsM1VvkUzl8kMDtFAKYWT/+ALK6GGU5UkaTjdec6x zJQPh/r38q/Ar6FM2BeQJdEalFAt4hnnzpROqgBTKYuJEtLW13k+J3IB4oe2MbVyw5N5 EZBuqiNyR9Y97OPDXvTkE0Ne9MJ/z6d5Ew0rEhj6vA6mYUirOpYOpQqbVErC7iQOS+cd Brim/SXf2GRzzMbutzwLpRHaCVwIwc0FKAg4x+BkjCOiv0NrKk3eotInORZkepZlGebl slvZIbDzCLNW2aFUu+pLIyI3MDwLpQFSnSWI/uoQxWE5OvW5DUhjxBMxgAuvgc6UQv6j Pitg== X-Gm-Message-State: AKS2vOymvtCOoAh/OwW8MAu9qb/67RcTyE+++kR3bnDHp0WCwU2zr1Kx UxSz6s3FMTWEZb9l6o//4hECdhBy1g== X-Received: by 10.37.176.140 with SMTP id f12mr10534242ybj.231.1498348396830; Sat, 24 Jun 2017 16:53:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.47.200 with HTTP; Sat, 24 Jun 2017 16:53:16 -0700 (PDT) In-Reply-To: References: From: Andrew Pinski Date: Sat, 24 Jun 2017 23:53:00 -0000 Message-ID: Subject: Re: [GCC][PATCH][mid-end] Optimize x * copysign (1.0, y) [Patch (1/2)] To: Tamar Christina Cc: GCC Patches , nd , "law@redhat.com" , "ian@airs.com" , "rguenther@suse.de" Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg01861.txt.bz2 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 This should allow you to reduce the number of patterns needed to match here. Note I still think we could do this in expand without a new builtin/internal function. I might go and code that up soonish. 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 XORSIGN. > > The expansion of xorsign depends on if the backend has an appropriate optab > 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 fall 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 argument. > (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.