PIPS
|
#include <stdio.h>
#include <stdlib.h>
#include "linear.h"
#include "genC.h"
#include "ri.h"
#include "effects.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "effects-util.h"
#include "text-util.h"
#include "misc.h"
#include "properties.h"
#include "resources.h"
#include "pipsdbm.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "expressions.h"
#include "eole_private.h"
Go to the source code of this file.
Data Structures | |
struct | available_scalar_t |
performs Associative-Commutative Common Subexpression Elimination on sequences. More... | |
Macros | |
#define | NO_SIMILARITY (0) |
#define | MAX_SIMILARITY (1000) |
Typedefs | |
typedef struct available_scalar_t * | available_scalar_pt |
Functions | |
static bool | Is_Associative_Commutative (entity e) |
static void | push_nesting (statement s) |
Keep track of statement nesting. More... | |
static void | pop_nesting (statement s) |
Pop the current statement from nesting list. More... | |
static int | current_level (void) |
The nesting depth of the current statement. More... | |
static bool | side_effects_p (expression e) |
There is a side effect if there is a W effect in the expression. More... | |
static bool | interference_on (entity var, list les) |
Compute if an effect list Some effect in les interfere with var. More... | |
static bool | moveable_to (list le, statement s) |
Whether sg with effects le can be moved up to s. More... | |
static int | level_of (list le) |
Return the level of this expression, using the current nesting list. More... | |
static int | expr_level_of (expression e) |
The level can be queried for a sub expression. More... | |
static statement | statement_of_level (int level) |
or for a statement. More... | |
static bool | currently_nested_p (void) |
Test if the current statement is not the top one: More... | |
static expression | right_side_of_assign_statement (statement stat) |
static bool | entity_as_arguments (entity ent, statement stat) |
Verify if entity ent is an argument in the right expression of the assign statement stat. More... | |
static expression | expr_left_side_of_assign_statement (statement stat) |
Return the expression in the left side of an assign statement. More... | |
static entity | left_side_of_assign_statement (statement stat) |
Return the entity in left side of an assign statement. More... | |
static list | insertion_statement_in_correct_position (statement news, list l) |
Insert statement s in the list of statement l. More... | |
static void | insert_before_statement (statement news, statement s, bool last) |
Just for test static void dump_list_of_statement(list l) { fprintf(stderr, "\n===== Dump List: \n"); MAP(STATEMENT, ss, { print_statement(ss); }, l); fprintf(stderr, "\n END dumpt List!!! \n"); }. More... | |
static bool | atomizable_sub_expression_p (expression e) |
Atomizable if some computation. More... | |
static gen_array_t | group_expr_by_level (int nlevels, list le) |
of list of expressions More... | |
static void | do_atomize_if_different_level (expression e, int level) |
Atomize sub expressions with. More... | |
static void | atomize_call (call c, int level) |
static void | atomize_or_associate_for_level (expression e, int level) |
static bool | icm_atom_call_flt (call c) |
Don't go into I/O calls... More... | |
static void | atomize_instruction (instruction i) |
Atomize an instruction with call. More... | |
static void | atomize_test (test t) |
static void | atomize_whileloop (whileloop w) |
static void | atomize_or_associate (expression e) |
static bool | loop_flt (loop l) |
static void | loop_rwt (loop l) |
static bool | number_of_use_greater_1 (statement s) |
PDSon: I use the field 'comments' of statement for counting its number of use. More... | |
static void | set_comment_of_statement (statement s, char *new_comment) |
Update the field 'comments' of a statement. More... | |
static statement | update_number_of_use (entity ent, list lst_stat, int up_down) |
Update the number of use of statement defining 'ent' which is a member of list lst_stat with step up_down (up_down = 1 | 0 | -1). More... | |
static void | increase_number_of_use_by_1 (entity ent, statement container) |
Increase number of use of variable ent by one. More... | |
static void | remove_statement_redundant (statement s, list *inserted) |
Remove statement redundant inserted before statement s. More... | |
static bool | cse_expression_flt (expression e, list *inserted) |
static bool | cse_call_flt (call c, __attribute__((unused)) list *inserted) |
Avoid visit the left side of assign statement. More... | |
static void | insert_rwt (statement s) |
Insert the new statements created. More... | |
static bool | prepare_icm (statement s) |
void | perform_icm_association (const char *name, statement s) |
Perform ICM and association on operators. More... | |
static void | add_ref_ent (reference r) |
static void | add_call_ent (call c) |
static list | get_all_entities (expression e) |
static bool | try_reorder_expression_call (expression e, list availables) |
static void | reorder_pointer_expression (expression e) |
make sure expressions are ordered with pointer first More... | |
static void | do_gather_all_expressions_perms (list sterns, list *perms) |
static bool | do_gather_all_expressions (expression e, list *gathered) |
static void | prune_singleton (list *l) |
static bool | expr_cse_flt (expression e, __attribute__((unused)) list *skip_list) |
whether to get in here, whether to atomize... More... | |
static bool | expression_in_list_p (expression e, list seen) |
static expression | find_equal_expression_not_in_list (expression e, list avails, list seen) |
static list | common_expressions (list args, list avails) |
of expression More... | |
static list | list_diff (list l1, list l2) |
of expression More... | |
static bool | expression_eq_in_list_p (expression e, list l, expression *f) |
Define forward. More... | |
static int | similarity (expression e, available_scalar_pt aspt) |
Find the commun sub-expression between e & aspt. More... | |
static available_scalar_pt | best_similar_expression (expression e, int *best_quality) |
static available_scalar_pt | make_available_scalar (entity scalar, statement container, expression contents) |
static bool | call_unary_minus_p (expression e) |
static void | atom_cse_expression (expression e, list *skip_list) |
Remove some inpropriate ones... More... | |
static bool | loop_stop (loop l, __attribute__((unused)) list *skip_list) |
static bool | test_stop (test t, __attribute__((unused)) list *skip_list) |
static bool | while_stop (whileloop wl, __attribute__((unused)) list *skip_list) |
static bool | cse_atom_call_flt (call c, list *skip_list) |
static list | atomize_cse_this_statement_expressions (statement s, list availables) |
side effects: use current_available and current_statement More... | |
static void | prune_non_constant (list effects, list *perms) |
void | try_reorder_expressions (void *s, bool icm) |
static bool | seq_flt (sequence s) |
top down. More... | |
static bool | call_flt (call c) |
handle all calls not in a sequence More... | |
void | perform_ac_cse (__attribute__((unused)) const char *name, statement s) |
bool | common_subexpression_elimination (const char *module_name) |
Pipsmake phase: Common Subexpression Elimination. More... | |
bool | icm (const char *module_name) |
Pipsmake phase: Invariant Code Motion. More... | |
Variables | |
static char * | table_of_AC_operators [] |
option: More... | |
static list | nesting = NIL |
assumes: More... | |
static list | current_available = NIL |
statement stack to current statement. More... | |
static statement | current_statement = statement_undefined |
static list * | w_effects |
PDSon: w_effect store all the variables modified in the sequence of statement. More... | |
static list | seen = NIL |
#define MAX_SIMILARITY (1000) |
Definition at line 1317 of file sequence_gcm_cse.c.
#define NO_SIMILARITY (0) |
Definition at line 1316 of file sequence_gcm_cse.c.
typedef struct available_scalar_t * available_scalar_pt |
|
static |
Definition at line 1094 of file sequence_gcm_cse.c.
References call_function, gen_once(), and seen.
Referenced by get_all_entities().
|
static |
Definition at line 1091 of file sequence_gcm_cse.c.
References gen_once(), reference_variable, and seen.
Referenced by get_all_entities().
|
static |
Remove some inpropriate ones...
static void clean_current_availables(void) {
}
statement head = current_statement_head();
only left and right side of the subscript are splittable
extract every possible common subexpression
some common expression found.
identical, just make a reference to the scalar, whatever the stuff stored inside.
Set the statement to status REAL
partial common expression...
of expression
just substitute lo1, don't build a new aspt.
Set the statement to status REAL
now cse is a reference to the newly created scalar.
update both expressions...
in code
don't visit it later.
updates available contents
add the new scalar as an available CSE.
nothing
PDSon: Do not atomize:
create a new atom...
At fisrt, this statement is set "virtual"
don't visit it later, just in case...
???
if there are variants in the expression it cannot be moved, and it is not available. Otherwise I should move it?
exp == e == <right expression of assignment> => Atomize this expression without using temporel variable; we use the left side variable of assignment in order to reduce the number of the variable temporel for the comprehensive of the code.
Definition at line 1616 of file sequence_gcm_cse.c.
References atomize_this_expression(), available_scalar_t::available_contents, best_similar_expression(), call_arguments, call_function, call_to_expression(), call_unary_minus_p(), CAR, CDR, common_expressions(), CONS, available_scalar_t::container, available_scalar_t::contents, copy_expression(), copy_syntax(), current_available, current_statement, available_scalar_t::depends, ENTITY, entity_to_expression(), entity_undefined_p, exp, EXPRESSION, expression_constant_p(), expression_eq_in_list_p(), expression_normalized, expression_pointer_p(), expression_scalar_p, expression_syntax, free_arguments(), gen_chunk_undefined, gen_find_eq(), gen_free_list(), gen_length(), gen_nconc(), gen_recurse_stop(), ifdebug, increase_number_of_use_by_1(), insert_before_statement(), instruction_call, instruction_call_p, Is_Associative_Commutative(), is_syntax_call, is_syntax_range, is_syntax_reference, left_side_of_assign_statement(), list_diff(), make_assign_statement(), make_available_scalar(), make_call(), make_expression(), make_new_scalar_variable(), make_reference(), make_syntax(), MAX_SIMILARITY, NIL, normalize_all_expressions_of(), normalized_undefined, available_scalar_t::operator, pips_assert, pips_debug, print_expression(), ref, reference_variable, available_scalar_t::scalar, set_comment_of_statement(), statement_instruction, strdup(), STRING, syntax_call, syntax_call_p, syntax_reference, syntax_reference_p, syntax_subscript_p, syntax_tag, and available_scalar_t::w_effects.
Referenced by atomize_cse_this_statement_expressions().
|
static |
Atomizable if some computation.
Missing cases? user functions? I/O?
Definition at line 421 of file sequence_gcm_cse.c.
References call_function, entity_constant_p, ENTITY_IMPLIEDDO_P, expression_syntax, is_syntax_call, is_syntax_range, is_syntax_reference, pips_internal_error, syntax_call, and syntax_tag.
Referenced by do_atomize_if_different_level().
of expression
Definition at line 550 of file sequence_gcm_cse.c.
References call_arguments, do_atomize_if_different_level(), EXPRESSION, FOREACH, gen_length(), and level.
Referenced by atomize_instruction(), and atomize_or_associate_for_level().
side effects: use current_available and current_statement
of available_scalar_pt
scan expressions in s; atomize/cse them; update availables;
statement_domain, current_statement_filter, current_statement_rewrite,
don't go inside these...
do the job on the found expression.
free_current_statement_stack();
Update w_effects: add the variable modified by the current statement
Update contents
Update address: w_effects always points to the end of the list of variable modified which is filled after each statement
Definition at line 1907 of file sequence_gcm_cse.c.
References assignment_statement_p(), atom_cse_expression(), call_domain, CDR, CONS, copy_expression(), cse_atom_call_flt(), current_available, current_statement, expr_cse_flt(), expr_left_side_of_assign_statement(), EXPRESSION, expression_domain, gen_context_multi_recurse(), gen_false(), gen_free_list(), gen_null(), loop_domain, loop_stop(), NIL, statement_undefined, test_domain, test_stop(), unstructured_domain, w_effects, while_stop(), and whileloop_domain.
Referenced by call_flt(), and seq_flt().
|
static |
Atomize an instruction with call.
Maybe I could consider moving the call as a whole?
Since we are at the top level statement, impossible to move something outside...
Should have been dealt by other means in the gen_multi_recurse() from gen_multi_recurse() before
stat_level_of(current_statement_head()));
Definition at line 668 of file sequence_gcm_cse.c.
References atomize_call(), current_level(), currently_nested_p(), instruction_call, and instruction_call_p.
Referenced by perform_icm_association().
|
static |
Definition at line 696 of file sequence_gcm_cse.c.
References atomize_or_associate_for_level(), and expr_level_of().
Referenced by perform_icm_association().
|
static |
of expression
Some depth, otherwise no ICM needed! should be fixed if root statement is pushed?
skip casts
Only do something with calls
something to icm
Reassociation + atomization maybe needed. code taken from JZ.
Note: the last level of an expression MUST NOT be moved! indeed, there may be a side effects in another part of the expr.
Insert expression in upward expression, eventually in e!
Fix last level if necessary.
Definition at line 566 of file sequence_gcm_cse.c.
References atomize_call(), atomize_this_expression(), call_arguments, call_function, cast_expression, CONS, current_level(), currently_nested_p(), EXPRESSION, expression_syntax, expression_to_string(), expression_undefined, gen_array_addto(), gen_array_item(), gen_length(), group_expr_by_level(), insert_before_statement(), Is_Associative_Commutative(), level, list_undefined, make_call(), make_expression(), make_new_scalar_variable(), make_syntax_call(), normalized_undefined, pips_debug, statement_of_level(), syntax_call, syntax_call_p, syntax_cast, and syntax_cast_p.
Referenced by atomize_or_associate().
|
static |
Definition at line 684 of file sequence_gcm_cse.c.
References current_level(), currently_nested_p(), do_atomize_if_different_level(), and test_condition.
Referenced by perform_icm_association().
|
static |
Definition at line 690 of file sequence_gcm_cse.c.
References current_level(), currently_nested_p(), do_atomize_if_different_level(), and whileloop_condition.
Referenced by perform_icm_association().
|
static |
Definition at line 1497 of file sequence_gcm_cse.c.
References current_available, FOREACH, MAX_SIMILARITY, similarity(), and STRING.
Referenced by atom_cse_expression().
handle all calls not in a sequence
Definition at line 2022 of file sequence_gcm_cse.c.
References atomize_cse_this_statement_expressions(), CDR, gen_cons(), gen_full_free_list(), gen_get_ancestor(), ifdebug, NIL, pips_debug, print_statement(), statement_domain, and w_effects.
Referenced by perform_ac_cse().
|
static |
Definition at line 1598 of file sequence_gcm_cse.c.
References call_function, ENTITY_UNARY_MINUS_P, expression_syntax, syntax_call, and syntax_call_p.
Referenced by atom_cse_expression().
of expression
Definition at line 1373 of file sequence_gcm_cse.c.
References CONS, EXPRESSION, find_equal_expression_not_in_list(), FOREACH, and NIL.
Referenced by atom_cse_expression(), and similarity().
bool common_subexpression_elimination | ( | const char * | module_name | ) |
Pipsmake phase: Common Subexpression Elimination.
[in] | module_name | is the name of the module we want to apply the Common Subexpression Elimination on |
module_name | odule_name |
Definition at line 2075 of file sequence_gcm_cse.c.
References get_string_property(), module_name(), optimize_expressions(), and set_string_property().
should avoid any W effect...
Update address: w_effects always points to the end of the list of variable modified which is filled after each statement
Definition at line 1879 of file sequence_gcm_cse.c.
References binary_call_lhs, call_function, CDR, CONS, copy_expression(), ENTITY_ASSIGN_P, ENTITY_IMPLIEDDO_P, EXPRESSION, expression_syntax, gen_recurse_stop(), get_bool_property(), io_intrinsic_p(), NIL, syntax_subscript_p, and w_effects.
Referenced by atomize_cse_this_statement_expressions().
|
static |
Avoid visit the left side of assign statement.
Go down!
Definition at line 931 of file sequence_gcm_cse.c.
References binary_call_lhs, call_function, ENTITY_ASSIGN_P, expression_pointer_p(), expression_scalar_p, gen_recurse_stop(), and get_bool_property().
Referenced by remove_statement_redundant().
|
static |
Go down
This statement is a real one. But it maybe contains a variable temporal -> Continue remove redundant statement from this one
Remove its comment for pretty look: It is visited! Not do again!
Go up
This statement is already visited! Not do again! Go up
s is a redundant statement. Replace e by the right side of the assign statement s
Remove s from list
Continue go down the new expression
Nothing is done! Go up
Definition at line 865 of file sequence_gcm_cse.c.
References exp, expression_syntax, FOREACH, free_statement(), gen_remove_once(), ifdebug, left_side_of_assign_statement(), number_of_use_greater_1(), pips_debug, print_expression(), print_statement(), reference_variable, remove_statement_redundant(), right_side_of_assign_statement(), set_comment_of_statement(), STATEMENT, statement_comments, string_undefined, string_undefined_p, syntax_reference, and syntax_reference_p.
Referenced by remove_statement_redundant().
|
static |
The nesting depth of the current statement.
Definition at line 145 of file sequence_gcm_cse.c.
References gen_length(), and nesting.
Referenced by atomize_instruction(), atomize_or_associate_for_level(), atomize_test(), atomize_whileloop(), currently_nested_p(), loop_rwt(), and statement_of_level().
|
static |
Test if the current statement is not the top one:
Definition at line 274 of file sequence_gcm_cse.c.
References current_level().
Referenced by atomize_instruction(), atomize_or_associate_for_level(), atomize_test(), atomize_whileloop(), and loop_rwt().
|
static |
Atomize sub expressions with.
Definition at line 530 of file sequence_gcm_cse.c.
References atomizable_sub_expression_p(), atomize_this_expression(), expr_level_of(), expression_to_string(), insert_before_statement(), level, make_new_scalar_variable(), pips_debug, side_effects_p(), and statement_of_level().
Referenced by atomize_call(), atomize_test(), atomize_whileloop(), and loop_rwt().
|
static |
Definition at line 1259 of file sequence_gcm_cse.c.
References CONS, do_gather_all_expressions_perms(), entity_to_expression(), EXPRESSION, expression_normalized, gen_nconc(), int_to_expression(), make_op_exp(), MULTIPLY_OPERATOR_NAME, NIL, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, TCST, VECTEUR_NUL_P, vecteur_succ, vecteur_val, and vecteur_var.
Referenced by try_reorder_expressions().
Definition at line 1236 of file sequence_gcm_cse.c.
References CAR, CONS, convert_to_c_operators(), copy_expression(), ENDP, exp, EXPRESSION, expression_normalized, FOREACH, gen_nconc(), NIL, NORMALIZE_EXPRESSION, normalized_linear, POP, Pvecteur_to_expression(), reorder_pointer_expression(), unnormalize_expression(), and vect_add().
Referenced by do_gather_all_expressions().
Verify if entity ent is an argument in the right expression of the assign statement stat.
Argument is maybe a call to a constant
Definition at line 305 of file sequence_gcm_cse.c.
References call_arguments, EXPRESSION, expression_syntax, FOREACH, pips_assert, reference_variable, right_side_of_assign_statement(), syntax_call, syntax_call_p, syntax_reference, and syntax_reference_p.
Referenced by insertion_statement_in_correct_position().
|
static |
whether to get in here, whether to atomize...
Definition at line 1297 of file sequence_gcm_cse.c.
References expression_call(), expression_syntax, ifdebug, IO_CALL_P, is_syntax_call, is_syntax_cast, is_syntax_reference, is_syntax_subscript, pips_debug, print_expression(), and syntax_tag.
Referenced by atomize_cse_this_statement_expressions().
|
static |
Return the expression in the left side of an assign statement.
Definition at line 332 of file sequence_gcm_cse.c.
References assignment_statement_p(), call_arguments, CAR, EXPRESSION, instruction_call, pips_internal_error, and statement_instruction.
Referenced by atomize_cse_this_statement_expressions(), and left_side_of_assign_statement().
|
static |
The level can be queried for a sub expression.
try again !
assigns...
Definition at line 225 of file sequence_gcm_cse.c.
References bound_expr_prw_effects_p(), EFFECT, effect_write_p, effects_effects, FOREACH, gen_full_free_list(), level_of(), load_expr_prw_effects(), and proper_effects_of_expression().
Referenced by atomize_or_associate(), do_atomize_if_different_level(), and group_expr_by_level().
|
static |
Define forward.
Define forward
Definition at line 1558 of file sequence_gcm_cse.c.
References EXPRESSION, expression_equal_p(), f(), and FOREACH.
Referenced by atom_cse_expression(), list_diff(), and similarity().
|
static |
Definition at line 1358 of file sequence_gcm_cse.c.
References EXPRESSION, f(), MAP, and seen.
Referenced by find_equal_expression_not_in_list().
|
static |
Definition at line 1364 of file sequence_gcm_cse.c.
References EXPRESSION, expression_equal_p(), expression_in_list_p(), f(), FOREACH, and seen.
Referenced by common_expressions().
|
static |
Definition at line 1097 of file sequence_gcm_cse.c.
References add_call_ent(), add_ref_ent(), call_domain, gen_multi_recurse(), gen_true(), NIL, reference_domain, and seen.
Referenced by make_available_scalar().
|
static |
of list of expressions
initialize chunks.
put expressions in chunks.
Fix expressions by useful levels, with some operations.
Definition at line 442 of file sequence_gcm_cse.c.
References CONS, expr_level_of(), EXPRESSION, FOREACH, gen_array_addto(), gen_array_item(), gen_array_make(), gen_length(), gen_nconc(), list_undefined, NIL, pips_assert, and side_effects_p().
Referenced by atomize_or_associate_for_level().
bool icm | ( | const char * | module_name | ) |
Pipsmake phase: Invariant Code Motion.
[in] | module_name | is the name of the module we want to apply the Invariant Code Motion on |
Beware, invariant_code_motion phase already exists too but deal with loop invariant code motion...
module_name | odule_name |
Definition at line 2101 of file sequence_gcm_cse.c.
References get_string_property(), module_name(), optimize_expressions(), and set_string_property().
Referenced by try_reorder_expressions().
Don't go into I/O calls...
Definition at line 658 of file sequence_gcm_cse.c.
References call_function, ENTITY_IMPLIEDDO_P, and io_intrinsic_p().
Referenced by perform_icm_association().
Increase number of use of variable ent by one.
Reduce by 1 number of use of variables contained by statement Updated
Definition at line 813 of file sequence_gcm_cse.c.
References assignment_statement_p(), call_arguments, entity_empty_label_p(), entity_name, exp, EXPRESSION, expression_syntax, FOREACH, instruction_sequence, instruction_sequence_p, left_side_of_assign_statement(), pips_assert, pips_internal_error, reference_variable, right_side_of_assign_statement(), sequence_statements, statement_instruction, statement_label, syntax_call, syntax_call_p, syntax_reference, syntax_reference_p, and update_number_of_use().
Referenced by atom_cse_expression().
Just for test static void dump_list_of_statement(list l) { fprintf(stderr, "\n===== Dump List: \n"); MAP(STATEMENT, ss, { print_statement(ss); }, l); fprintf(stderr, "\n END dumpt List!!! \n"); }.
Statements are stored in reverse order... this will have to be fixed latter on. see #1#.
Definition at line 383 of file sequence_gcm_cse.c.
References cleanup_subscripts(), CONS, entity_empty_label_p(), insertion_statement_in_correct_position(), instruction_block, make_block_statement(), NIL, pips_assert, STATEMENT, statement_block_p, statement_instruction, and statement_label.
Referenced by atom_cse_expression(), atomize_or_associate_for_level(), and do_atomize_if_different_level().
|
static |
Insert the new statements created.
Reverse list of inserted statements (#1#)
Remove statements redundant
need some patching
Definition at line 957 of file sequence_gcm_cse.c.
References clone(), CONS, copy_instruction(), empty_extensions(), entity_empty_label(), entity_empty_label_p(), free_extensions(), gen_nreverse(), instruction_sequence, instruction_sequence_p, instruction_to_statement(), pips_assert, remove_statement_redundant(), sequence_statements, STATEMENT, statement_extensions, statement_instruction, statement_label, and update_statement_instruction().
Referenced by perform_ac_cse(), and perform_icm_association().
Insert statement s in the list of statement l.
Definition at line 358 of file sequence_gcm_cse.c.
References CAR, CDR, CONS, ENDP, entity_as_arguments(), entity_undefined_p, left_side_of_assign_statement(), and STATEMENT.
Referenced by insert_before_statement().
Compute if an effect list Some effect in les interfere with var.
[in] | var | is the variable to test interference with the effects |
[in] | les | is the effect list to look for var |
There is an interference only if there is a write effect:
If an effect can write anywhere, it may be also on var:
If we may have a write effect on var, mark a conflict:
les | of effect |
Definition at line 174 of file sequence_gcm_cse.c.
References EFFECT, effect_any_reference, effect_entity(), effect_write_p, entities_may_conflict_p(), entity_all_locations_p(), FOREACH, and reference_variable.
Referenced by moveable_to().
Definition at line 81 of file sequence_gcm_cse.c.
References entity_local_name(), local_name(), pips_debug, same_string_p, and table_of_AC_operators.
Referenced by atom_cse_expression(), atomize_or_associate_for_level(), make_available_scalar(), and similarity().
Return the entity in left side of an assign statement.
Definition at line 347 of file sequence_gcm_cse.c.
References entity_undefined, expr_left_side_of_assign_statement(), expression_syntax, reference_variable, syntax_reference, and syntax_reference_p.
Referenced by atom_cse_expression(), cse_expression_flt(), increase_number_of_use_by_1(), insertion_statement_in_correct_position(), and update_number_of_use().
Return the level of this expression, using the current nesting list.
0: before any statement! n: outside nth loop. and so on.
of statement
le | of effects |
Definition at line 208 of file sequence_gcm_cse.c.
References FOREACH, gen_copy_seq(), gen_free_list(), gen_nreverse(), level, moveable_to(), nesting, and STATEMENT.
Referenced by expr_level_of().
of expression
returns an allocated l1-l2 with expression_equal_p l2 included in l1.
of expression
Definition at line 1576 of file sequence_gcm_cse.c.
References CONS, EXPRESSION, expression_eq_in_list_p(), FOREACH, gen_copy_seq(), gen_free_list(), gen_remove(), and NIL.
Referenced by atom_cse_expression(), and similarity().
RK: Why ?
Definition at line 701 of file sequence_gcm_cse.c.
References instruction_loop, pips_assert, push_nesting(), and statement_instruction.
Referenced by perform_icm_association().
|
static |
RK: Why ?
Deal with loop bound expressions
Nothing to do if we are in the top-level statement
Atomize the loop bound expressions:
Definition at line 711 of file sequence_gcm_cse.c.
References current_level(), currently_nested_p(), do_atomize_if_different_level(), level, loop_range, pop_nesting(), range_increment, range_lower, and range_upper.
Referenced by perform_icm_association().
|
static |
Definition at line 1859 of file sequence_gcm_cse.c.
References gen_recurse_stop(), and loop_body.
Referenced by atomize_cse_this_statement_expressions().
|
static |
Definition at line 1521 of file sequence_gcm_cse.c.
References available_scalar_t::available_contents, call_arguments, call_function, available_scalar_t::container, available_scalar_t::contents, available_scalar_t::depends, entity_user_name(), expression_syntax, expression_to_string(), gen_copy_seq(), get_all_entities(), Is_Associative_Commutative(), malloc(), NIL, available_scalar_t::operator, pips_debug, available_scalar_t::scalar, syntax_call, syntax_call_p, w_effects, and available_scalar_t::w_effects.
Referenced by atom_cse_expression().
Whether sg with effects le can be moved up to s.
le | of effects |
Definition at line 194 of file sequence_gcm_cse.c.
References EFFECT, effect_any_reference, FOREACH, interference_on(), load_cumulated_rw_effects_list(), and reference_variable.
Referenced by level_of().
PDSon: I use the field 'comments' of statement for counting its number of use.
Raison: The field 'comments' of new statement added is always empty! This function verifies if number of use is greater than 1 or not.
Definition at line 736 of file sequence_gcm_cse.c.
References comment(), empty_comments_p(), and statement_comments.
Referenced by cse_expression_flt().
void perform_ac_cse | ( | __attribute__((unused)) const char * | name, |
statement | s | ||
) |
they have to be recomputed, because if ICM before.
set full (expr and statements) PROPER EFFECTS well, they are computed twice here... looks rather temporary.
make_current_statement_stack();
insert moved code in statement.
Remove the "inserted" mapping:
Definition at line 2034 of file sequence_gcm_cse.c.
References call_domain, call_flt(), cleanup_subscripts(), gen_multi_recurse(), gen_null(), gen_true(), insert_rwt(), seq_flt(), sequence_domain, and statement_domain.
void perform_icm_association | ( | const char * | name, |
statement | s | ||
) |
Perform ICM and association on operators.
This is kind of an atomization. many side effects: modifies the code, uses simple effects
[in] | name | specified the module name to work on |
[in,out] | s | is the statement of the module |
GET CUMULATED EFFECTS
SG: reorder expression so that the icm algorithm matches more cases
Set full (expr and statements) PROPER EFFECTS
Initialize the "inserted" mapping:
Create the stack to track current statement:
ATOMIZE and REASSOCIATE by level.
On each statement, we push the statement top-down on the current_statement stack, and when climbing bottom-up, we pull back the statement and verify it was the same on the stack. Nowadays we could use statement parent information directly from NewGen...
Atomize instructions with calls during bottom-up phase:
could also push while loops...
do not atomize index computations at the time...
skip IO calls
Insert moved code in statement at the right place:
Delete the stack used to track current statement:
no memory leaks?
some clean up
This only works in Fortran because of C local declarations. It's easier to let restructure_control() or flatten_code take care of it.
name | ame |
s | of the module of the module |
Definition at line 1002 of file sequence_gcm_cse.c.
References atomize_instruction(), atomize_or_associate(), atomize_test(), atomize_whileloop(), call_domain, close_expr_prw_effects(), close_proper_rw_effects(), db_get_memory_resource(), expression_domain, full_simple_proper_effects(), gen_multi_recurse(), gen_null(), gen_recurse, gen_true(), icm_atom_call_flt(), insert_rwt(), instruction_domain, loop_domain, loop_flt(), loop_rwt(), nesting, NIL, pips_assert, pop_nesting(), prepare_icm(), push_nesting(), reset_cumulated_rw_effects(), set_cumulated_rw_effects(), stack_undefined, statement_domain, test_domain, and whileloop_domain.
Referenced by optimize_expressions().
|
static |
Pop the current statement from nesting list.
Definition at line 135 of file sequence_gcm_cse.c.
References CAR, CDR, gen_free_list(), nesting, NIL, pips_assert, and STATEMENT.
Referenced by loop_rwt(), and perform_icm_association().
Definition at line 987 of file sequence_gcm_cse.c.
References statement_loop_p(), and try_reorder_expressions().
Referenced by perform_icm_association().
Definition at line 1957 of file sequence_gcm_cse.c.
References CONS, effects_write_variable_p(), exp, EXPRESSION, FOREACH, gen_free_list(), get_referenced_entities(), NIL, out, SET_FOREACH, and set_free().
Referenced by try_reorder_expressions().
|
static |
Definition at line 1282 of file sequence_gcm_cse.c.
References CONS, copy_expression(), EXPRESSION, FOREACH, gen_full_free_list(), NIL, and same_expression_p().
Referenced by try_reorder_expressions().
|
static |
Keep track of statement nesting.
Definition at line 129 of file sequence_gcm_cse.c.
References CONS, nesting, and STATEMENT.
Referenced by loop_flt(), and perform_icm_association().
Remove statement redundant inserted before statement s.
Definition at line 946 of file sequence_gcm_cse.c.
References call_domain, cse_call_flt(), cse_expression_flt(), expression_domain, gen_context_multi_recurse(), and gen_null().
Referenced by cse_expression_flt(), and insert_rwt().
|
static |
make sure expressions are ordered with pointer first
Definition at line 1218 of file sequence_gcm_cse.c.
References basic_of_expression(), basic_pointer_p, binary_call_lhs, binary_call_rhs, call_arguments, commutative_call_p(), EXPRESSION, expression_call(), expression_call_p(), FOREACH, gen_free_list(), and make_expression_list.
Referenced by do_gather_all_expressions_perms().
|
static |
Definition at line 283 of file sequence_gcm_cse.c.
References call_arguments, call_function, CAR, CDR, ENTITY_ASSIGN_P, EXPRESSION, instruction_call, instruction_call_p, pips_assert, and statement_instruction.
Referenced by cse_expression_flt(), entity_as_arguments(), and increase_number_of_use_by_1().
top down.
At first, w_effects is empty list BUT not list points to NIL!!!
SG: not valid due to newgen check w_effects = &CDR(CONS(EXPRESSION, NIL, NIL));
top_of_w_effects points to the top of list, It is used to free memory later
SG we try to perform some reordering of linear expression to ease matching. To do so we (optimistically) gather similar expressions, and when pairs are found, they are kept for further matching. The pair gathering is store unaware, but the later process takes care of this. At worse we did some useless reordering.
Free top_of_w_effects and availables
Definition at line 1987 of file sequence_gcm_cse.c.
References atomize_cse_this_statement_expressions(), CDR, FOREACH, gen_cons(), gen_full_free_list(), ifdebug, NIL, pips_debug, print_statement(), sequence_statements, STATEMENT, try_reorder_expressions(), and w_effects.
Referenced by perform_ac_cse().
|
static |
Update the field 'comments' of a statement.
Definition at line 752 of file sequence_gcm_cse.c.
References empty_comments_p(), free(), and statement_comments.
Referenced by atom_cse_expression(), cse_expression_flt(), and update_number_of_use().
|
static |
There is a side effect if there is a W effect in the expression.
of effect
Definition at line 152 of file sequence_gcm_cse.c.
References EFFECT, effect_write_p, effects_effects, expression_to_string(), FOREACH, load_expr_prw_effects(), and pips_debug.
Referenced by do_atomize_if_different_level(), and group_expr_by_level().
|
static |
Find the commun sub-expression between e & aspt.
Attention: Commun expression does't contain any expression in w_effects
same function...
similarity is the number of args in common. inversion is not tested at the time.
any call: must be equal
A variable is already modified !
Definition at line 1427 of file sequence_gcm_cse.c.
References available_scalar_t::available_contents, call_arguments, call_function, CAR, CDR, common_expressions(), available_scalar_t::contents, EXPRESSION, expression_eq_in_list_p(), expression_equal_p(), expression_syntax, gen_free_list(), gen_length(), Is_Associative_Commutative(), list_diff(), MAX_SIMILARITY, NO_SIMILARITY, pips_assert, reference_equal_p(), syntax_call, syntax_call_p, syntax_reference, syntax_reference_p, syntax_tag, and available_scalar_t::w_effects.
Referenced by best_similar_expression().
or for a statement.
Returns the statement of the specified level should returns current_statement_head() to avoid ICM directly.
Definition at line 261 of file sequence_gcm_cse.c.
References current_level(), gen_nth(), level, nesting, and STATEMENT.
Referenced by atomize_or_associate_for_level(), and do_atomize_if_different_level().
|
static |
Definition at line 1865 of file sequence_gcm_cse.c.
References gen_recurse_stop(), test_false, and test_true.
Referenced by atomize_cse_this_statement_expressions().
|
static |
update normalized field, and make sure it is consistent
the idea is to split an expression into two linear parts, one that is already available and one that is not
Definition at line 1171 of file sequence_gcm_cse.c.
References copy_expression(), entity_intrinsic(), EXPRESSION, expression_normalized, expression_undefined, expression_undefined_p, FOREACH, make_call(), make_expression_list, make_op_exp(), make_syntax_call(), MINUS_OPERATOR_NAME, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, PLUS_C_OPERATOR_NAME, same_expression_p(), unnormalize_expression(), update_expression_syntax(), vect_rm(), vect_size(), and vect_substract().
Referenced by try_reorder_expressions().
void try_reorder_expressions | ( | void * | s, |
bool | icm | ||
) |
icm | cm |
Definition at line 1975 of file sequence_gcm_cse.c.
References do_gather_all_expressions(), expression_domain, gen_context_recurse, gen_full_free_list(), gen_null2(), icm(), load_cumulated_rw_effects_list(), NIL, prune_non_constant(), prune_singleton(), and try_reorder_expression_call().
Referenced by prepare_icm(), and seq_flt().
Update the number of use of statement defining 'ent' which is a member of list lst_stat with step up_down (up_down = 1 | 0 | -1).
If ent is a variable of original code (ex: x, y), not new variable added (ex: F_0, F_1,..), there is not any statement in lst_stat defining ent. Return: statement updated
First time, no value
Update old value
Definition at line 771 of file sequence_gcm_cse.c.
References comment(), empty_comments_p(), entity_name, FOREACH, int2a(), left_side_of_assign_statement(), pips_internal_error, set_comment_of_statement(), STATEMENT, statement_comments, and strdup().
Referenced by increase_number_of_use_by_1().
|
static |
Definition at line 1872 of file sequence_gcm_cse.c.
References gen_recurse_stop(), and whileloop_body.
Referenced by atomize_cse_this_statement_expressions().
statement stack to current statement.
statements to be inserted as a sequence. For CSE
Definition at line 119 of file sequence_gcm_cse.c.
Referenced by atom_cse_expression(), atomize_cse_this_statement_expressions(), and best_similar_expression().
|
static |
Definition at line 120 of file sequence_gcm_cse.c.
Referenced by atom_cse_expression(), atomize_cse_this_statement_expressions(), and make_fsm_transitions_statement().
assumes:
Definition at line 108 of file sequence_gcm_cse.c.
Referenced by adg_path_possible_source(), current_level(), level_of(), perform_icm_association(), pop_nesting(), push_nesting(), and statement_of_level().
Definition at line 1089 of file sequence_gcm_cse.c.
Referenced by add_call_ent(), add_ref_ent(), expression_in_list_p(), find_equal_expression_not_in_list(), and get_all_entities().
|
static |
option:
Definition at line 68 of file sequence_gcm_cse.c.
Referenced by Is_Associative_Commutative().
|
static |
PDSon: w_effect store all the variables modified in the sequence of statement.
Definition at line 125 of file sequence_gcm_cse.c.
Referenced by atomize_cse_this_statement_expressions(), call_flt(), cse_atom_call_flt(), make_available_scalar(), seq_flt(), and two_addresses_code_generator().