From patchwork Wed Oct 11 12:21:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 824392 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-463930-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Kxi8Bnu9"; 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 3yBtPT6Cw7z9s7p for ; Wed, 11 Oct 2017 23:21:13 +1100 (AEDT) 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=h5p9Asj2fGOtQJtwqnfCATDuJPuCGPfXEtLakBvp3bD48WAQOvVih RyDBeBg5kvtRoyB92U624AwW/+t9f/23NGatUZsnypeWrqqFPCFm7KpsTBcdlx3k Vv1gUrf8mcvbo6uLObyeBBwzcuieHBmOznEv+DxWmYbVMU0BJHBLxs= 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=ugyyQlJGoci8m3wXHHXn21kp7Lw=; b=Kxi8Bnu9S/JS5aEY2YD8 N6na71fAaNcovo1gvp9q0n0bHXSSUjaPNw3CNZfYcweHS8CMtBu543aCbFTSNxEk 9tkRaemITdFN2UGHpp0v2+iAWGu9SL9usC59Ja5nCTjDd2PnhQ5waoTDPJK1rCRg hCR4dW471LJQ6cAKitl910I= Received: (qmail 100262 invoked by alias); 11 Oct 2017 12:21:05 -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 100250 invoked by uid 89); 11 Oct 2017 12:21:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=H*MI:6597 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Oct 2017 12:21:03 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 06AA1AAD0 for ; Wed, 11 Oct 2017 12:21:01 +0000 (UTC) Date: Wed, 11 Oct 2017 14:21:00 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Shrink POLYNOMIAL_CHREC Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 This moves CHREC_VARIABLE to the tree base union as it just records a loop number there's no need to allocate a tree node and tree operand for it. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2017-10-11 Richard Biener * tree.def (POLYNOMIAL_CHREC): Remove CHREC_VARIABLE tree operand. * tree-core.h (tree_base): Add chrec_var union member. * tree.h (CHREC_VAR): Remove. (CHREC_LEFT, CHREC_RIGHT, CHREC_VARIABLE): Adjust. * tree-chrec.h (build_polynomial_chrec): Adjust. * tree-chrec.c (reset_evolution_in_loop): Use build_polynomial_chrec. * tree-pretty-print.c (dump_generic_node): Use CHREC_VARIABLE. Index: gcc/tree-chrec.c =================================================================== --- gcc/tree-chrec.c (revision 253632) +++ gcc/tree-chrec.c (working copy) @@ -872,8 +872,7 @@ reset_evolution_in_loop (unsigned loop_n new_evol); tree right = reset_evolution_in_loop (loop_num, CHREC_RIGHT (chrec), new_evol); - return build3 (POLYNOMIAL_CHREC, TREE_TYPE (left), - CHREC_VAR (chrec), left, right); + return build_polynomial_chrec (CHREC_VARIABLE (chrec), left, right); } while (TREE_CODE (chrec) == POLYNOMIAL_CHREC Index: gcc/tree-chrec.h =================================================================== --- gcc/tree-chrec.h (revision 253632) +++ gcc/tree-chrec.h (working copy) @@ -157,8 +157,9 @@ build_polynomial_chrec (unsigned loop_nu if (chrec_zerop (right)) return left; - return build3 (POLYNOMIAL_CHREC, TREE_TYPE (left), - build_int_cst (NULL_TREE, loop_num), left, right); + tree chrec = build2 (POLYNOMIAL_CHREC, TREE_TYPE (left), left, right); + CHREC_VARIABLE (chrec) = loop_num; + return chrec; } /* Determines whether the expression CHREC is a constant. */ Index: gcc/tree-core.h =================================================================== --- gcc/tree-core.h (revision 253632) +++ gcc/tree-core.h (working copy) @@ -981,6 +981,9 @@ struct GTY(()) tree_base { /* SSA version number. This field is only used with SSA_NAME. */ unsigned int version; + /* CHREC_VARIABLE. This field is only used with POLYNOMIAL_CHREC. */ + unsigned int chrec_var; + /* Internal function code. */ enum internal_fn ifn; Index: gcc/tree-pretty-print.c =================================================================== --- gcc/tree-pretty-print.c (revision 253632) +++ gcc/tree-pretty-print.c (working copy) @@ -2819,8 +2819,7 @@ dump_generic_node (pretty_printer *pp, t dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false); pp_string (pp, ", +, "); dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false); - pp_string (pp, "}_"); - dump_generic_node (pp, CHREC_VAR (node), spc, flags, false); + pp_printf (pp, "}_%u", CHREC_VARIABLE (node)); is_stmt = false; break; Index: gcc/tree.def =================================================================== --- gcc/tree.def (revision 253632) +++ gcc/tree.def (working copy) @@ -982,8 +982,8 @@ DEFTREECODE (SCEV_KNOWN, "scev_known", t DEFTREECODE (SCEV_NOT_KNOWN, "scev_not_known", tcc_expression, 0) /* Polynomial chains of recurrences. - Under the form: cr = {CHREC_LEFT (cr), +, CHREC_RIGHT (cr)}. */ -DEFTREECODE (POLYNOMIAL_CHREC, "polynomial_chrec", tcc_expression, 3) + cr = {CHREC_LEFT (cr), +, CHREC_RIGHT (cr)}_CHREC_VARIABLE (cr). */ +DEFTREECODE (POLYNOMIAL_CHREC, "polynomial_chrec", tcc_expression, 2) /* Used to chain children of container statements together. Use the interface in tree-iterator.h to access this node. */ Index: gcc/tree.h =================================================================== --- gcc/tree.h (revision 253632) +++ gcc/tree.h (working copy) @@ -1241,10 +1241,9 @@ extern void protected_set_expr_location #define COND_EXPR_ELSE(NODE) (TREE_OPERAND (COND_EXPR_CHECK (NODE), 2)) /* Accessors for the chains of recurrences. */ -#define CHREC_VAR(NODE) TREE_OPERAND (POLYNOMIAL_CHREC_CHECK (NODE), 0) -#define CHREC_LEFT(NODE) TREE_OPERAND (POLYNOMIAL_CHREC_CHECK (NODE), 1) -#define CHREC_RIGHT(NODE) TREE_OPERAND (POLYNOMIAL_CHREC_CHECK (NODE), 2) -#define CHREC_VARIABLE(NODE) TREE_INT_CST_LOW (CHREC_VAR (NODE)) +#define CHREC_LEFT(NODE) TREE_OPERAND (POLYNOMIAL_CHREC_CHECK (NODE), 0) +#define CHREC_RIGHT(NODE) TREE_OPERAND (POLYNOMIAL_CHREC_CHECK (NODE), 1) +#define CHREC_VARIABLE(NODE) POLYNOMIAL_CHREC_CHECK (NODE)->base.u.chrec_var /* LABEL_EXPR accessor. This gives access to the label associated with the given label expression. */