From patchwork Sat Jul 4 14:34:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Glisse X-Patchwork-Id: 491228 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 45D00140781 for ; Sun, 5 Jul 2015 00:34:21 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=aL01R34S; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=WPRnOuO+BG92IfFTeNTYriE3fxIw+UNoSrkfzmLkzH60YfqaicxiY F5cvqf+cxxRWsJqeh8hInBbuIbG/C/L39PN6CA34bV8+VbZTS4nwedEwxMxxprwW qJ/N+AQZaZ3/aadJ5QjiX9WgEk5W9Hsa4unbBLCH3lMVZBv68qbm+I= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=3HxNV1GvpvinNohBtwX8BvpbuuU=; b=aL01R34Sa/1q3jZgm32N +RgxGCNce8OP8FqdDZNz3/Sm7h+WHQlC05AdQi9yMnngd1+wH6IeXkJm274NtVa2 pB0Ga8uiwIYLiemKuqIos6pU6EJn+jetJj+Br04iIv+iUVzLQz64pA5NhGMcSp5Q 8Pc8DNbJDh+IfelsSaWoELA= Received: (qmail 111700 invoked by alias); 4 Jul 2015 14:34:12 -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 111691 invoked by uid 89); 4 Jul 2015 14:34:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL, BAYES_50, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mail3-relais-sop.national.inria.fr Received: from mail3-relais-sop.national.inria.fr (HELO mail3-relais-sop.national.inria.fr) (192.134.164.104) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Sat, 04 Jul 2015 14:34:10 +0000 Received: from ip-0.net-81-220-131.standre.rev.numericable.fr (HELO laptop-mg.local) ([81.220.131.0]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 04 Jul 2015 16:34:05 +0200 Date: Sat, 4 Jul 2015 16:34:00 +0200 (CEST) From: Marc Glisse To: gcc-patches@gcc.gnu.org Subject: Clean-ups in match.pd Message-ID: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Hello, these are just some minor changes. I believe I had already promised a build_ function to match integer_each_onep. Bootstrap+testsuite on powerpc64le-unknown-linux-gnu (it looks like *-match.c takes about 10 minutes to compile in stage2 these days). 2015-07-06 Marc Glisse * match.pd: Remove element_mode inside HONOR_*. (~ (-A) -> A - 1, ~ (A - 1) -> -A): Handle complex types. (~X | X -> -1, ~X ^ X -> -1): Merge. * tree.c (build_each_one_cst): New function. * tree.h (build_each_one_cst): Likewise. Index: match.pd =================================================================== --- match.pd (revision 225411) +++ match.pd (working copy) @@ -101,7 +101,7 @@ negative value by 0 gives -0, not +0. */ (simplify (mult @0 real_zerop@1) - (if (!HONOR_NANS (type) && !HONOR_SIGNED_ZEROS (element_mode (type))) + (if (!HONOR_NANS (type) && !HONOR_SIGNED_ZEROS (type)) @1)) /* In IEEE floating point, x*1 is not equivalent to x for snans. @@ -108,8 +108,8 @@ Likewise for complex arithmetic with signed zeros. */ (simplify (mult @0 real_onep) - (if (!HONOR_SNANS (element_mode (type)) - && (!HONOR_SIGNED_ZEROS (element_mode (type)) + (if (!HONOR_SNANS (type) + && (!HONOR_SIGNED_ZEROS (type) || !COMPLEX_FLOAT_TYPE_P (type))) (non_lvalue @0))) @@ -116,8 +116,8 @@ /* Transform x * -1.0 into -x. */ (simplify (mult @0 real_minus_onep) - (if (!HONOR_SNANS (element_mode (type)) - && (!HONOR_SIGNED_ZEROS (element_mode (type)) + (if (!HONOR_SNANS (type) + && (!HONOR_SIGNED_ZEROS (type) || !COMPLEX_FLOAT_TYPE_P (type))) (negate @0))) @@ -165,7 +165,7 @@ (rdiv @0 @0) (if (FLOAT_TYPE_P (type) && ! HONOR_NANS (type) - && ! HONOR_INFINITIES (element_mode (type))) + && ! HONOR_INFINITIES (type)) { build_one_cst (type); })) /* Optimize -A / A to -1.0 if we don't care about @@ -174,19 +174,19 @@ (rdiv:c @0 (negate @0)) (if (FLOAT_TYPE_P (type) && ! HONOR_NANS (type) - && ! HONOR_INFINITIES (element_mode (type))) + && ! HONOR_INFINITIES (type)) { build_minus_one_cst (type); })) /* In IEEE floating point, x/1 is not equivalent to x for snans. */ (simplify (rdiv @0 real_onep) - (if (!HONOR_SNANS (element_mode (type))) + (if (!HONOR_SNANS (type)) (non_lvalue @0))) /* In IEEE floating point, x/-1 is not equivalent to -x for snans. */ (simplify (rdiv @0 real_minus_onep) - (if (!HONOR_SNANS (element_mode (type))) + (if (!HONOR_SNANS (type)) (negate @0))) /* If ARG1 is a constant, we can convert this to a multiply by the @@ -297,9 +297,10 @@ @1) /* ~x | x -> -1 */ -(simplify - (bit_ior:c (convert? @0) (convert? (bit_not @0))) - (convert { build_all_ones_cst (TREE_TYPE (@0)); })) +(for op (bit_ior bit_xor plus) + (simplify + (op:c (convert? @0) (convert? (bit_not @0))) + (convert { build_all_ones_cst (TREE_TYPE (@0)); }))) /* x ^ x -> 0 */ (simplify @@ -311,11 +312,6 @@ (bit_xor @0 integer_all_onesp@1) (bit_not @0)) -/* ~X ^ X is -1. */ -(simplify - (bit_xor:c (bit_not @0) @0) - { build_all_ones_cst (type); }) - /* x & ~0 -> x */ (simplify (bit_and @0 integer_all_onesp) @@ -603,11 +599,11 @@ (simplify (bit_not (convert? (negate @0))) (if (tree_nop_conversion_p (type, TREE_TYPE (@0))) - (convert (minus @0 { build_one_cst (TREE_TYPE (@0)); })))) + (convert (minus @0 { build_each_one_cst (TREE_TYPE (@0)); })))) /* Convert ~ (A - 1) or ~ (A + -1) to -A. */ (simplify - (bit_not (convert? (minus @0 integer_onep))) + (bit_not (convert? (minus @0 integer_each_onep))) (if (tree_nop_conversion_p (type, TREE_TYPE (@0))) (convert (negate @0)))) (simplify Index: tree.c =================================================================== --- tree.c (revision 225411) +++ tree.c (working copy) @@ -1968,6 +1968,21 @@ return t; } +/* Return the constant 1 in type TYPE. If TYPE has several elements, each + element is set to 1. In particular, this is 1 + i for complex types. */ + +tree +build_each_one_cst (tree type) +{ + if (TREE_CODE (type) == COMPLEX_TYPE) + { + tree scalar = build_one_cst (TREE_TYPE (type)); + return build_complex (type, scalar, scalar); + } + else + return build_one_cst (type); +} + /* Return a constant of arithmetic type TYPE which is the multiplicative identity of the set TYPE. */ Index: tree.h =================================================================== --- tree.h (revision 225411) +++ tree.h (working copy) @@ -3772,6 +3772,7 @@ extern tree build_constructor_va (tree, int, ...); extern tree build_real_from_int_cst (tree, const_tree); extern tree build_complex (tree, tree, tree); +extern tree build_each_one_cst (tree); extern tree build_one_cst (tree); extern tree build_minus_one_cst (tree); extern tree build_all_ones_cst (tree);