From patchwork Thu Jun 28 00:25:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 935823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-480614-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="yob3h4B4"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="MBLlKFmV"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41GLF96Dq1z9s01 for ; Thu, 28 Jun 2018 10:26:52 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=MSvMalkOMUJcrSyNb/VynFgLo1gbeITJ8Y3y5Sq8SCuKGE CIMsHP5PxexdotOgf92S/rDR/eOlOEWLctBH7oVR/LTavotCgIzdOlQYO82biR9Z fGghpclgbiQZCeYE7WIED8f17YLj+L9lLDH5fgQn5pk09Yx0Ofq7F+VKpGJ4U= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=cXT+yzt5BhR05q1DeyN2sHRwOSQ=; b=yob3h4B4ORNIvIDLgxmh MMOqwI5jUU5u8oJtppDS2P+Gj1+s1+hZAiWYX+ljPOIJKuOr4TtxuIq862l9xuqF is50+mDzgDC7u83yO4FwOD3cCiWqurDmp2U+uQBwipbT3QOOlrJ/8AoT3irBzg3E rjQTkNeUvJis7Il/BMnKkIA= Received: (qmail 109493 invoked by alias); 28 Jun 2018 00:26:43 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 109478 invoked by uid 89); 28 Jun 2018 00:26:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:sk:t22-v6s X-HELO: mail-lj1-f176.google.com Received: from mail-lj1-f176.google.com (HELO mail-lj1-f176.google.com) (209.85.208.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 28 Jun 2018 00:26:41 +0000 Received: by mail-lj1-f176.google.com with SMTP id t22-v6so3007470ljc.11 for ; Wed, 27 Jun 2018 17:26:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:from:date:message-id:subject:to; bh=q1xsPK7MNWh0emFFZpIqS0BVJ8Kulsgk4rGwUARu2UM=; b=MBLlKFmVQ8hAwy/UGJoVP1piKo/CiPe8o2oXMBbHVuzmPW0x54socXrQ1vvJyUGU8I 28ukSg9T5D4t5erxctAqC9UA2oqt8FKezTbcAEci807IItZhZNnPD/j9JCY/lvYLnAam 7cUdXTk68tCtyyTXlVhCi6QZj+b9WfzpJctl4= MIME-Version: 1.0 Received: by 2002:a2e:6c02:0:0:0:0:0 with HTTP; Wed, 27 Jun 2018 17:25:58 -0700 (PDT) From: Kugan Vivekanandarajah Date: Thu, 28 Jun 2018 10:25:58 +1000 Message-ID: Subject: [ABSU_EXPR] Add some of the missing patterns in match,pd To: GCC Patches X-IsSubscribed: yes Hi, This patch adds some of the missing patterns in match.pd for ABSU_EXPR. Bootstrap and regression testing on x86_64-linux-gnu. Is this OK if no regressions. Thanks, Kugan gcc/ChangeLog: 2018-06-28 Kugan Vivekanandarajah * match.pd (absu(x)*absu(x) -> x*x): Handle. (absu(absu(X)) -> absu(X)): Likewise. (absu(-X) -> absu(X)): Likewise. (absu(X) where X is nonnegative -> X): Likewise. From 374ee7928039c16cb091bd02d5efd4c493aab86e Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Mon, 18 Jun 2018 10:51:06 +1000 Subject: [PATCH] add absu patterns Change-Id: Ied504be83f00041a6c815d23e16a394b71445f27 --- gcc/match.pd | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index c1e0963..a356a92 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -571,10 +571,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (copysigns (op @0) @1) (copysigns @0 @1)))) -/* abs(x)*abs(x) -> x*x. Should be valid for all types. */ -(simplify - (mult (abs@1 @0) @1) - (mult @0 @0)) +/* abs(x)*abs(x) -> x*x. Should be valid for all types. + also for absu(x)*absu(x) -> x*x. */ +(for op (abs absu) + (simplify + (mult (op@1 @0) @1) + (mult @0 @0))) /* cos(copysign(x, y)) -> cos(x). Similarly for cosh. */ (for coss (COS COSH) @@ -1013,15 +1015,24 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && tree_nop_conversion_p (type, TREE_TYPE (@2))) (bit_xor (convert @1) (convert @2)))) -(simplify - (abs (abs@1 @0)) - @1) -(simplify - (abs (negate @0)) - (abs @0)) -(simplify - (abs tree_expr_nonnegative_p@0) - @0) +/* Convert abs (abs (X)) into abs (X). + also absu (absu (X)) into absu (X). */ +(for op (abs absu) + (simplify + (op (op@1 @0)) + @1)) + +/* Convert abs[u] (-X) -> abs[u] (X). */ +(for op (abs absu) + (simplify + (op (negate @0)) + (op @0))) + +/* Convert abs[u] (X) where X is nonnegative -> (X). */ +(for op (abs absu) + (simplify + (op tree_expr_nonnegative_p@0) + @0)) /* A few cases of fold-const.c negate_expr_p predicate. */ (match negate_expr_p -- 2.7.4