Shrink POLYNOMIAL_CHREC

Message ID alpine.LSU.2.20.1710111420090.6597@zhemvz.fhfr.qr
State New
Headers show
Series
  • Shrink POLYNOMIAL_CHREC
Related show

Commit Message

Richard Biener Oct. 11, 2017, 12:21 p.m.
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  <rguenther@suse.de>

	* 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.

Patch

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.  */