PIPS
sc.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include "linear_assert.h"
#include "arithmetique.h"
#include "boolean.h"
#include "vecteur.h"
#include "contrainte.h"
#include "sc.h"
+ Include dependency graph for sc.c:

Go to the source code of this file.

Functions

void norm_syst (Psysteme sc)
 norm_syst(Psysteme): division des contraintes, egalites ou inegalites, par le PGCD des coefficients de chaque contrainte; More...
 
Psysteme sc_make (Pcontrainte leg, Pcontrainte lineg)
 Psysteme sc_make(Pcontrainte leg, Pcontrainte lineg): allocation et initialisation d'un systeme d'equations et inequations lineaires a partir de deux listes de contraintes, une liste d'egalites et une liste d'inegalites. More...
 
Psysteme sc_translate (Psysteme s, Pbase b, char *(*variable_name)())
 Psysteme sc_translate(Psysteme s, Pbase b, char * (*variable_name)()): reecriture du systeme s dans la base b basee sur les noms des vecteurs de base; tous les vecteurs de base utilises dans s doivent avoir un vecteur de base de meme nom dans b. More...
 
Psysteme sc_substitute_dimension (Psysteme s, Variable i, Pvecteur v)
 Psysteme sc_substitute_dimension(Psysteme s, Variable i, Pvecteur v): The ith dimension of all constraints c is updated: More...
 
Psysteme sc_variable_rename (Psysteme s, Variable v_old, Variable v_new)
 Psysteme sc_variable_rename(Psysteme s, Variable v_old, Variable v_new): reecriture du systeme s remplacant toutes les occurences de la coordonnees v_old par des occurences de v_new. More...
 
Psysteme sc_rename_variables (Psysteme s, bool(*renamed_p)(), Variable(*new_variable)())
 Psysteme sc_rename_variables(s, renamed_p, new_variable) Psysteme s; bool (*renamed_p)(Variable); Variable (*new_variable)(Variable);. More...
 
Psysteme sc_variables_rename (Psysteme s, Pvecteur pv_old, Pvecteur pv_new, get_variable_name_t variable_name)
 Psysteme sc_variables_rename(Psysteme s, Pvecteur pv_old, Pvecteur pv_new): reecriture du systeme s remplacant toutes les occurences des coordonnees de pv_old par des occurences de pv_new. More...
 
void sc_base_remove_variable (Psysteme sc, Variable v)
 
void sc_base_add_variable (Psysteme sc, Variable var)
 
bool sc_consistent_p (Psysteme sc)
 bool sc_consistent_p(Psysteme sc): check that sc is well defined, that the numbers of equalities and inequalities are consistent with the lists of equalities and inequalities, and that every variable in the constraints is in the base More...
 
bool sc_weak_consistent_p (Psysteme sc)
 check that sc is well defined, that the numbers of equalities and inequalities are consistent with the lists of equalities and inequalities, that the dimension is consistent with the basis, that the basis itself is consistent (all coefficients must be 1), and that every variable in the constraints is in the basis. More...
 
void sc_separate_on_vars (Psysteme s, Pbase b, Psysteme *pwith, Psysteme *pwithout)
 

Function Documentation

◆ norm_syst()

void norm_syst ( Psysteme  sc)

norm_syst(Psysteme): division des contraintes, egalites ou inegalites, par le PGCD des coefficients de chaque contrainte;

la faisabilite ou la non-faisabilite n'est pas testee: le terme constant ne devrait pas etre pris en compte dans norm_eq().

Definition at line 53 of file sc.c.

55 {
57 
58  for (eq=sc->egalites;eq!=NULL;eq=eq->succ)
59  norm_eq(eq);
60  for (eq=sc->inegalites;eq!=NULL;eq=eq->succ)
61  norm_eq(eq);
62 }
void norm_eq(Pcontrainte)
unaires.c
Definition: unaires.c:44
Pcontrainte eq
element du vecteur colonne du systeme donne par l'analyse
Definition: sc_gram.c:108
struct Scontrainte * succ
Pcontrainte inegalites
Definition: sc-local.h:71
Pcontrainte egalites
Definition: sc-local.h:70

References eq, norm_eq(), and Scontrainte::succ.

+ Here is the call graph for this function:

◆ sc_base_add_variable()

void sc_base_add_variable ( Psysteme  sc,
Variable  var 
)

Definition at line 248 of file sc.c.

251 {
252 
253  Pbase b1 = sc->base;
254 
255  if (!VECTEUR_NUL_P(b1)) {
256  for(; !VECTEUR_NUL_P(b1) && !variable_equal(vecteur_var(b1), var);
257  b1 = b1->succ);
258  if (VECTEUR_NUL_P(b1)) {
259  for (b1 = sc->base; !VECTEUR_NUL_P(b1->succ); b1=b1->succ);
260  b1->succ = vect_new(var, VALUE_ONE);
261  sc_dimension(sc)++;
262  }
263  }
264  else {
265  sc->base = vect_new(var, VALUE_ONE);
266  sc_dimension(sc)++; }
267 }
#define VALUE_ONE
bool variable_equal(Variable v1, Variable v2)
package vecteur - routines sur les variables
Definition: variable.c:62
Value b1
booleen indiquant quel membre est en cours d'analyse
Definition: sc_gram.c:105
Pbase base
Definition: sc-local.h:75
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
#define vecteur_var(v)
#define VECTEUR_NUL_P(v)
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
Definition: alloc.c:110

References b1, VALUE_ONE, variable_equal(), vect_new(), VECTEUR_NUL_P, and vecteur_var.

Referenced by add_value_to_transformer_space(), fortran_user_call_to_transformer(), and sc_restricted_to_variables_transitive_closure().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_base_remove_variable()

void sc_base_remove_variable ( Psysteme  sc,
Variable  v 
)

Definition at line 239 of file sc.c.

242 {
243  sc_base(sc) = base_remove_variable(sc_base(sc),v);
244  sc_dimension(sc) --;
245 }
Pbase base_remove_variable(Pbase b, Variable v)
Pbase base_remove_variable(b, v): remove basis vector relative to v from b; abort if v is not in b;.
Definition: base.c:122

References base_remove_variable().

Referenced by cell_reference_sc_exact_projection_along_variable(), loop_regions_normalize(), new_system_with_only_live_variable(), parametric_transformer_empty_p(), region_exact_projection_along_variable(), region_sc_projection_along_variables_ofl_ctrl(), region_sc_projection_ofl_along_parameters(), sc_projection_optim_along_vecteur_ofl(), transformer_combine(), transformer_filter(), and transformer_projection_with_redundancy_elimination_and_check().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_consistent_p()

bool sc_consistent_p ( Psysteme  sc)

bool sc_consistent_p(Psysteme sc): check that sc is well defined, that the numbers of equalities and inequalities are consistent with the lists of equalities and inequalities, and that every variable in the constraints is in the base

Francois Irigoin, 7 July 1993

Note:

  • it also checks that every variable in the basis is used with a non-zero coefficient in at least one constraint (although there is no reason for that)
  • there is no explicit check of TCST in the basis; TCST should not be in the basis

This assert is too bad ! I remove it.

Alexis Platonoff, 31 january 1995

assert(consistent);

Definition at line 282 of file sc.c.

283 {
284  bool consistent;
285  bool flawed = false;
286 
287  consistent = !SC_UNDEFINED_P(sc);
288 
289  if(consistent) {
290  if(sc->nb_eq != safe_nb_elems_list(sc_egalites(sc), sc->nb_eq)) {
291  fprintf(stderr, "Inconsistent number of equalities\n");
292  flawed = true;
293  }
294  if(sc->nb_ineq != safe_nb_elems_list(sc_inegalites(sc), sc->nb_ineq)) {
295  fprintf(stderr, "Inconsistent number of inequalities\n");
296  flawed = true;
297  }
298  if(sc_dimension(sc) != base_dimension(sc_base(sc))) {
299  fprintf(stderr, "Inconsistent dimension\n");
300  flawed = true;
301  }
302  if(!base_normalized_p(sc_base(sc))) {
303  fprintf(stderr, "Inconsistent base\n");
304  flawed = true;
305  }
306  }
307  consistent = consistent && !flawed;
308 
309  if(consistent) {
311  Pbase diagonale = BASE_UNDEFINED;
313  Pbase diff = BASE_UNDEFINED;
314 
315  for(eq = sc->egalites; eq!= NULL; eq=eq->succ) {
316  for (pv = eq->vecteur;pv!= NULL;pv=pv->succ)
317  if (pv->var != TCST)
318  vect_chg_coeff(&diagonale,pv->var, VALUE_ONE);
319  }
320  for(eq = sc->inegalites; eq!= NULL; eq=eq->succ) {
321  for (pv = eq->vecteur;pv!= NULL;pv=pv->succ)
322  if (pv->var != TCST)
323  vect_chg_coeff(&diagonale,pv->var, VALUE_ONE);
324  }
325  diff = base_difference(diagonale, sc_base(sc));
326  consistent = BASE_NULLE_P(diff);
327  if(!consistent) {
328  fprintf(stderr, "The base does not cover all the constraints\n");
329  fprintf(stderr, "Current base\n");
330  vect_dump(sc_base(sc));
331  fprintf(stderr, "Necessary base\n");
332  vect_dump(diagonale);
333  fprintf(stderr, "Base difference\n");
334  vect_dump(diff);
335  }
336  }
337 
338  /* This assert is too bad ! I remove it.
339  *
340  * Alexis Platonoff, 31 january 1995 */
341  /* assert(consistent); */
342 
343  return consistent;
344 }
Pbase base_difference(Pbase b1, Pbase b2)
Pbase base_difference(Pbase b1, Pbase b2): allocate b; b = b1 - b2 – with the set meaning return b;.
Definition: base.c:621
bool base_normalized_p(Pbase b)
Definition: base.c:604
#define CONTRAINTE_UNDEFINED
int safe_nb_elems_list(Pcontrainte, int)
Compute the number of elements in the list if it is less than n.
Definition: listes.c:162
void vect_dump(Pvecteur v)
void vect_dump(Pvecteur v): print sparse vector v on stderr.
Definition: io.c:304
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
Pvecteur vecteur
int nb_ineq
Definition: sc-local.h:73
int nb_eq
Definition: sc-local.h:72
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define VECTEUR_UNDEFINED
#define BASE_UNDEFINED
#define base_dimension(b)
#define BASE_NULLE_P(b)
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val)
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val): mise de la coordonnee var du vecteur *pp...
Definition: unaires.c:143

References base_difference(), base_dimension, base_normalized_p(), BASE_NULLE_P, BASE_UNDEFINED, CONTRAINTE_UNDEFINED, Ssysteme::egalites, eq, fprintf(), Ssysteme::inegalites, Ssysteme::nb_eq, Ssysteme::nb_ineq, safe_nb_elems_list(), Scontrainte::succ, Svecteur::succ, TCST, VALUE_ONE, Svecteur::var, vect_chg_coeff(), vect_dump(), Scontrainte::vecteur, and VECTEUR_UNDEFINED.

Referenced by add_bounding_box_constraints(), build_third_comb(), gcd_and_constant_dependence_test(), prepare_reindexing(), sc_bounded_normalization(), sc_proj_optim_on_di_ofl(), sc_projection_optim_along_vecteur_ofl(), simplify_float_constraint_system(), and TestDependence().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_make()

Psysteme sc_make ( Pcontrainte  leg,
Pcontrainte  lineg 
)

Psysteme sc_make(Pcontrainte leg, Pcontrainte lineg): allocation et initialisation d'un systeme d'equations et inequations lineaires a partir de deux listes de contraintes, une liste d'egalites et une liste d'inegalites.

ATTENTION: les deux listes leg et lineq ne sont pas dupliquees; un appel a cette fonction peut donc creer du sharing entre structures de donnees

Ancien nom: mk_syst()

Modifications:

  • ajout de l'initialisation de base et de dimension par un appel a sc_creer_base()

Definition at line 78 of file sc.c.

81 {
82  Psysteme s;
83 
84  s = (Psysteme ) MALLOC(sizeof(Ssysteme),SYSTEME,"sc_make");
85  s->egalites = leg;
86  s->inegalites = lineg;
87  s->nb_eq = nb_elems_list(leg);
88  s->nb_ineq = nb_elems_list(lineg);
90  sc_creer_base(s);
91  return(s);
92 }
int nb_elems_list(Pcontrainte)
int nb_elems_list(Pcontrainte list): nombre de contraintes se trouvant dans une liste de contraintes
Definition: listes.c:129
#define MALLOC(s, t, f)
package matrice
Definition: smith.c:42
struct Ssysteme * Psysteme
#define SYSTEME
package sc sur les Systemes de Contraintes lineaires.
Definition: sc-local.h:47
void sc_creer_base(Psysteme ps)
void sc_creer_base(Psysteme ps): initialisation des parametres dimension et base d'un systeme lineair...
Definition: sc_alloc.c:129

References Ssysteme::base, Ssysteme::egalites, Ssysteme::inegalites, MALLOC, nb_elems_list(), Ssysteme::nb_eq, Ssysteme::nb_ineq, sc_creer_base(), SYSTEME, and VECTEUR_UNDEFINED.

Referenced by adg_dataflowgraph(), adg_dataflowgraph_with_extremities(), adg_max_of_leaves(), adg_suppress_2nd_in_1st_ps(), affine_to_transformer(), algorithm_row_echelon_generic(), broadcast_conditions(), build_third_comb(), check_range_wrt_precondition(), constraint_to_bound(), constraints_to_loop_bound(), dj_simple_inegs_to_eg(), dj_system_complement(), expression_and_precondition_to_integer_interval(), extract_common_syst(), extract_nredund_subsystem(), fortran_user_function_call_to_transformer(), generic_equality_to_transformer(), generic_minmax_to_transformer(), get_other_constraints(), include_trans_on_LC_in_ref(), include_trans_on_LC_in_sc(), include_trans_on_LC_in_sc2(), integer_divide_to_transformer(), integer_expression_and_precondition_to_integer_interval(), integer_power_to_transformer(), integer_right_shift_to_transformer(), integer_value_and_precondition_to_integer_interval(), logical_binary_function_to_transformer(), logical_constant_to_transformer(), make_primal(), pa_path_to_few_disjunct_ofl_ctrl(), partial_broadcast_coefficients(), prepare_reindexing(), relation_to_transformer(), sc_empty(), sc_gen_write(), sc_separate_on_vars(), sc_strong_normalize2(), sc_strong_normalize_and_check_feasibility(), sc_strong_normalize_and_check_feasibility2(), sc_supress_parallel_redund_constraints(), sc_supress_same_constraints(), simple_addition_to_transformer(), simple_affine_to_transformer(), suppress_sc_in_sc(), system_inversion_restrict(), transformer_add_loop_index_initialization(), transformer_identity(), and transitive_closure_system().

+ Here is the call graph for this function:

◆ sc_rename_variables()

Psysteme sc_rename_variables ( Psysteme  s,
bool (*)()  renamed_p,
Variable (*)()  new_variable 
)

Psysteme sc_rename_variables(s, renamed_p, new_variable) Psysteme s; bool (*renamed_p)(Variable); Variable (*new_variable)(Variable);.

what: driven renaming of variables in s. how: scans, decides and replaces. input: Psysteme s, plus the decision and replacement functions output: s is returned. side effects:

  • the system is modified in place. bugs or features:
  • was written by FC...
Parameters
renamed_pwhat: driven renaming of variables in s. how: scans, decides and replaces. input: Psysteme s, plus the decision and replacement functions output: s is returned. side effects:
  • the system is modified in place. bugs or features:
  • was written by FC... ariable
new_variablewhat: driven renaming of variables in s. how: scans, decides and replaces. input: Psysteme s, plus the decision and replacement functions output: s is returned. side effects:
  • the system is modified in place. bugs or features:
  • was written by FC... ariable

Definition at line 198 of file sc.c.

202 {
203  Pcontrainte c;
204 
205  if(SC_UNDEFINED_P(s)) return(s);
206 
207  for(c=sc_egalites(s); c!=NULL; c=c->succ)
209  renamed_p, new_variable);
210 
211  for(c=sc_inegalites(s); c!=NULL; c=c->succ)
213  renamed_p, new_variable);
214 
215  (void) vect_rename_variables(sc_base(s), renamed_p, new_variable);
216 
217  return(s);
218 }
Pvecteur vect_rename_variables(Pvecteur v, bool(*renamed_p)(Variable), Variable(*new_variable)(Variable))
Pvecteur vect_rename_variables(v, renamed_p, new_variable) Pvecteur v; bool (*renamed_p)(Variable); V...
Definition: base.c:281
#define contrainte_vecteur(c)
passage au champ vecteur d'une contrainte "a la Newgen"
static entity new_variable
entity to be replaced, the primary?
Definition: dynamic.c:860

References contrainte_vecteur, new_variable, Scontrainte::succ, and vect_rename_variables().

Referenced by shift_system_to_prime_variables().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_separate_on_vars()

void sc_separate_on_vars ( Psysteme  s,
Pbase  b,
Psysteme pwith,
Psysteme pwithout 
)

Definition at line 418 of file sc.c.

423 {
424  Pcontrainte i_with, e_with, i_without, e_without;
425 
426  Pcontrainte_separate_on_vars(sc_inegalites(s), b, &i_with, &i_without);
427  Pcontrainte_separate_on_vars(sc_egalites(s), b, &e_with, &e_without);
428 
429  *pwith = sc_make(e_with, i_with),
430  *pwithout = sc_make(e_without, i_without);
431 }
void Pcontrainte_separate_on_vars(Pcontrainte, Pbase, Pcontrainte *, Pcontrainte *)
void Pcontrainte_separate_on_vars(initial, vars, pwith, pwithout) Pcontrainte initial; Pbase vars; Pc...
Definition: unaires.c:140
Psysteme sc_make(Pcontrainte leg, Pcontrainte lineg)
Psysteme sc_make(Pcontrainte leg, Pcontrainte lineg): allocation et initialisation d'un systeme d'equ...
Definition: sc.c:78

References Pcontrainte_separate_on_vars(), and sc_make().

Referenced by generate_remapping_code().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_substitute_dimension()

Psysteme sc_substitute_dimension ( Psysteme  s,
Variable  i,
Pvecteur  v 
)

Psysteme sc_substitute_dimension(Psysteme s, Variable i, Pvecteur v): The ith dimension of all constraints c is updated:

c = c + c_i v

Vector v is untouched

translate all equations

translate all inequalities

update basis in s

Definition at line 130 of file sc.c.

131 {
132  Pcontrainte e;
133  Pcontrainte c;
134 
135  if(!SC_UNDEFINED_P(s)) {
136  //vect_add_elem(&v, i, VALUE_MONE);
137  /* translate all equations */
138  for(e=s->egalites; !CONTRAINTE_UNDEFINED_P(e); e = e->succ)
139  (void) contrainte_substitute_dimension(e, i, v);
140 
141  /* translate all inequalities */
142  for(c=s->inegalites; !CONTRAINTE_UNDEFINED_P(c); c = c->succ)
143  (void) contrainte_substitute_dimension(c, i, v);
144 
145  /* update basis in s */
146  vect_rm(s->base);
147  s->base = (Pbase) NULL;
148  sc_creer_base(s);
149  }
150  return s;
151 }
#define CONTRAINTE_UNDEFINED_P(c)
Pcontrainte contrainte_substitute_dimension(Pcontrainte e, Variable i, Pvecteur v)
Definition: binaires.c:57
struct Svecteur * Pbase
void vect_rm(Pvecteur v)
void vect_rm(Pvecteur v): desallocation des couples de v;
Definition: alloc.c:78

References Ssysteme::base, contrainte_substitute_dimension(), CONTRAINTE_UNDEFINED_P, Ssysteme::egalites, Ssysteme::inegalites, sc_creer_base(), Scontrainte::succ, and vect_rm().

+ Here is the call graph for this function:

◆ sc_translate()

Psysteme sc_translate ( Psysteme  s,
Pbase  b,
char * (*)()  variable_name 
)

Psysteme sc_translate(Psysteme s, Pbase b, char * (*variable_name)()): reecriture du systeme s dans la base b basee sur les noms des vecteurs de base; tous les vecteurs de base utilises dans s doivent avoir un vecteur de base de meme nom dans b.

translate all equations

translate all inequalities

update basis in s; its dimension should not change

Definition at line 99 of file sc.c.

103 {
104  Pcontrainte e;
105  Pcontrainte i;
106 
107  if(!SC_UNDEFINED_P(s)) {
108 
109  /* translate all equations */
110  for(e=s->egalites; !CONTRAINTE_UNDEFINED_P(e); e = e->succ)
111  (void) contrainte_translate(e, b, variable_name);
112 
113  /* translate all inequalities */
114  for(i=s->inegalites; !CONTRAINTE_UNDEFINED_P(i); i = i->succ)
115  (void) contrainte_translate(i, b, variable_name);
116 
117  /* update basis in s; its dimension should not change */
118  s->base = vect_translate(s->base, b, variable_name);
119  }
120  return s;
121 }
Pvecteur vect_translate(Pvecteur v, Pbase b, char *(*variable_name)(Variable))
Pvecteur vect_translate(Pvecteur v, Pbase b, char * (*variable_name)()): modify vector v so that its ...
Definition: base.c:313
Pcontrainte contrainte_translate(Pcontrainte, Pbase, char *(*)(void))
char * variable_name(Variable v)
polynome_ri.c
Definition: polynome_ri.c:73

References contrainte_translate(), CONTRAINTE_UNDEFINED_P, Scontrainte::succ, variable_name(), and vect_translate().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_variable_rename()

Psysteme sc_variable_rename ( Psysteme  s,
Variable  v_old,
Variable  v_new 
)

Psysteme sc_variable_rename(Psysteme s, Variable v_old, Variable v_new): reecriture du systeme s remplacant toutes les occurences de la coordonnees v_old par des occurences de v_new.

v_new MUST NOT already be in the base.

rename all equations

rename all inequalities

update basis in s; its dimension should not change

Definition at line 157 of file sc.c.

161 {
162  Pcontrainte e, i;
163 
164  /* v_new MUST NOT already be in the base. */
165  assert(vect_coeff(v_new, s->base)==VALUE_ZERO);
166 
167  if(!SC_UNDEFINED_P(s))
168  {
169  /* rename all equations */
170  for(e=s->egalites; !CONTRAINTE_UNDEFINED_P(e); e = e->succ)
171  (void) contrainte_variable_rename(e, v_old, v_new);
172 
173  /* rename all inequalities */
174  for(i=s->inegalites; !CONTRAINTE_UNDEFINED_P(i); i = i->succ)
175  (void) contrainte_variable_rename(i, v_old, v_new);
176 
177  /* update basis in s; its dimension should not change */
178  s->base = vect_variable_rename(s->base, v_old, v_new);
179  }
180 
181  return s;
182 }
#define VALUE_ZERO
Pvecteur vect_variable_rename(Pvecteur v, Variable v_old, Variable v_new)
Pvecteur vect_variable_rename(Pvecteur v, Variable v_old, Variable v_new): rename the potential coord...
Definition: base.c:366
Pcontrainte contrainte_variable_rename(Pcontrainte, Variable, Variable)
Pcontrainte contrainte_variable_rename(Pcontrainte c, Variable v_old, Variable v_new): rename the pot...
Definition: unaires.c:115
#define assert(ex)
Definition: newgen_assert.h:41
Value vect_coeff(Variable var, Pvecteur vect)
Variable vect_coeff(Variable var, Pvecteur vect): coefficient de coordonnee var du vecteur vect —> So...
Definition: unaires.c:228

References assert, CONTRAINTE_UNDEFINED_P, contrainte_variable_rename(), Scontrainte::succ, VALUE_ZERO, vect_coeff(), and vect_variable_rename().

Referenced by adg_dataflowgraph(), c_convex_effects_on_actual_parameter_forward_translation(), copy_write_statement_with_cumulated_regions(), dj_variable_rename(), interlaced_basic_workchunk_regions_p(), sc_change_baseindex(), sc_variables_rename(), transformer_combine(), transformer_domain_intersection(), and transformer_value_substitute().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_variables_rename()

Psysteme sc_variables_rename ( Psysteme  s,
Pvecteur  pv_old,
Pvecteur  pv_new,
get_variable_name_t  variable_name 
)

Psysteme sc_variables_rename(Psysteme s, Pvecteur pv_old, Pvecteur pv_new): reecriture du systeme s remplacant toutes les occurences des coordonnees de pv_old par des occurences de pv_new.

Definition at line 224 of file sc.c.

228 {
229  Pvecteur pv;
230  for (pv = pv_old; !VECTEUR_UNDEFINED_P(pv); pv = pv->succ) {
231  Variable var_new = base_find_variable_name(pv_new, vecteur_var(pv),
232  variable_name);
233  if (!VARIABLE_UNDEFINED_P(var_new))
234  s = sc_variable_rename(s,pv->var,var_new);
235  }
236  return s;
237 }
Variable base_find_variable_name(Pbase b, Variable v, char *(*variable_name)(Variable))
Variable base_find_variable_name(Pbase b, Variable v, char * (*variable_name)()): returns the variabl...
Definition: base.c:170
Psysteme sc_variable_rename(Psysteme s, Variable v_old, Variable v_new)
Psysteme sc_variable_rename(Psysteme s, Variable v_old, Variable v_new): reecriture du systeme s remp...
Definition: sc.c:157
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60
#define VARIABLE_UNDEFINED_P(v)
Definition: vecteur-local.h:65
#define VECTEUR_UNDEFINED_P(v)

References base_find_variable_name(), sc_variable_rename(), Svecteur::succ, Svecteur::var, variable_name(), VARIABLE_UNDEFINED_P, VECTEUR_UNDEFINED_P, and vecteur_var.

Referenced by loop_nest_movement_generation(), loop_nest_to_wp65_code(), and movement_computation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_weak_consistent_p()

bool sc_weak_consistent_p ( Psysteme  sc)

check that sc is well defined, that the numbers of equalities and inequalities are consistent with the lists of equalities and inequalities, that the dimension is consistent with the basis, that the basis itself is consistent (all coefficients must be 1), and that every variable in the constraints is in the basis.

Each component in the basis should only appear once thanks to the specifications of Pvecteur (this is not checked).

Francois Irigoin, 13 November 1995

Note:

  • there is no explicit check of TCST in the basis; TCST should not be in the basis for some use of Psystemes, like transformers in Linear/C3 Library.

The test is broken down into three lines to increase the information available when Valgrind detects a memory access error.

assert(weak_consistent);

Definition at line 362 of file sc.c.

363 {
364  bool weak_consistent;
365 
366  weak_consistent = !SC_UNDEFINED_P(sc);
367 
368  if(weak_consistent) {
369  /* The test is broken down into three lines to increase the
370  information available when Valgrind detects a memory access
371  error. */
372  int neq = nb_elems_list(sc_egalites(sc));
373  int nineq = nb_elems_list(sc_inegalites(sc));
374  int dim = base_dimension(sc_base(sc));
375 
376  weak_consistent = (sc->nb_eq == neq);
377  weak_consistent = weak_consistent
378  && (sc->nb_ineq == nineq);
379  weak_consistent = weak_consistent
380  && (sc_dimension(sc) == dim);
381  }
382 
383  if(weak_consistent && sc_dimension(sc) != 0) {
384  Pbase b = sc_base(sc);
385  weak_consistent = base_normalized_p(b);
386  }
387 
388  if(weak_consistent) {
389  Pcontrainte eq;
390  Pvecteur pv;
391  Pbase diagonale = BASE_NULLE;
392 
393  for(eq = sc->egalites; eq!= NULL; eq=eq->succ) {
394  for (pv = eq->vecteur;pv!= NULL;pv=pv->succ)
395  if (pv->var != TCST)
396  vect_chg_coeff(&diagonale,pv->var, VALUE_ONE);
397  }
398  for(eq = sc->inegalites; eq!= NULL; eq=eq->succ) {
399  for (pv = eq->vecteur;pv!= NULL;pv=pv->succ)
400  if (pv->var != TCST)
401  vect_chg_coeff(&diagonale,pv->var, VALUE_ONE);
402  }
403  weak_consistent = base_included_p(diagonale, sc_base(sc));
404  base_rm(diagonale);
405  }
406 
407  /* assert(weak_consistent); */
408 
409  return weak_consistent;
410 }
bool base_included_p(Pbase b1, Pbase b2)
Pbase base_included_p(Pbase b1, Pbase b2): include_p = b1 is included in b2 – with the set meaning re...
Definition: base.c:640
#define base_rm(b)
#define BASE_NULLE
MACROS SUR LES BASES.

References base_dimension, base_included_p(), base_normalized_p(), BASE_NULLE, base_rm, Ssysteme::egalites, eq, Ssysteme::inegalites, nb_elems_list(), Ssysteme::nb_eq, Ssysteme::nb_ineq, Scontrainte::succ, Svecteur::succ, TCST, VALUE_ONE, Svecteur::var, vect_chg_coeff(), and Scontrainte::vecteur.

Referenced by main(), region_consistent_p(), sc_elim_redund_with_first_ofl_ctrl(), sc_simplex_feasibility_ofl_ctrl_fixprec(), sc_strong_normalize2(), sc_strong_normalize_and_check_feasibility(), sc_strong_normalize_and_check_feasibility2(), TestDependence(), transformer_formal_parameter_projection(), transformer_general_consistency_p(), and transformer_return_value_projection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: