diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d30aa3adf2d..91e16cf61e1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +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. + 2017-10-11 Marc Glisse * fold-const.c (fold_binary_loc) [X +- Y CMP X]: Move ... diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c index 3867072566e..beddf108104 100644 --- a/gcc/tree-chrec.c +++ b/gcc/tree-chrec.c @@ -872,8 +872,7 @@ reset_evolution_in_loop (unsigned loop_num, 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 diff --git a/gcc/tree-chrec.h b/gcc/tree-chrec.h index 4a8a3734d79..4838bae89aa 100644 --- a/gcc/tree-chrec.h +++ b/gcc/tree-chrec.h @@ -157,8 +157,9 @@ build_polynomial_chrec (unsigned loop_num, 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. */ diff --git a/gcc/tree-core.h b/gcc/tree-core.h index b34080e2575..09be6239075 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -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; diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 4e7bb5fbdbc..9a5eab5b2e1 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -2819,8 +2819,7 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags, 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; diff --git a/gcc/tree.def b/gcc/tree.def index 9f80c4d41f5..3d2bd95d666 100644 --- a/gcc/tree.def +++ b/gcc/tree.def @@ -982,8 +982,8 @@ DEFTREECODE (SCEV_KNOWN, "scev_known", tcc_expression, 0) 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. */ diff --git a/gcc/tree.h b/gcc/tree.h index 7c2d2e7eb02..9507c3bef51 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -1241,10 +1241,9 @@ extern void protected_set_expr_location (tree, location_t); #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. */