From 5e803fbe4ef0f368b8e24a6516ff2e1f5344a3c0 Mon Sep 17 00:00:00 2001 From: spop Date: Wed, 25 Nov 2009 04:33:03 +0000 Subject: [PATCH] 2009-09-02 Sebastian Pop Partially revert the previous patch, except the following. * tree-scalar-evolution.c (instantiate_scev_not): Adapted to pass as parameters the operands of the not expression. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154542 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.graphite | 6 ++ gcc/tree-scalar-evolution.c | 168 +++++++------------------------------------- 2 files changed, 32 insertions(+), 142 deletions(-) diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index 7c2b950..8821143 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,3 +1,9 @@ +2009-09-02 Sebastian Pop + + Partially revert the previous patch, except the following. + * tree-scalar-evolution.c (instantiate_scev_not): Adapted to pass + as parameters the operands of the not expression. + 2009-09-01 Sebastian Pop * tree-scalar-evolution.c (instantiate_scev_assign): New. diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index 41e95b4..e3f33e2 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -2109,21 +2109,13 @@ loop_closed_phi_def (tree var) return NULL_TREE; } -static tree instantiate_scev_binary (basic_block, struct loop *, tree, - enum tree_code, tree, tree, tree, - bool, htab_t, int); -static tree instantiate_scev_convert (basic_block, struct loop *, tree, tree, - tree, bool, htab_t, int); -static tree instantiate_scev_not (basic_block, struct loop *, tree, - enum tree_code, tree, tree, - bool, htab_t, int); static tree instantiate_scev_r (basic_block, struct loop *, tree, bool, htab_t, int); /* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW and EVOLUTION_LOOP, that were left under a symbolic form. - STMT is a GIMPLE assignment to be instantiated. + CHREC is an SSA_NAME to be instantiated. CACHE is the cache of already instantiated values. @@ -2135,91 +2127,39 @@ static tree instantiate_scev_r (basic_block, struct loop *, tree, bool, instantiated, and to stop if it exceeds some limit. */ static tree -instantiate_scev_assign (basic_block instantiate_below, - struct loop *evolution_loop, gimple stmt, - bool fold_conversions, htab_t cache, int size_expr) +instantiate_scev_name (basic_block instantiate_below, + struct loop *evolution_loop, tree chrec, + bool fold_conversions, htab_t cache, int size_expr) { - tree type = TREE_TYPE (gimple_assign_lhs (stmt)); - tree rhs1 = gimple_assign_rhs1 (stmt); - tree rhs2 = gimple_assign_rhs2 (stmt); - enum tree_code code = gimple_assign_rhs_code (stmt); - - if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS) - { - if (is_gimple_min_invariant (rhs1)) - return chrec_convert (type, rhs1, stmt); - - if (code == SSA_NAME) - { - rhs1 = instantiate_scev_r (instantiate_below, evolution_loop, rhs1, - fold_conversions, cache, size_expr); - return chrec_convert (type, rhs1, stmt); - } - - if (code == ASSERT_EXPR) - { - rhs1 = ASSERT_EXPR_VAR (rhs1); - rhs1 = instantiate_scev_r (instantiate_below, evolution_loop, rhs1, - fold_conversions, cache, size_expr); - return chrec_convert (type, rhs1, stmt); - } - - return chrec_dont_know; - } - - switch (code) - { - case POINTER_PLUS_EXPR: - case PLUS_EXPR: - case MINUS_EXPR: - case MULT_EXPR: - return instantiate_scev_binary (instantiate_below, evolution_loop, - NULL_TREE, code, type, rhs1, rhs2, - fold_conversions, cache, size_expr); - - case NEGATE_EXPR: - case BIT_NOT_EXPR: - return instantiate_scev_not (instantiate_below, evolution_loop, - NULL_TREE, code, type, rhs1, - fold_conversions, cache, size_expr); - - CASE_CONVERT: - return instantiate_scev_convert (instantiate_below, evolution_loop, - NULL_TREE, type, rhs1, - fold_conversions, cache, size_expr); - default: - return chrec_dont_know; - } -} - -/* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW - and EVOLUTION_LOOP, that were left under a symbolic form. - - CHREC is an SSA_NAME defined by a GIMPLE PHI node. As the PHI node - belongs to the region to be instantiated, it is fully analyzed and - transformed into a chain of recurrence. + tree res; + struct loop *def_loop; + basic_block def_bb = gimple_bb (SSA_NAME_DEF_STMT (chrec)); - CACHE is the cache of already instantiated values. + /* A parameter (or loop invariant and we do not want to include + evolutions in outer loops), nothing to do. */ + if (!def_bb + || loop_depth (def_bb->loop_father) == 0 + || dominated_by_p (CDI_DOMINATORS, instantiate_below, def_bb)) + return chrec; - FOLD_CONVERSIONS should be set to true when the conversions that - may wrap in signed/pointer type are folded, as long as the value of - the chrec is preserved. + /* We cache the value of instantiated variable to avoid exponential + time complexity due to reevaluations. We also store the convenient + value in the cache in order to prevent infinite recursion -- we do + not want to instantiate the SSA_NAME if it is in a mixer + structure. This is used for avoiding the instantiation of + recursively defined functions, such as: - SIZE_EXPR is used for computing the size of the expression to be - instantiated, and to stop if it exceeds some limit. */ + | a_2 -> {0, +, 1, +, a_2}_1 */ -static tree -instantiate_scev_phi (basic_block instantiate_below, - struct loop *evolution_loop, tree chrec, - bool fold_conversions, htab_t cache, int size_expr) -{ - tree res = chrec_dont_know; - gimple def = SSA_NAME_DEF_STMT (chrec); - basic_block def_bb = gimple_bb (def); - loop_p def_loop = find_common_loop (evolution_loop, def_bb->loop_father); + res = get_instantiated_value (cache, instantiate_below, chrec); + if (res) + return res; + res = chrec_dont_know; set_instantiated_value (cache, instantiate_below, chrec, res); + def_loop = find_common_loop (evolution_loop, def_bb->loop_father); + /* If the analysis yields a parametric chrec, instantiate the result again. */ res = analyze_scalar_evolution (def_loop, chrec); @@ -2248,63 +2188,7 @@ instantiate_scev_phi (basic_block instantiate_below, /* Store the correct value to the cache. */ set_instantiated_value (cache, instantiate_below, chrec, res); return res; -} - -/* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW - and EVOLUTION_LOOP, that were left under a symbolic form. - CHREC is an SSA_NAME to be instantiated. - - CACHE is the cache of already instantiated values. - - FOLD_CONVERSIONS should be set to true when the conversions that - may wrap in signed/pointer type are folded, as long as the value of - the chrec is preserved. - - SIZE_EXPR is used for computing the size of the expression to be - instantiated, and to stop if it exceeds some limit. */ - -static tree -instantiate_scev_name (basic_block instantiate_below, - struct loop *evolution_loop, tree chrec, - bool fold_conversions, htab_t cache, int size_expr) -{ - tree res; - gimple def = SSA_NAME_DEF_STMT (chrec); - basic_block def_bb = gimple_bb (def); - - /* A parameter (or loop invariant and we do not want to include - evolutions in outer loops), nothing to do. */ - if (!def_bb - || loop_depth (def_bb->loop_father) == 0 - || dominated_by_p (CDI_DOMINATORS, instantiate_below, def_bb)) - return chrec; - - /* We cache the value of instantiated variable to avoid exponential - time complexity due to reevaluations. We also store the convenient - value in the cache in order to prevent infinite recursion -- we do - not want to instantiate the SSA_NAME if it is in a mixer - structure. This is used for avoiding the instantiation of - recursively defined functions, such as: - - | a_2 -> {0, +, 1, +, a_2}_1 */ - - res = get_instantiated_value (cache, instantiate_below, chrec); - if (res) - return res; - - /* Return the RHS */ - switch (gimple_code (def)) - { - case GIMPLE_ASSIGN: - return instantiate_scev_assign (instantiate_below, evolution_loop, def, - fold_conversions, cache, size_expr); - case GIMPLE_PHI: - return instantiate_scev_phi (instantiate_below, evolution_loop, chrec, - fold_conversions, cache, size_expr); - default: - return chrec_dont_know; - } } /* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW -- 2.7.4