27 #ifdef BUILDER_PARTIAL_REDUNDANCY_ELIMINATION
30 #include "pips_config.h"
67 static int number_of_simplified_expressions;
68 static int number_of_simplified_assign_expressions;
69 static int number_of_simplified_if_conditions;
70 static int number_of_false_while_conditions;
71 static int number_of_false_if_conditions;
72 static int number_of_true_if_conditions;
74 static void initialize_partial_redundancy_elimination_statistics(
void)
76 number_of_simplified_expressions = 0;
77 number_of_simplified_assign_expressions = 0;
78 number_of_simplified_if_conditions = 0;
79 number_of_false_while_conditions = 0;
80 number_of_false_if_conditions = 0;
81 number_of_true_if_conditions = 0;
84 static void display_partial_redundancy_elimination_statistics(
void)
86 number_of_simplified_expressions =
87 number_of_simplified_assign_expressions +
88 number_of_false_while_conditions +
89 number_of_simplified_if_conditions;
91 if (number_of_simplified_expressions > 0)
93 user_log(
"* There %s %d simplified expression%s including :*\n",
94 number_of_simplified_expressions > 1 ?
"are" :
"is",
95 number_of_simplified_expressions ,
96 number_of_simplified_expressions > 1 ?
"s" :
"");
98 if (number_of_simplified_assign_expressions > 0)
100 user_log(
"*\t %d simplified assign expression%s *\n",
101 number_of_simplified_assign_expressions ,
102 number_of_simplified_assign_expressions > 1 ?
"s" :
"");
104 if (number_of_simplified_expressions > 0)
106 user_log(
"*\t %d simplified if condition%s *\n",
107 number_of_simplified_if_conditions ,
108 number_of_simplified_if_conditions > 1 ?
"s" :
"");
110 if (number_of_false_while_conditions > 0)
112 user_log(
"*\t %d false while loop condition%s *\n",
113 number_of_false_while_conditions,
114 number_of_false_while_conditions > 1 ?
"s" :
"");
116 if (number_of_false_if_conditions > 0)
118 user_log(
"* There %s %d if statement%s with false condition *\n",
119 number_of_false_if_conditions > 1 ?
"are" :
"is",
120 number_of_false_if_conditions,
121 number_of_false_if_conditions > 1 ?
"s" :
"");
123 if (number_of_true_if_conditions > 0)
125 user_log(
"* There %s %d if statement%s with true condition *\n",
126 number_of_true_if_conditions > 1 ?
"are" :
"is",
127 number_of_true_if_conditions,
128 number_of_true_if_conditions > 1 ?
"s" :
"");
143 for (vec = v; vec != NULL; vec = vec->
succ)
169 fprintf(stderr,
" Logical expression to be simplified:");
171 fprintf(stderr,
" \n with precondition : ");
211 fprintf(stderr,
"\n Relational expression and linear normalizations: ");
216 if (all_variables_in_precondition(v,prec))
220 fprintf(stderr,
"\n All variables are in the base of the precondition: ");
404 expression retour1 = partial_redundancy_elimination_expression(e1,prec);
411 expression retour1 = partial_redundancy_elimination_expression(e1,prec);
412 expression retour2 = partial_redundancy_elimination_expression(e2,prec);
421 expression retour1= partial_redundancy_elimination_expression(e1,prec);
422 expression retour2= partial_redundancy_elimination_expression(e2,prec);
425 fprintf(stderr,
" Simplified OR expression: retour1 + retour2");
437 expression retour1 = partial_redundancy_elimination_expression(e1,prec);
438 expression retour2 = partial_redundancy_elimination_expression(e2,prec);
449 expression retour1 = partial_redundancy_elimination_expression(e1,prec);
450 expression retour2 = partial_redundancy_elimination_expression(e2,prec);
466 partial_redundancy_elimination_rwt(
statement s,
488 expression retour = partial_redundancy_elimination_expression(e,prec);
491 fprintf(stderr,
" Assign statement with logical expression:");
493 fprintf(stderr,
" \n with non empty / not true precondition : ");
503 number_of_simplified_assign_expressions++;
513 expression retour = partial_redundancy_elimination_expression(e,prec);
516 fprintf(stderr,
" Whileloop statement:");
518 fprintf(stderr,
" \n with non empty / not true precondition : ");
527 number_of_false_while_conditions++;
538 expression retour = partial_redundancy_elimination_expression(e,prec);
541 fprintf(stderr,
" Test statement:");
543 fprintf(stderr,
" Simplified expression:");
545 fprintf(stderr,
" \n with non empty / not true precondition : ");
550 number_of_simplified_if_conditions++;
564 number_of_false_if_conditions++;
598 number_of_true_if_conditions++;
706 debug_on(
"PARTIAL_REDUNDANCY_ELIMINATION_DEBUG_LEVEL");
708 debug(1,
"Partial redundancy elimination for logical expressions",
"Begin for %s\n",
module_name);
711 initialize_partial_redundancy_elimination_statistics();
713 display_partial_redundancy_elimination_statistics();
void user_log(const char *format,...)
instruction copy_instruction(instruction p)
INSTRUCTION.
persistant_statement_to_control make_persistant_statement_to_control(void)
expression copy_expression(expression p)
EXPRESSION.
statement copy_statement(statement p)
STATEMENT.
bool statement_consistent_p(statement p)
test make_test(expression a1, statement a2, statement a3)
control apply_persistant_statement_to_control(persistant_statement_to_control f, statement k)
void free_instruction(instruction p)
instruction make_instruction(enum instruction_utype tag, void *val)
bool bound_persistant_statement_to_control_p(persistant_statement_to_control f, statement k)
void extend_persistant_statement_to_control(persistant_statement_to_control f, statement k, control v)
void free_persistant_statement_to_control(persistant_statement_to_control p)
dg_vertex_label vertex_label
static statement module_statement
#define value_notzero_p(val)
#define value_negz_p(val)
#define value_zero_p(val)
#define value_posz_p(val)
static bool store_mapping(control c, bottom_up_abc_context_p context)
bool base_contains_variable_p(Pbase b, Variable v)
bool base_contains_variable_p(Pbase b, Variable v): returns true if variable v is one of b's elements...
struct _newgen_struct_statement_ * statement
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
bool vect_constant_p(Pvecteur)
bool vect_constant_p(Pvecteur v): v contains only a constant term, may be zero
const char * module_name(const char *s)
Return the module part of an entity name.
Psysteme stmt_prec(statement)
void reset_current_module_entity(void)
Reset the current module entity.
void reset_current_module_statement(void)
Reset the current module statement.
statement set_current_module_statement(statement)
Set the current module statement.
entity set_current_module_entity(entity)
static.c
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
instruction make_instruction_block(list statements)
Build an instruction block from a list of statements.
instruction make_assign_instruction(expression l, expression r)
#define ENDP(l)
Test if a list is empty.
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
#define NIL
The empty list (nil in Lisp)
#define CAR(pcons)
Get the value of the first element of a list.
#define CDR(pcons)
Get the list less its first element.
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
statement update_statement_instruction(statement, instruction)
Replace the instruction in statement s by instruction i.
void fix_sequence_statement_attributes(statement)
Since blocks are not represented in Fortran, they cannot carry a label.
void vect_fprint(FILE *f, Pvecteur v, get_variable_name_t variable_name)
void vect_fprint(FILE * f, Pvecteur v, char * (*variable_name)()): impression d'un vecteur creux v su...
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
#define pips_internal_error
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
hash_table set_ordering_to_statement(statement s)
To be used instead of initialize_ordering_to_statement() to make sure that the hash table ots is in s...
void reset_ordering_to_statement(void)
Reset the mapping from ordering to statement.
void print_expression(expression e)
no file descriptor is passed to make is easier to use in a debugging stage.
void print_statement(statement)
Print a statement on stderr.
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
#define ENTITY_NON_EQUAL_P(e)
#define ENTITY_EQUAL_P(e)
#define EQUIV_OPERATOR_NAME
#define ENTITY_LESS_THAN_P(e)
#define NORMALIZE_EXPRESSION(e)
#define NON_EQUIV_OPERATOR_NAME
#define and_expression(e1, e2)
#define binary_intrinsic_expression(name, e1, e2)
#define ENTITY_GREATER_THAN_P(e)
#define ENTITY_NON_EQUIV_P(e)
#define not_expression(e)
#define ENTITY_LESS_OR_EQUAL_P(e)
#define ENTITY_GREATER_OR_EQUAL_P(e)
#define or_expression(e1, e2)
#define ASSIGN_OPERATOR_NAME
#define ENTITY_EQUIV_P(e)
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
bool false_expression_p(expression e)
bool logical_operator_expression_p(expression e)
C xor is missing.
bool true_expression_p(expression e)
bool expression_equal_p(expression e1, expression e2)
Syntactic equality e1==e2.
bool logical_expression_p(expression e)
expression make_false_expression()
bool relational_expression_p(expression e)
expression make_true_expression()
#define normalized_linear_p(x)
#define control_predecessors(x)
#define statement_domain
newgen_sizeofexpression_domain_defined
#define control_domain
newgen_controlmap_domain_defined
#define CONTROL(x)
CONTROL.
#define EXPRESSION(x)
EXPRESSION.
#define expression_undefined
@ is_instruction_unstructured
@ is_instruction_whileloop
@ is_instruction_sequence
#define instruction_tag(x)
#define control_successors(x)
#define test_condition(x)
#define instruction_whileloop(x)
#define statement_instruction(x)
#define instruction_call(x)
#define call_arguments(x)
#define control_statement(x)
#define instruction_test(x)
#define whileloop_condition(x)
#define normalized_linear(x)
#define expression_syntax(x)
bool sc_rn_p(Psysteme sc)
bool sc_rn_p(Psysteme sc): check if the set associated to sc is the whole space, rn
void sc_rm(Psysteme ps)
void sc_rm(Psysteme ps): liberation de l'espace memoire occupe par le systeme de contraintes ps;
bool sc_empty_p(Psysteme sc)
bool sc_empty_p(Psysteme sc): check if the set associated to sc is the constant sc_empty or not.
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
bool efficient_sc_check_inequality_feasibility(Pvecteur v, Psysteme prec)
bool sc_integer_feasibility_ofl_ctrl(Psysteme sc, int ofl_ctrl, bool ofl_res)
Psysteme sc_constraint_add(Psysteme sc, Pcontrainte c, bool equality)
void sc_fprint(FILE *fp, Psysteme ps, get_variable_name_t nom_var)
void sc_fprint(FILE * f, Psysteme ps, char * (*nom_var)()): cette fonction imprime dans le fichier po...
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
Pvecteur vect_multiply(Pvecteur v, Value x)
Pvecteur vect_multiply(Pvecteur v, Value x): multiplication du vecteur v par le scalaire x,...
void reset_precondition_map(void)
void set_precondition_map(statement_mapping)
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
The structure used to build lists in NewGen.
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
#define OFL_CTRL
I do thing that overflows are managed in a very poor manner.
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
Pvecteur vect_add(Pvecteur v1, Pvecteur v2)
package vecteur - operations binaires
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2)
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2): allocation d'un vecteur v dont la valeur est la di...