PIPS
bound_generation.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "constants.h"
#include "misc.h"
#include "matrice.h"
#include "sparse_sc.h"
#include "tiling.h"
#include "movements.h"
#include "text-util.h"
#include "polyedre.h"
#include "dg.h"
+ Include dependency graph for bound_generation.c:

Go to the source code of this file.

Functions

expression lower_bound_generation (Psysteme sc_neg, Pbase index_base, int number_of_lower_bounds, int loop_rank)
 This fonction generates the lower bounds of the "loop_rank"-th loop. More...
 
expression upper_bound_generation (Psysteme sc_pos, Pbase index_base, int number_of_upper_bounds, int loop_rank)
 This fonction generates the upper bounds of the "loop_rank"-th loop. More...
 
expression test_bound_generation (Psysteme sc_test, Pbase index_base)
 This function generates the expressions of the guard if it exists. More...
 
statement bound_generation (entity module, bool bank_code, bool receive_code, entity ent, Pbase loop_body_indices, Pbase var_id, Psysteme *lsystem, Pbase index_base, int n, int sc_info[][4])
 Generation of the new loop nest characterizing the new domain. More...
 

Function Documentation

◆ bound_generation()

statement bound_generation ( entity  module,
bool  bank_code,
bool  receive_code,
entity  ent,
Pbase  loop_body_indices,
Pbase  var_id,
Psysteme lsystem,
Pbase  index_base,
int  n,
int  sc_info[][4] 
)

Generation of the new loop nest characterizing the new domain.

The set of systems lsystem describes the set of constraints of each loop index. New loop bounds are deduced from these sytems.

Initialisation des systemes

make new bound expression and new range loop

looplabel = make_new_label(initial_module_name);

new code by FI to add continue statements starts here

end of new code by FI

Parameters
moduleodule
bank_codeank_code
receive_codeeceive_code
entnt
loop_body_indicesoop_body_indices
var_idar_id
lsystemsystem
index_basendex_base
sc_infoc_info

Definition at line 328 of file bound_generation.c.

339 {
340 
341  Psysteme ps,*sc_pos,*sc_neg,sc_test;
342  Pvecteur pv;
343  Variable var;
344  int n0_loop,i,first_loop;
345  int number_of_lower_bounds = 0;
346  int number_of_upper_bounds =0;
347  expression lower_bound;
348  expression upper_bound;
349  expression test_bound;
350  range looprange;
351  statement stat, cs;
352  statement loopbody =statement_undefined;
353  test tst;
354  entity looplabel;
355  loop newloop;
356  int space = (n+1) * sizeof(Ssysteme);
357  bool debut = true;
358  int j;
359  debug_on("MOVEMENT_DEBUG_LEVEL");
360  debug(8,"bound_generation","begin\n");
361 
362  /* Initialisation des systemes */
363 
364  sc_neg = (Psysteme *) malloc((unsigned)(space));
365  sc_pos = (Psysteme *) malloc((unsigned)(space));
366  ps = lsystem[1];
367  sc_test = sc_init_with_sc(ps);
368 
369  bound_distribution(lsystem,index_base,sc_info,n,
370  sc_neg,sc_pos,sc_test);
371 
372 
373  if (!CONTRAINTE_UNDEFINED_P(sc_test->inegalites)) {
374  test_bound = test_bound_generation(sc_test,index_base);
375  loopbody = make_datum_movement(module,receive_code,ent,
376  loop_body_indices,
377  var_id);
378  tst = make_test(test_bound,loopbody,
380  stat = test_to_statement(tst);
381  loopbody=make_block_statement(CONS(STATEMENT,stat,NIL));
382  debut=false;
383  }
384 
385  ifdebug(8) {
386  (void) fprintf(stderr, "base des indices \n");
387  for (pv = index_base; pv!=NULL; pv=pv->succ)
388  fprintf (stderr,"%s,",entity_local_name((entity) pv->var));
389 
390  for (i=1;i<=n;i++) {
391  for (j=1; j<=3;j++) {
392  printf ("%d,",sc_info[i][j]); }
393  printf ("\n");
394  }
395  }
396 
397  first_loop = (bank_code) ? 2 : 1;
398 
399  for (n0_loop = vect_size(index_base); n0_loop >= first_loop; n0_loop --) {
400  var = variable_of_rank(index_base,n0_loop);
401 
402  if (sc_info[rank_of_variable(index_base,var)][1]) {
403  ps = lsystem[n0_loop];
404  ifdebug(8) {
405  (void) fprintf(stderr,"LE SYSTEME est :\n");
406  (void) sc_fprint(stderr, ps, (get_variable_name_t) entity_local_name);
407  }
408  number_of_lower_bounds = 0;
409  number_of_upper_bounds = 0;
410  if (debut) {
412  receive_code,ent,
413  loop_body_indices,
414  var_id,
415  sc_neg[n0_loop],
416  sc_pos[n0_loop],
417  index_base,n0_loop,
418  sc_info[n0_loop][3],
419  sc_info[n0_loop][2]);
420  debut = false;
421  }
422  else {
423  /* make new bound expression and new range loop */
424 
425  number_of_upper_bounds=sc_info[n0_loop][2];
426  number_of_lower_bounds=sc_info[n0_loop][3];
427  lower_bound = lower_bound_generation(sc_neg[n0_loop],
428  index_base,
429  number_of_lower_bounds,
430  n0_loop);
431 
432  upper_bound = upper_bound_generation(sc_pos[n0_loop],
433  index_base,
434  number_of_upper_bounds,
435  n0_loop);
436 
437  looprange = make_range(lower_bound,upper_bound,
438  int_to_expression(1));
439 
440  /* looplabel = make_new_label(initial_module_name); */
441  /* new code by FI to add continue statements starts here */
442  looplabel = make_loop_label(9000, module);
443  cs = make_continue_statement(looplabel);
446  CONS(STATEMENT, cs, NIL));
447  else {
448  loopbody = make_block_statement(CONS(STATEMENT, loopbody,
449  CONS(STATEMENT, cs, NIL)));
450  }
451  /* end of new code by FI */
452 
453  if (n0_loop ==1)
454  newloop = make_loop((entity) var,
455  looprange,
456  loopbody,
457  looplabel,
459  UU),
460  NIL);
461  else newloop = make_loop((entity) var,
462  looprange,
463  loopbody,
464  looplabel,
466  NIL);
467 
468  stat = loop_to_statement(newloop);
469 
470  loopbody = make_block_statement(CONS(STATEMENT,stat,NIL));
471  ifdebug(8) {
473  pips_debug(8,"systeme pour la %d boucle \n",n0_loop);
474  (void) sc_fprint(stderr, sc_neg[n0_loop],
476  (void) sc_fprint(stderr, sc_pos[n0_loop],
478  (void) sc_fprint(stderr, sc_test,
480  }
481  }
482  }
483  }
484 
485  free((Psysteme) sc_neg);
486  free((Psysteme) sc_pos);
487 
488  debug(8,"bound_generation","end\n");
489  debug_off();
490  return(loopbody);
491 
492 }
execution make_execution(enum execution_utype tag, void *val)
Definition: ri.c:838
loop make_loop(entity a1, range a2, statement a3, entity a4, execution a5, list a6)
Definition: ri.c:1301
test make_test(expression a1, statement a2, statement a3)
Definition: ri.c:2607
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
int rank_of_variable(Pbase base, Variable var)
this function returns the rank of the variable var in the base 0 encodes TCST, but I do not know why,...
Definition: base.c:497
void bound_distribution(Psysteme *pps, Pbase index_base, sc_info, int nb_loop, Psysteme *sc_neg, Psysteme *sc_pos, Psysteme sc_test)
Distribution of the constraints of the system ps in three systems.
#define CONTRAINTE_UNDEFINED_P(c)
void * malloc(YYSIZE_T)
void free(void *)
statement make_block_statement(list)
Make a block statement from a list of statement.
Definition: statement.c:616
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
statement make_continue_statement(entity)
Definition: statement.c:953
float_t space[SIZE][SIZE]
Definition: jacobi.c:7
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
statement make_movements_loop_body_wp65(entity module, bool receive_code, entity ent, Pbase local_indices, Pbase var_id, Psysteme sc_neg, Psysteme sc_pos, Pbase index_base, int rank, int number_of_lower_bounds, int number_of_upper_bounds)
statement make_movements_loop_body_wp65(module,receive_code, ent,local_indices,var_id,...
void wp65_debug_print_text(entity m, statement s)
include "values.h"
statement make_datum_movement(entity module, bool receive_code, entity ent, Pbase local_indices, Pbase var_id)
statement make_datum_movement(module,receive_code,ent, local_indices,var_id)
#define debug_on(env)
Definition: misc-local.h:157
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define debug_off()
Definition: misc-local.h:160
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
expression test_bound_generation(Psysteme sc_test, Pbase index_base)
This function generates the expressions of the guard if it exists.
expression lower_bound_generation(Psysteme sc_neg, Pbase index_base, int number_of_lower_bounds, int loop_rank)
This fonction generates the lower bounds of the "loop_rank"-th loop.
expression upper_bound_generation(Psysteme sc_pos, Pbase index_base, int number_of_upper_bounds, int loop_rank)
This fonction generates the upper bounds of the "loop_rank"-th loop.
#define UU
Definition: newgen_types.h:98
static char * module
Definition: pips.c:74
#define instruction_block_p(i)
#define loop_to_statement(l)
#define test_to_statement(t)
#define instruction_block(i)
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...
Definition: entity.c:453
entity entity_empty_label(void)
Definition: entity.c:1105
entity make_loop_label(int __attribute__((unused)) desired_number, entity module)
Definition: entity.c:370
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188
#define entity_undefined
Definition: ri.h:2761
#define statement_instruction(x)
Definition: ri.h:2458
@ is_execution_parallel
Definition: ri.h:1190
@ is_execution_sequential
Definition: ri.h:1189
#define statement_undefined
Definition: ri.h:2419
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
Psysteme sc_init_with_sc(Psysteme sc)
This function returns a new empty system which has been initialized with the same dimension and base ...
Definition: sc_alloc.c:303
Variable variable_of_rank()
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...
Definition: sc_io.c:220
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
int printf()
#define ifdebug(n)
Definition: sg.c:47
Pcontrainte inegalites
Definition: sc-local.h:71
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92
char *(* get_variable_name_t)(Variable)
Definition: vecteur-local.h:62
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

References bound_distribution(), CONS, CONTRAINTE_UNDEFINED_P, debug(), debug_off, debug_on, entity_empty_label(), entity_local_name(), entity_undefined, fprintf(), free(), gen_nconc(), ifdebug, Ssysteme::inegalites, instruction_block, instruction_block_p, int_to_expression(), is_execution_parallel, is_execution_sequential, loop_to_statement, lower_bound_generation(), make_block_statement(), make_continue_statement(), make_datum_movement(), make_execution(), make_loop(), make_loop_label(), make_movements_loop_body_wp65(), make_range(), make_test(), malloc(), module, NIL, pips_debug, printf(), rank_of_variable(), sc_fprint(), sc_init_with_sc(), space, STATEMENT, statement_instruction, statement_undefined, Svecteur::succ, test_bound_generation(), test_to_statement, upper_bound_generation(), UU, Svecteur::var, variable_of_rank(), vect_size(), and wp65_debug_print_text().

Referenced by movement_computation().

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

◆ lower_bound_generation()

expression lower_bound_generation ( Psysteme  sc_neg,
Pbase  index_base,
int  number_of_lower_bounds,
int  loop_rank 
)

This fonction generates the lower bounds of the "loop_rank"-th loop.

bound_generation.c

this condition is true if the constraint constrains directly the variable

In that case the bound expression results from the combination of two constraints. The variable of rank "higher_rank" will be eliminated from these two constraints in order to give only one bound for the "loop_rank" index.

Parameters
sc_negc_neg
index_basendex_base
number_of_lower_boundsumber_of_lower_bounds
loop_rankoop_rank

Definition at line 56 of file bound_generation.c.

60 {
61  Pcontrainte ineq;
62  Variable var = variable_of_rank(index_base,loop_rank);
63  Pvecteur pv2 = VECTEUR_NUL;
64  expression expr,ex1,ex2, lower=expression_undefined ;
65  cons * lex2,* lexpr = NIL;
67  int higher_rank,nlb = 0;
68  Value coeff;
69  bool reductible = false;
70 
71  debug_on("MOVEMENT_DEBUG_LEVEL");
72  debug(8,"lower_bound_generation","begin\n");
73 
74  if (number_of_lower_bounds>=1) {
75  for (ineq = sc_neg->inegalites;
76  !CONTRAINTE_UNDEFINED_P(ineq);
77  ineq=ineq->succ) {
78  Variable var2;
79  Value coeff2,coeff3;
80  reductible = false;
81  higher_rank=search_higher_rank(ineq->vecteur,index_base);
82  if (higher_rank > loop_rank ) {
83  Pcontrainte pc2 = ineq->succ;
84  var2 = variable_of_rank(index_base,higher_rank);
85  coeff2 = vect_coeff(var2,ineq->vecteur);
86  coeff3 = vect_coeff(var2,pc2->vecteur);
87 
88  if (value_one_p(value_abs(coeff2)) ||
89  value_one_p(value_abs(coeff3))) {
90  reductible = true;
91  pv2 = vect_cl2(value_abs(coeff2),pc2->vecteur,
92  value_abs(coeff3),ineq->vecteur);
93  ineq= ineq->succ;
94  }
95  }
96  else pv2 = vect_dup(ineq->vecteur);
97  if (higher_rank <= loop_rank || reductible ) {
98  /* this condition is true if the constraint constrains
99  directly the variable */
100  if (value_notmone_p(coeff= vect_coeff(var,pv2)))
101  vect_add_elem(&pv2, TCST,
103  vect_chg_coeff(&pv2,var,VALUE_ZERO);
104  expr = ex1 = make_vecteur_expression(pv2);
105  if (value_notmone_p(coeff)) {
106  ex2 = int_to_expression(
107  VALUE_TO_INT(value_abs(coeff)));
108  lex2 =CONS(EXPRESSION,ex2,NIL);
109  expr=make_div_expression(ex1,lex2);
110  vect_add_elem(&pv2,TCST,value_plus(coeff,VALUE_ONE));
111  }
112  }
113  else {
114  /* In that case the bound expression results from
115  the combination of two constraints. The variable of
116  rank "higher_rank" will be eliminated from these two
117  constraints in order to give only one bound for
118  the "loop_rank" index. */
119  expr = complex_bound_computation(sc_neg,index_base,
120  ineq,ineq->succ,
121  higher_rank);
122  ineq = ineq->succ;
123 
124  }
125  lexpr = CONS(EXPRESSION, expr,lexpr);
126  nlb ++;
127  }
128  if (nlb > 1)
129  lower = make_op_expression(max,lexpr);
130  else lower = EXPRESSION(CAR(lexpr));
131  }
132  debug(8,"lower_bound_generation","end\n");
133  debug_off();
134 
135  return(lower);
136 }
#define VALUE_ZERO
#define VALUE_TO_INT(val)
#define value_uminus(val)
unary operators on values
#define value_one_p(val)
int Value
#define value_notmone_p(val)
#define value_plus(v1, v2)
binary operators on values
#define VALUE_ONE
#define value_abs(val)
int search_higher_rank(Pvecteur vect, Pbase base)
int search_higher_rank(): this fonction returns the rank of the variable of higher rank in the vecteu...
Definition: base.c:541
expression complex_bound_computation(Psysteme __attribute__((unused)) sc, Pbase index_base, Pcontrainte ineq1, Pcontrainte ineq2, int rank)
Compute the complex bounds associated to the variable of higher rank, after the variable "el_var" of ...
#define max(a, b)
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
expression make_div_expression(expression, cons *)
operation.c
Definition: operation.c:42
expression make_op_expression(entity, cons *)
Definition: operation.c:55
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
Definition: entity.c:1450
expression make_vecteur_expression(Pvecteur pv)
make expression for vector (Pvecteur)
Definition: expression.c:1650
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define expression_undefined
Definition: ri.h:1223
Pvecteur vecteur
struct Scontrainte * succ
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Definition: alloc.c:51
Pvecteur vect_cl2(Value x1, Pvecteur v1, Value x2, Pvecteur v2)
Definition: binaires.c:247
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Definition: unaires.c:72
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
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 CAR, complex_bound_computation(), CONS, CONTRAINTE_UNDEFINED_P, debug(), debug_off, debug_on, EXPRESSION, expression_undefined, Ssysteme::inegalites, int_to_expression(), local_name_to_top_level_entity(), make_div_expression(), make_op_expression(), make_vecteur_expression(), max, NIL, search_higher_rank(), Scontrainte::succ, TCST, value_abs, value_notmone_p, VALUE_ONE, value_one_p, value_plus, VALUE_TO_INT, value_uminus, VALUE_ZERO, variable_of_rank(), vect_add_elem(), vect_chg_coeff(), vect_cl2(), vect_coeff(), vect_dup(), Scontrainte::vecteur, and VECTEUR_NUL.

Referenced by bound_generation(), and make_movements_loop_body_wp65().

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

◆ test_bound_generation()

expression test_bound_generation ( Psysteme  sc_test,
Pbase  index_base 
)

This function generates the expressions of the guard if it exists.

All the expressions of the guards are computed from the combination of two constraints where the variable of higher_rank is eliminated.

generation of the left hand side of the guard

generation of the right hand side of the guard

generation of the inequality

Parameters
sc_testc_test
index_basendex_base

Definition at line 234 of file bound_generation.c.

237 {
238 
239  Pcontrainte ineq,right_ineq,left_ineq;
240  int rank;
241  Value coeff;
242  Variable var;
243  bool debut;
244  expression expr,ex1,ex2,ex3,ex4;
248 
249  cons * lex2;
252 
253  debug_on("MOVEMENT_DEBUG_LEVEL");
254  debug(8,"test_bound_generation","begin\n");
255 
256 
257  debut = true;
258  for (ineq = sc_test->inegalites;
259  !CONTRAINTE_UNDEFINED_P(ineq);
260  ineq=ineq->succ) {
261  rank = search_higher_rank(ineq->vecteur,index_base);
262  var = variable_of_rank(index_base,rank);
263 
264  if (value_pos_p(coeff= vect_coeff(var,ineq->vecteur))) {
265  right_ineq = contrainte_dup(ineq);
266  left_ineq = contrainte_dup(ineq->succ);
267  }
268  else {
269  right_ineq = contrainte_dup(ineq->succ);
270  left_ineq= contrainte_dup(ineq);
271  }
272 
273  /* generation of the left hand side of the guard */
274  if (value_notmone_p(coeff= vect_coeff(var,left_ineq->vecteur)))
275  vect_add_elem(&(left_ineq->vecteur),TCST,
277 
278  vect_chg_coeff(&(left_ineq->vecteur),var,VALUE_ZERO);
279  ex1 = make_vecteur_expression(left_ineq->vecteur);
280  if (value_notmone_p(coeff)) {
281  ex2 = int_to_expression(
282  VALUE_TO_INT(value_abs(coeff)));
283  lex2 = CONS(EXPRESSION,ex2,NIL);
284  exl = make_div_expression(ex1,lex2);
285  vect_add_elem(&(left_ineq->vecteur),TCST,
286  value_plus(coeff,VALUE_ONE));
287  }
288 
289  /* generation of the right hand side of the guard */
290 
291  coeff= vect_coeff(var,right_ineq->vecteur);
292  vect_chg_sgn(right_ineq->vecteur);
293  vect_chg_coeff(&(right_ineq->vecteur),var,VALUE_ZERO);
294  ex3= make_vecteur_expression(right_ineq->vecteur);
295  vect_chg_sgn(right_ineq->vecteur);
296 
297  if (value_notone_p(coeff)) {
298  ex4 = int_to_expression(
299  VALUE_TO_INT(value_abs(coeff)));
300  lex2 =CONS(EXPRESSION,ex4,NIL);
301  exr = make_div_expression(ex3,lex2);
302  }
303  lex2 = CONS(EXPRESSION,exr,NIL);
304 
305  /* generation of the inequality */
306  expr = make_op_expression(inf,CONS(EXPRESSION,exl,lex2));
307 
308  if (debut) lexpr =expr;
309  else {
310  lex2 = CONS(EXPRESSION,expr,NIL);
311  lexpr=make_op_expression(an,CONS(EXPRESSION,lexpr,lex2));
312  }
313  ineq = ineq->succ;
314  debut = false;
315  }
316 
317  debug(8,"test_bound_generation","end\n");
318  debug_off();
319  return(lexpr);
320 }
#define value_pos_p(val)
#define value_notone_p(val)
Pcontrainte contrainte_dup(Pcontrainte c_in)
Pcontrainte contrainte_dup(Pcontrainte c_in): allocation d'une contrainte c_out prenant la valeur de ...
Definition: alloc.c:132
static entity rank
#define AND_OPERATOR_NAME
FI: intrinsics are defined at a third place after bootstrap and effects! I guess the name should be d...
#define LESS_OR_EQUAL_OPERATOR_NAME
void vect_chg_sgn(Pvecteur v)
void vect_chg_sgn(Pvecteur v): multiplie v par -1
Definition: scalaires.c:151

References AND_OPERATOR_NAME, CONS, contrainte_dup(), CONTRAINTE_UNDEFINED_P, debug(), debug_off, debug_on, EXPRESSION, expression_undefined, Ssysteme::inegalites, int_to_expression(), LESS_OR_EQUAL_OPERATOR_NAME, local_name_to_top_level_entity(), make_div_expression(), make_op_expression(), make_vecteur_expression(), NIL, rank, search_higher_rank(), Scontrainte::succ, TCST, value_abs, value_notmone_p, value_notone_p, VALUE_ONE, value_plus, value_pos_p, VALUE_TO_INT, value_uminus, VALUE_ZERO, variable_of_rank(), vect_add_elem(), vect_chg_coeff(), vect_chg_sgn(), vect_coeff(), and Scontrainte::vecteur.

Referenced by bound_generation().

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

◆ upper_bound_generation()

expression upper_bound_generation ( Psysteme  sc_pos,
Pbase  index_base,
int  number_of_upper_bounds,
int  loop_rank 
)

This fonction generates the upper bounds of the "loop_rank"-th loop.

this condition is true if the constraint constrains directly the variable

In that case the bound expression results from the combination of two constraints. The variable of rank "higher_rank" will be eliminated from these two constraints in order to give only one bound for the "loop_rank" index.

Parameters
sc_posc_pos
index_basendex_base
number_of_upper_boundsumber_of_upper_bounds
loop_rankoop_rank

Definition at line 145 of file bound_generation.c.

149 {
150  Pcontrainte ineq;
151  Pvecteur pv2=VECTEUR_NUL;
152  int higher_rank, nub = 0;
153  Value coeff;
154  Variable var = variable_of_rank(index_base,loop_rank);
155  expression expr, ex2, ex1, upper = expression_undefined;
156  cons * lex2,* lexpr = NIL;
158  bool reductible = false;
159 
160  debug_on("MOVEMENT_DEBUG_LEVEL");
161  debug(8,"upper_bound_generation","begin\n");
162 
163 
164  if (number_of_upper_bounds) {
165  for (ineq = sc_pos->inegalites;
166  !CONTRAINTE_UNDEFINED_P(ineq);
167  ineq=ineq->succ) {
168  Variable var2;
169  Value coeff2,coeff3;
170  reductible = false;
171  higher_rank=search_higher_rank(ineq->vecteur,index_base);
172  if (higher_rank > loop_rank ) {
173  var2 = variable_of_rank(index_base,higher_rank);
174  coeff2 = vect_coeff(var2,ineq->vecteur);
175  coeff3 = vect_coeff(var2,(ineq->succ)->vecteur);
176  if (value_one_p(value_abs(coeff2)) ||
177  value_one_p(value_abs(coeff3))) {
178  reductible = true;
179  pv2 = vect_cl2(value_abs(coeff2),(ineq->succ)->vecteur,
180  value_abs(coeff3),ineq->vecteur);
181 
182  ineq= ineq->succ;
183  }
184  }
185  else pv2 = vect_dup(ineq->vecteur);
186 
187  if (higher_rank <=loop_rank || reductible) {
188  /* this condition is true if the constraint constrains
189  directly the variable */
190  coeff= vect_coeff(var,pv2);
191  vect_chg_sgn(pv2);
192  vect_chg_coeff(&pv2,var,VALUE_ZERO);
193  expr = ex1 =make_vecteur_expression(pv2);
194  vect_chg_sgn(pv2);
195 
196  if (value_notone_p(coeff)) {
197  ex2 = int_to_expression(
198  VALUE_TO_INT(value_abs(coeff)));
199  lex2 = CONS(EXPRESSION,ex2,NIL);
200  expr= make_div_expression(ex1,lex2);
201  }
202  }
203  else {
204  /* In that case the bound expression results from
205  the combination of two constraints. The variable of
206  rank "higher_rank" will be eliminated from these two
207  constraints in order to give only one bound for
208  the "loop_rank" index. */
209  expr = complex_bound_computation(sc_pos,index_base,
210  ineq,ineq->succ,
211  higher_rank);
212  ineq = ineq->succ;
213  }
214  lexpr = CONS(EXPRESSION, expr,lexpr);
215  nub ++;
216  }
217  if (nub > 1)
218  upper = make_op_expression(min,lexpr);
219  else upper = EXPRESSION(CAR(lexpr));
220  }
221  debug(8,"upper_bound_generation","end\n");
222  debug_off();
223  return (upper);
224 
225 }
#define min(a, b)

References CAR, complex_bound_computation(), CONS, CONTRAINTE_UNDEFINED_P, debug(), debug_off, debug_on, EXPRESSION, expression_undefined, Ssysteme::inegalites, int_to_expression(), local_name_to_top_level_entity(), make_div_expression(), make_op_expression(), make_vecteur_expression(), min, NIL, search_higher_rank(), Scontrainte::succ, value_abs, value_notone_p, value_one_p, VALUE_TO_INT, VALUE_ZERO, variable_of_rank(), vect_chg_coeff(), vect_chg_sgn(), vect_cl2(), vect_coeff(), vect_dup(), Scontrainte::vecteur, and VECTEUR_NUL.

Referenced by bound_generation(), and make_movements_loop_body_wp65().

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