PIPS
ricedg.c
Go to the documentation of this file.
1 /*
2 
3  $Id: ricedg.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23  */
24 #ifdef HAVE_CONFIG_H
25 #include "pips_config.h"
26 #endif
27 /* Dependence Graph computation for Allen & Kennedy algorithm
28  *
29  * Remi Triolet, Yi-qing Yang
30  *
31  * Modifications:
32  * - new option to use semantics analysis results (Francois Irigoin,
33  * 12 April 1991)
34  *
35  * - compute the dependence cone, the statistics.
36  * (Yi-Qing, August 1991)
37  *
38  * - updated using DEFINE_CURRENT_MAPPING, BA, September 3, 1993
39  *
40  * - dg_type introduced to replace dg_fast and dg_semantics; it is more
41  * general. (BC, August 1995).
42  *
43  * - TestDependence split into different procedures for more readability.
44  * (BC, August 1995).
45  *
46  * - creation of quick_privatize.c and prettyprint.c to reduce
47  * the size of ricedg.c (FI, Oct. 1995)
48  *
49  * Notes:
50  * - Many values seem to be assigned to StatementToContext and never be
51  * freed;
52  *
53  */
54 
55 #include "genC.h"
56 #include "local.h"
57 #include "workspace-util.h"
58 #include "prettyprint.h"
59 
60 /* local variables */
61 /*the variables for the statistics of test of dependence and parallelization */
62 /* they should not be global ? FC.
63  */
65 int NbrIndepFind = 0;
66 int NbrAllEquals = 0;
67 int NbrDepCnst = 0;
68 int NbrTestExact = 0;
72 int NbrScalDep = 0;
73 int NbrIndexDep = 0;
74 int deptype[5][3], constdep[5][3];
75 int NbrTestCnst = 0;
76 int NbrTestGcd = 0;
77 int NbrTestSimple = 0; /* by sc_normalize() */
78 int NbrTestDiCnst = 0;
81 int NbrTestProjEq = 0;
82 int NbrTestProjFM = 0;
83 int NbrTestDiVar = 0;
86 int FMComp[18]; /*for counting the number of F-M complexity less than 16.
87  The complexity of one projection by F-M is multiply
88  of the nbr. of inequations positive and the nbr. of
89  inequations negatives who containe the variable
90  eliminated.The last elem of the array (ie FMComp[17])
91  is used to count cases with complexity over 16*/
92 bool is_test_exact = true;
93 bool is_test_inexact_eq = false;
94 bool is_test_inexact_fm = false;
95 bool is_dep_cnst = false;
97 bool Finds2s1;
98 
99 /* to map statements to execution contexts */
100 /* Psysteme_undefined is not defined in sc.h; as Psysteme is external,
101  * I define it here. BA, September 1993
102  */
103 #define Psysteme_undefined SC_UNDEFINED
105 
106 /* to map statements to enclosing loops */
107 /* DEFINE_CURRENT_MAPPING(loops, list) now defined in ri-util, BA, September 1993 */
108 
109 /* the dependence graph being updated */
110 static graph dg;
111 
112 static bool PRINT_RSDG = false;
113 
114 /* Different types of dependence tests:
115  *
116  * switch dg_type:
117  *
118  * DG_FAST: no context constraints are added
119  * DG_FULL: use loop bounds as context
120  * DG_SEMANTICS : use preconditions as context
121  *
122  * The use of the variable dg_type allows to add more cases in the future.
123  */
124 #define DG_FAST 1
125 #define DG_FULL 2
126 #define DG_SEMANTICS 3
127 
128 static int dg_type = DG_FAST;
129 
130 // stupid counter used by one debug message in ricedg
131 extern int Nbrdo;
132 
133 /*********************************************************************************/
134 /* INTERFACE FUNCTIONS */
135 /*********************************************************************************/
136 
137 static bool rice_dependence_graph(char */*mod_name*/);
138 
139 bool rice_fast_dependence_graph(char *mod_name) {
140  dg_type = DG_FAST;
141  return rice_dependence_graph(mod_name);
142 }
143 
144 bool rice_full_dependence_graph(char *mod_name) {
145  dg_type = DG_FULL;
146  return rice_dependence_graph(mod_name);
147 }
148 
149 bool rice_semantics_dependence_graph(char *mod_name) {
151  return rice_dependence_graph(mod_name);
152 }
153 
154 bool rice_regions_dependence_graph(char *mod_name) {
156  "REGION_CHAINS"))
157  pips_user_warning("Region chains not selected - using effects instead\n");
158 
159  dg_type = DG_FAST;
160  return rice_dependence_graph(mod_name);
161 }
162 
163 
164 
165 /*********************************************************************************/
166 /* STATIC FUNCTION DECLARATIONS */
167 /*********************************************************************************/
168 
169 static void rdg_unstructured(unstructured /*u*/);
170 static void rdg_statement(statement /*stat*/);
171 static void rdg_loop(statement /*stat*/);
172 static void rice_update_dependence_graph(statement /*stat*/, set /*region*/);
173 static list TestCoupleOfEffects(statement /*s1*/,
174  effect /*e1*/,
175  statement /*s2*/,
176  effect /*e2*/,
177  list /*llv*/,
178  Ptsg */*gs*/,
179  list */*levelsop*/,
180  Ptsg */*gsop*/);
181 static list TestDependence(list /*n1*/,
182  Psysteme /*sc1*/,
183  statement /*s1*/,
184  effect /*ef1*/,
185  reference /*r1*/,
186  list /*n2*/,
187  Psysteme /*sc2*/,
188  statement /*s2*/,
189  effect /*ef2*/,
190  reference /*r2*/,
191  list /*llv*/,
192  Ptsg */*gs*/,
193  list */*levelsop*/,
194  Ptsg */*gsop*/);
196  reference /*r2*/,
197  Psysteme /*sc1*/,
198  Psysteme /*sc2*/,
199  Psysteme */*psc_dep*/,
200  list /*llv*/,
201  list /*s2_enc_loops*/);
203  reference /*r2*/,
204  list /*llv*/,
205  list /*s2_enc_loops*/,
206  Psysteme */*psc_dep*/);
207 static void dependence_system_add_lci_and_di(Psysteme */*psc_dep*/,
208  list /*s1_enc_loops*/,
209  Pvecteur */*p_DiIncNonCons*/);
211  int /*cl*/,
212  statement /*s1*/,
213  effect /*ef1*/,
214  statement /*s2*/,
215  effect /*ef2*/);
216 static Ptsg dependence_cone_positive(Psysteme /*dep_sc*/);
217 static list loop_variant_list(statement /*stat*/);
218 static bool TestDiCnst(Psysteme /*ps*/,
219  int /*cl*/,
220  statement /*s1*/,
221  effect /*ef1*/,
222  statement /*s2*/,
223  effect /*ef2*/);
224 
225 
226 /**************************************** WALK THROUGH THE DEPENDENCE GRAPH */
227 
228 /* The supplementary call to init_ordering_to_statement should be
229  avoided if ordering.c were more clever. */
230 static bool rice_dependence_graph(char *mod_name) {
231  FILE *fp;
232 
234  int i, j;
235  graph chains;
236  string dg_name;
238 
240 
242  mod_name,
243  true));
245 
246  chains = (graph)db_get_memory_resource(DBR_CHAINS, mod_name, true);
247 
249 
250  debug_on("RICEDG_DEBUG_LEVEL");
251  pips_debug(1, "Computing Rice dependence graph for %s\n", mod_name);
252 
253  ifdebug(2) {
256  }
257 
258  ifdebug(1) {
259  fprintf(stderr,
260  "Space for chains: %d bytes\n",
262  fprintf(stderr,
263  "Space for obj_table: %d bytes\n",
265  }
266 
268  dg = copy_graph(chains);
269 
270  ifdebug(1) {
271  fprintf(stderr,
272  "Space for chains's copy: %d bytes\n",
274  fprintf(stderr,
275  "Space for obj_table: %d bytes\n",
277  }
278 
279  pips_debug(8,"original graph\n");
280  ifdebug(8) {
284  }
285 
286  debug_off();
287 
288  if(dg_type == DG_SEMANTICS)
290  mod_name,
291  true));
292 
294  mod_name,
295  true));
296 
297  debug_on("RICEDG_DEBUG_LEVEL");
298  pips_debug(1, "finding enclosing loops ...\n");
299 
301  ifdebug(3) {
302  fprintf(stderr, "\nThe number of DOs :\n");
303  fprintf(stderr, " Nbrdo=%d", Nbrdo);
304  }
305  debug_on("QUICK_PRIVATIZER_DEBUG_LEVEL");
306 
307  /* we need to access the statements from their ordering for the
308  dependance-graph: */
309  /* Do this as late as possible as it is also used by pipsdbm... */
311 
313  debug_off();
314 
315  for (i = 0; i <= 4; i++) {
316  for (j = 0; j <= 2; j++) {
317  deptype[i][j] = 0;
318  constdep[i][j] = 0;
319  }
320  }
321 
322  /* walk thru mod_stat to find well structured loops.
323  update dependence graph for these loops. */
324 
326 
327  ifdebug(3) {
328  fprintf(stderr, "\nThe results of statistique of test of dependence are:\n");
329  fprintf(stderr, "NbrArrayDepInit = %d\n", NbrArrayDepInit);
330  fprintf(stderr, "NbrIndepFind = %d\n", NbrIndepFind);
331  fprintf(stderr, "NbrAllEquals = %d\n", NbrAllEquals);
332  fprintf(stderr, "NbrDepCnst = %d\n", NbrDepCnst);
333  fprintf(stderr, "NbrTestExact= %d\n", NbrTestExact);
334  fprintf(stderr, "NbrDepInexactEq= %d\n", NbrDepInexactEq);
335  fprintf(stderr, "NbrDepInexactFM= %d\n", NbrDepInexactFM);
336  fprintf(stderr, "NbrDepInexactEFM= %d\n", NbrDepInexactEFM);
337  fprintf(stderr, "NbrScalDep = %d\n", NbrScalDep);
338  fprintf(stderr, "NbrIndexDep = %d\n", NbrIndexDep);
339  fprintf(stderr, "deptype[][]");
340  for (i = 0; i <= 4; i++)
341  for (j = 0; j <= 2; j++)
342  fprintf(stderr, "%d ", deptype[i][j]);
343  fprintf(stderr, "\nconstdep[][]");
344  for (i = 0; i <= 4; i++)
345  for (j = 0; j <= 2; j++)
346  fprintf(stderr, "%d ", constdep[i][j]);
347  fprintf(stderr, "\nNbrTestCnst = %d\n", NbrTestCnst);
348  fprintf(stderr, "NbrTestGcd = %d\n", NbrTestGcd);
349  fprintf(stderr, "NbrTestSimple = %d\n", NbrTestSimple);
350  fprintf(stderr, "NbrTestDiCnst = %d\n", NbrTestDiCnst);
351  fprintf(stderr, "NbrTestProjEqDi = %d\n", NbrTestProjEqDi);
352  fprintf(stderr, "NbrTestProjFMDi = %d\n", NbrTestProjFMDi);
353  fprintf(stderr, "NbrTestProjEq = %d\n", NbrTestProjEq);
354  fprintf(stderr, "NbrTestProjFM = %d\n", NbrTestProjFM);
355  fprintf(stderr, "NbrTestDiVar = %d\n", NbrTestDiVar);
356  fprintf(stderr, "NbrProjFMTotal = %d\n", NbrProjFMTotal);
357  fprintf(stderr, "NbrFMSystNonAug = %d\n", NbrFMSystNonAug);
358  fprintf(stderr, "FMComp[]");
359  for (i = 0; i < 18; i++)
360  fprintf(stderr, "%d ", FMComp[i]);
361  }
362  /* write the result to the file correspondant in the order of :
363  module,NbrArrayDeptInit,NbrIndeptFind,NbrArrayDepInit,NbrScalDep,
364  NbrIndexDep,deptype[5][3]*/
366  writeresult(mod_name);
367 
368  ifdebug(2) {
369  fprintf(stderr, "updated graph\n");
371  }
372 
373  /* FI: this is not a proper way to do it */
374  if(get_bool_property("PRINT_DEPENDENCE_GRAPH") || PRINT_RSDG) {
376  "/",
377  mod_name,
378  ".dg",
379  NULL));
380  fp = safe_fopen(dg_name, "w");
382  safe_fclose(fp, dg_name);
383  }
384 
385  debug_off();
386 
387  DB_PUT_MEMORY_RESOURCE(DBR_DG, mod_name, (char*) dg);
388 
395 
396  return true;
397 }
398 
400  list blocs = NIL;
401 
402  CONTROL_MAP(c, {
404  }, unstructured_control(u), blocs);
405 
406  gen_free_list(blocs);
407 }
408 
409 static void rdg_statement(statement stat) {
413  instruction istat = statement_instruction(stat);
414 
415  switch(instruction_tag(istat)) {
416  case is_instruction_block: {
417  FOREACH (STATEMENT, s, instruction_block(istat))
418  rdg_statement(s);
419  break;
420  }
421  case is_instruction_test:
424  break;
425  case is_instruction_loop:
426  rdg_loop(stat);
427  break;
429  wl = instruction_whileloop (istat);
430  body = whileloop_body (wl);
431  rdg_statement(body);
432  break;
434  fl = instruction_forloop (istat);
435  body = forloop_body (fl);
436  rdg_statement(body);
437  break;
438  case is_instruction_goto:
439  case is_instruction_call:
441  break;
444  break;
445  default:
446  pips_internal_error("case default reached with tag %d",
447  instruction_tag(istat));
448  break;
449  }
450 }
451 
452 static void rdg_loop(statement stat) {
453  set region;
454 
455  if(get_bool_property("COMPUTE_ALL_DEPENDENCES")) {
456  region = region_of_loop(stat);
457  ifdebug(7) {
458  fprintf(stderr, "[rdg_loop] applied on region:\n");
459  print_statement_set(stderr, region);
460  }
462  } else {
463  if((region = distributable_loop(stat)) == set_undefined) {
464  ifdebug(1) {
465  fprintf(stderr,
466  "[rdg_loop] skipping loop %td (but recursing)\n",
467  statement_number(stat));
468  }
470  } else {
472  set_free(region);
473  }
474  }
475 }
476 
477 
478 
479 /* Update of dependence graph
480  *
481  * The update of conflict information is performed for all statements in
482  * a loop. This set of statements seems to be defined by "region", while
483  * the loop is defined by "stat".
484  *
485  * Let v denote a vertex, a an arc, s a statement attached to a vertex
486  * and c a conflict, i.e. a pair of effects (e1,e2). Each arc is
487  * labelled by a list of statements. Each vertex points to a list of
488  * arcs. Each arc points to a list of conflicts. See dg.f.tex and
489  * graph.f.tex in Documentation/Newgen for more details.
490  *
491  * The procedure is quite complex because:
492  *
493  * - each dependence arc carries a list of conflicts; when a conflict is
494  * found non-existent, it has to be removed from the conflict list and
495  * the arc may also have to be removed from the arc list associated to
496  * the current vertex if its associated conflict list becomes empty;
497  * removing an element from a list is a pain because you need to know
498  * the previous element and to handle the special case of the list first
499  * element removal;
500  *
501  * - the same conflict may appear twice, once as a def-use conflict and
502  * once as a use-def conflicts; since dependence testing may be long,
503  * the conflict and its symmetric conflict are processed simultaneously;
504  * of course, conflict list and dependence arc updates become tricky,
505  *
506  * - especially if the two vertices of the dependence arc are only one:
507  * you can have a s1->s1 dependence; thus you might be scanning and
508  * updating the very same list of arcs and conflicts twice... but there
509  * is a test on pchead and pchead1 to avoid it (pchead and pchead1
510  * points to the heads of the current conflict list and of the conflict
511  * list containing the symmetrical conflict); remember, you have no
512  * guarantee that s1!=s2 and/or v1=!v2 and/or a1!=a2
513  *
514  * - note that there also is a test about symmetry: def-def and use-use
515  * conflicts cannot have symmetric conflicts;
516  *
517  * - because of the use-def/def-use symmetry, a conflict may already
518  * have been processed when it is accessed;
519  *
520  * - due to a strange feature in the NewGen declarations, the arcs
521  * are called "successors"; variables in the procedure are named with
522  * the same convention except... except when they are not; so a so-called
523  * "successor" may be either an arc or a vertex (or a statement since
524  * each vertex points to a statement)
525  *
526  * - you don't know if dg is a graph or a multigraph; apparently it's
527  * a multigraph but there is no clear semantics attaches to the different
528  * arcs joining a pair of vertices (Pierre Jouvelot, help!)
529  *
530  * - conflicts are assumed uniquely identifiable by the addresses of their
531  * two effects (and by labelling the same pair of vertices - but not the
532  * same arc); that calls for tricky bugs if some sharing between effects
533  * exists.
534  *
535  * The procedure is made of many too many nested loops and tests:
536  *
537  * for all vertex v1 in graph dg
538  * if statement s1 associated to v1 in region
539  * for all arcs a1 outgoing from v1
540  * let v2 be the sink of a1 and s2 the statement associated to v2
541  * if s2 in region
542  * for all conflicts c12 carried by a1
543  * if c12 has not yet been refined
544  * if c12 may have a symmetric conflict
545  * for all arcs a2 outgoing from the sink v2 of a1
546  * if sink(a2) equals v1
547  * for all conflicts c21
548  * if c21 equal c12
549  * halleluia!
550  * compute refined dependence information for c12
551  * and possibly c21
552  * possibly update c21 and possibly remove a2
553  * update c12 and possibly remove a1
554  *
555  * Good luck for the restructuring! I'm not sure the current procedure
556  * might not end up removing as a2 the very same arc a1 it uses to
557  * iterate...
558  */
559 
561  list pv1, ps, pss;
562  list llv, llv1;
563 
564  pips_assert("statement is a loop", statement_loop_p(stat));
565 
566  pips_debug(1, "Begin\n");
567 
568  if(dg_type == DG_FULL) {
569  pips_debug(1, "computing execution contexts\n");
571  }
572 
573  llv = loop_variant_list(stat);
574 
575  ifdebug(6) {
576  fprintf(stderr, "The list of loop variants is :\n");
577  MAP(ENTITY, e, fprintf(stderr," %s", entity_local_name(e)), llv);
578  fprintf(stderr, "\n");
579  }
580 
581  for (pv1 = graph_vertices(dg); pv1 != NIL; pv1 = CDR(pv1)) {
582  vertex v1 = VERTEX(CAR(pv1));
585 
586  if(!set_belong_p(region, (char *)s1))
587  continue;
588 
590 
591  ps = vertex_successors(v1);
592  pss = NIL;
593  while(ps != NIL) {
594  successor su = SUCCESSOR(CAR(ps));
595  vertex v2 = successor_vertex(su);
598  list true_conflicts = NIL;
599  list pc, pchead;
600 
601  if(!set_belong_p(region, (char *)s2)) {
602  pss = ps;
603  ps = CDR(ps);
604  continue;
605  }
606 
607  pc = dg_arc_label_conflicts(dal);
608  pchead = pc;
609  while(pc != NIL) {
610  conflict c = CONFLICT(CAR(pc));
611  effect e1 = conflict_source(c);
612  effect e2 = conflict_sink(c);
613 
614  ifdebug(4) {
615  fprintf(stderr, "dep %02td (", statement_number(s1));
616  print_words(stderr, words_effect(e1));
617  fprintf(stderr, ") --> %02td (", statement_number(s2));
618  print_words(stderr, words_effect(e2));
619  fprintf(stderr, ") \n");
620  }
621 
622  if(conflict_cone(c) != cone_undefined) {
623  /* This conflict cone has been updated. */
624  ifdebug(4) {
625  fprintf(stderr, " \nThis dependence has been computed.\n");
626  }
627  true_conflicts = gen_nconc(true_conflicts, CONS(CONFLICT, c, NIL));
628  } else { /*Compute this conflit and the opposite one */
629  list ps2su = NIL, ps2sus = NIL, pcs2s1 = NIL, pchead1 = NIL;
631  vertex v1bis;
632  statement s1bis;
635  effect e1bis = effect_undefined, e2bis = effect_undefined;
636  list levels = list_undefined;
637  list levelsop = list_undefined;
638  Ptsg gs = SG_UNDEFINED;
639  Ptsg gsop = SG_UNDEFINED;
640 
641  Finds2s1 = false;
642 
643  /*looking for the opposite dependence from (s2,e2) to
644  (s1,e1) */
645 
646  /* Make sure that you do not try to find the very same
647  * conflict: eliminate symmetric conflicts like dd's,
648  * and, if the KEEP-READ-READ-DEPENDENCE option is on,
649  * the unusual uu's.
650  */
651  if(!((s1 == s2) && (action_write_p(effect_action(e1)))
652  && (action_write_p(effect_action(e2)))) && !((s1 == s2)
653  && (action_read_p(effect_action(e1)))
654  && (action_read_p(effect_action(e2)))))
655  /* && (reference_indices(effect_any_reference(e1))) != NIL) */
656  {
657  pips_debug (4, "looking for the opposite dependence");
658 
659  ps2su = vertex_successors(v2);
660  ps2sus = NIL;
661  while(ps2su != NIL && !Finds2s1) {
662  s2su = SUCCESSOR(CAR(ps2su));
663  v1bis = successor_vertex(s2su);
664  s1bis = vertex_to_statement(v1bis);
665  if(s1bis != s1) {
666  ps2sus = ps2su;
667  ps2su = CDR(ps2su);
668  continue;
669  } else {
670  dals2s1 = (dg_arc_label)successor_arc_label(s2su);
671  pcs2s1 = dg_arc_label_conflicts(dals2s1);
672  pchead1 = pcs2s1;
673  while((pcs2s1 != NIL) && !Finds2s1) {
674  cs2s1 = CONFLICT(CAR(pcs2s1));
675  e1bis = conflict_source(cs2s1);
676  e2bis = conflict_sink(cs2s1);
677  if(e1bis == e2 && e2bis == e1) {
678  Finds2s1 = true;
679  continue;
680  } else {
681  pcs2s1 = CDR(pcs2s1);
682  continue;
683  }
684  }
685  if(!Finds2s1) {
686  ps2sus = ps2su;
687  ps2su = CDR(ps2su);
688  }
689  continue;
690  }
691  }
692 
693  /* if (!Finds2s1)
694  pips_internal_error("Expected opposite dependence are not found"); */
695 
696  if(Finds2s1) {
697  ifdebug(4) {
698  fprintf(stderr, "\n dep %02td (", statement_number(s2));
699  print_words(stderr, words_effect(e1bis));
700  fprintf(stderr, ") --> %02td (", statement_number(s1));
701  print_words(stderr, words_effect(e2bis));
702  fprintf(stderr, ") \n");
703  }
704  }
705 
706  }
707 
708  llv1 = gen_copy_seq(llv);
709  /* freed in of leaked. */
710  levels = TestCoupleOfEffects(s1,
711  e1,
712  s2,
713  e2,
714  llv1,
715  &gs,
716  &levelsop,
717  &gsop);
718 
719  /* updating DG for the dependence (s1,e1)-->(s2,e2)*/
720  if(levels == NIL) {
721  debug(4, "", "\nThe dependence (s1,e1)-->(s2,e2)"
722  " must be removed. \n");
723 
726  free_conflict(c);
727  } else {
728  debug(4, "", "\nUpdating the dependence (s1,e1)-->(s2,e2)\n");
729 
730  if(!SG_UNDEFINED_P(gs))
731  conflict_cone(c) = make_cone(levels, gs);
732  else
733  conflict_cone(c) = make_cone(levels, SG_UNDEFINED);
734  true_conflicts = gen_nconc(true_conflicts, CONS(CONFLICT, c, NIL));
735  }
736 
737  if(Finds2s1) {
738  /* updating DG for the dependence (s2,e2)-->(s1,e1)*/
739  if(levelsop == NIL) {
740  debug(4, "", "\nThe dependence (s2,e2)-->(s1,e1)"
741  " must be removed.\n");
742 
745  /*gen_free(cs2s1);*/
746 
747  if(pchead == pchead1)
748  /* They are in the same conflicts list */
749  gen_remove(&pchead, cs2s1);
750  else {
751  gen_remove(&pchead1, cs2s1);
752  if(pchead1 != NIL) {
753  dg_arc_label_conflicts(dals2s1) = pchead1;
754  successor_arc_label_(s2su) = newgen_arc_label(dals2s1);
755  } else {
756  /* This successor has only one
757  conflict that has been killed.*/successor_vertex(s2su)
761  free_successor(s2su);
762  ps2su = CDR(ps2su);
763  if(ps2sus == NIL) {
764  vertex_successors(v2) = ps2su;
765  } else {
766  CDR(ps2sus) = ps2su;
767  }
768  }
769  }
770  }
771 
772  else {
773  debug(4, "", "\nUpdating the dependence (s2,e2)-->(s1,e1)\n");
774 
775  if(!SG_UNDEFINED_P(gsop))
776  conflict_cone(cs2s1) = make_cone(levelsop, gsop);
777  else
778  conflict_cone(cs2s1) = make_cone(levelsop, SG_UNDEFINED);
779  }
780  }
781  }
782  pc = CDR(pc);
783  }
784 
785  /* gen_free_list(dg_arc_label_conflicts(dal));*/
786  if(true_conflicts != NIL) {
787  dg_arc_label_conflicts(dal) = true_conflicts;
788  pss = ps;
789  ps = CDR(ps);
790  } else {
793  free_successor(su);
794  ps = CDR(ps);
795  if(pss == NIL)
796  vertex_successors(v1) = ps;
797  else
798  CDR(pss) = ps;
799  }
800  /*ifdebug(4){ prettyprint_dependence_graph(stderr, mod_stat, dg); }*/
801  }
802  }
803 
804  ifdebug(8) {
805  pips_debug(8,"updated graph\n");
806  print_statement_set(stderr, region);
808  }
809 
811 
812  // No leak
813  gen_free_list(llv);
814 }
815 
816 
817 /*********************************************************************************/
818 /* DEPENDENCE TEST */
819 /*********************************************************************************/
820 
822  effect e1,
823  statement s2,
824  effect e2,
825  list llv, /* must be freed */
826  Ptsg * gs,
827  list * levelsop,
828  Ptsg * gsop) {
830  Psysteme sc1 = SC_UNDEFINED;
831  reference r1 = effect_any_reference( e1 );
832 
834  Psysteme sc2 = SC_UNDEFINED;
836 
837  switch(dg_type) {
838  case DG_FAST: {
839  /* use region information if some is available */
840  sc1 = effect_system(e1);
841  sc2 = effect_system(e2);
842  break;
843  }
844 
845  case DG_FULL: {
846  sc1 = load_statement_context(s1);
847  sc2 = load_statement_context(s2);
848  break;
849  }
850 
851  case DG_SEMANTICS: {
852  /* This is not correct because loop bounds should be frozen on
853  loop entry; we assume variables used in loop bounds are not
854  too often modified by the loop body */
857 
860  break;
861  }
862 
863  default:
864  pips_internal_error("Unknown dependence test %d\n", dg_type);
865  break;
866  }
867 
868  return TestCoupleOfReferences(n1,
869  sc1,
870  s1,
871  e1,
872  r1,
873  n2,
874  sc2,
875  s2,
876  e2,
877  r2,
878  llv,
879  gs,
880  levelsop,
881  gsop);
882 }
883 
884 /*
885  * This function checks if two references have memory locations in common.
886  *
887  * The problem is obvious for references to the same scalar variable.
888  *
889  * The problem is also obvious if the references are not to the same
890  * variable, except if the two variables have memory locations in common,
891  * in which case we assume there are common locations and all kind of
892  * dependences (although offsets in COMMON could be taken into account).
893  *
894  * When both references are to the same array variable, the function
895  * TestDependence() is called.
896  *
897  * FI: When both references are relative to the same pointer variable, the
898  * variable value is *assumed* to be the same in the two statements and
899  * the function TestDependence() is called. Transformers on pointers
900  * should be used to check that the pointer value is constant. The
901  * simplest transformer would be the written memory effects for the
902  * common enclosing loop.
903  */
904 
906  Psysteme sc1 __attribute__ ((unused)),
907  statement s1,
908  effect ef1,
909  reference r1,
910  list n2,
911  Psysteme sc2 __attribute__ ((unused)),
912  statement s2,
913  effect ef2,
914  reference r2,
915  list llv,
916  Ptsg * gs __attribute__ ((unused)),
917  list * levelsop __attribute__ ((unused)),
918  Ptsg * gsop __attribute__ ((unused))) {
919  _int i, cl, dims, ty;
920  list levels = NIL, levels1 = NIL;
921 
922  entity e1 = reference_variable(r1);
923  entity e2 = reference_variable(r2);
924 
925  list b1 = reference_indices(r1);
926  list b2 = reference_indices(r2);
927 
928  type t1 = ultimate_type(entity_type(e1));
929 
930  if(e1 != e2) {
931  ifdebug(1) {
932  fprintf(stderr, "dep %02td (", statement_number(s1));
933  print_words(stderr, words_effect(ef1));
934  fprintf(stderr, ") --> %02td (", statement_number(s2));
935  print_words(stderr, words_effect(ef2));
936  fprintf(stderr, ") \n");
937  }
938  pips_user_warning("Dependence between differents variables: "
939  "%s and %s\nDependence assumed\n",
941  }
942 
943  /* if (e1 == e2 && !entity_scalar_p(e1) && !entity_scalar_p(e2)) */
944  /* FI: Why have two tests under the condition e1==e2? */
945 
946  /* FI: this test must be modified to take pointer dereferencing
947  * such as p[i] into account, although p as an entity generates
948  * atomic references.
949  *
950  * If chains.c were updated, we could also check that:
951  * gen_length(b1)==gen_length(b2).
952  */
953  if(e1 == e2 && !entity_all_locations_p(e1) && !entity_all_locations_p(e2)
955  && gen_length(b1) > 0))) {
956  if(get_bool_property("RICEDG_STATISTICS_ALL_ARRAYS")) {
957  NbrArrayDepInit++;
958  } else {
959  if(b1 != NIL && b2 != NIL)
960  NbrArrayDepInit++;
961  }
962 
963  if(b1 == NIL || b2 == NIL) {
964  /* A(*) reference appears in the dependence graph */
965  cl = FindMaximumCommonLevel(n1, n2);
966 
967  for (i = 1; i <= cl; i++)
968  levels = gen_nconc(levels, CONS(INT, i, NIL));
969 
971  levels = gen_nconc(levels, CONS(INT, cl+1, NIL));
972 
973  if(Finds2s1) {
974  for (i = 1; i <= cl; i++)
975  levels1 = gen_nconc(levels1, CONS(INT, i, NIL));
976 
978  levels1 = gen_nconc(levels1, CONS(INT, cl+1, NIL));
979 
980  *levelsop = levels1;
981  }
982 
983  gen_free_list(llv);
984  } else {
985  /* llv is freed here */
986  levels = TestDependence(n1,
987  sc1,
988  s1,
989  ef1,
990  r1,
991  n2,
992  sc2,
993  s2,
994  ef2,
995  r2,
996  llv,
997  gs,
998  levelsop,
999  gsop);
1000  }
1001 
1002  if(get_bool_property("RICEDG_STATISTICS_ALL_ARRAYS") || (b1 != NIL && b2
1003  != NIL)) {
1004  if(levels != NIL) {
1005  /* test the dependence type, constant dependence? */
1006  dims = gen_length(b1);
1007  ty = dep_type(effect_action(ef1), effect_action(ef2));
1008  deptype[dims][ty]++;
1009  if(is_dep_cnst) {
1010  NbrDepCnst++;
1011  constdep[dims][ty]++;
1012  }
1013  }
1014 
1015  if(*levelsop != NIL) {
1016  /* test the dependence type, constant dependence?
1017  exact dependence? */
1018  dims = gen_length(b1);
1019  ty = dep_type(effect_action(ef2), effect_action(ef1));
1020  deptype[dims][ty]++;
1021  if(is_dep_cnst) {
1022  NbrDepCnst++;
1023  constdep[dims][ty]++;
1024  }
1025  }
1026 
1027  if(levels != NIL || *levelsop != NIL) {
1028  if(is_test_exact)
1029  NbrTestExact++;
1030  else {
1031  if(is_test_inexact_eq) {
1032  if(is_test_inexact_fm)
1033  NbrDepInexactEFM++;
1034  else
1035  NbrDepInexactEq++;
1036  } else
1037  NbrDepInexactFM++;
1038  }
1039  }
1040 
1041  ifdebug(6) {
1042  if(is_test_exact)
1043  fprintf(stderr, "\nThis test is exact! \n");
1044  else if(is_test_inexact_eq)
1045  fprintf(stderr, "\nTest not exact : "
1046  "non-exact elimination of equation!");
1047  else
1048  fprintf(stderr, "\nTest not exact : "
1049  "non-exact elimination of F-M!");
1050  }
1051  }
1052 
1053  return (levels);
1054  } else {
1055  /* the case of scalar variables and equivalenced arrays */
1056 
1057  // llv is no longer used
1058  gen_free_list(llv);
1059 
1060  cl = FindMaximumCommonLevel(n1, n2);
1061 
1062  for (i = 1; i <= cl; i++)
1063  levels = gen_nconc(levels, CONS(INT, i, NIL));
1064 
1065  if(statement_possible_less_p(s1, s2))
1066  levels = gen_nconc(levels, CONS(INT, cl+1, NIL));
1067 
1070  NbrIndexDep++;
1071  else {/*scalar variable dependence */
1072  NbrScalDep++;
1073  ty = dep_type(effect_action(ef1), effect_action(ef2));
1074  deptype[0][ty]++;
1075  }
1076 
1077  if(Finds2s1) {
1078  for (i = 1; i <= cl; i++)
1079  levels1 = gen_nconc(levels1, CONS(INT, i, NIL));
1080 
1081  if(statement_possible_less_p(s2, s1))
1082  levels1 = gen_nconc(levels1, CONS(INT, cl+1, NIL));
1083 
1084  *levelsop = levels1;
1087  NbrIndexDep++;
1088  else {/*case of scalar variable dependence */
1089  NbrScalDep++;
1090  ty = dep_type(effect_action(ef2), effect_action(ef1));
1091  deptype[0][ty]++;
1092  }
1093  }
1094 
1095  return (levels);
1096  }
1097 }
1098 
1099 /* static list TestDependence(list n1, n2, Psysteme sc1, sc2,
1100  * statement s1, s2, effect ef1, ef2,
1101  * reference r1, r2, list llv,
1102  * list *levelsop, Ptsg *gs,*gsop)
1103  * input :
1104  * list n1, n2 : enclosing loops for statements s1 and s2;
1105  * Psysteme sc1, sc2: current context for each statement;
1106  * statement s1, s2 : currently analyzed statements;
1107  * effect ef1, ef2 : effects of each statement upon the current variable;
1108  * (maybe array regions)
1109  * reference r1, r2 : current variables references;
1110  * list llv : loop variant list
1111  * (variables that vary in loop nests n1 and n2?);
1112  * list *levelsop : dependence levels from s2 to s1
1113  * Ptsg *gs,*gsop : dependence cones from s1 to s2 and from s2 to s1
1114  * output : dependence levels from s1 to s2
1115  * modifies : levelsop, gsop, gs and returns levels
1116  *
1117  * Comments :
1118  *
1119  * This procedure has been amplified twice. The initial procedure
1120  * only computed the dependence levels, "levels", for conflict s1->s2.
1121  * The dependence cone computation was added by Yi-Qing Yang. She later
1122  * added the computation of the dependence levels and the dependence cone
1123  * for symetrical conflict, s2 -> s1, because both conflicts share the
1124  * same dependence system and because a set of tests can be shared.
1125  *
1126  * For her PhD, Yi-Qing Yang also added intermediate tests and instrumentation.
1127  *
1128  * This much too long procedure is made of three parts:
1129  * 0. The initialization of the dependence system
1130  * 1. A set of feasibility tests applied to the dependence system
1131  * 2. The computation of levels and cone for s1->s2
1132  * 3. The very same computation for s2->s1
1133  *
1134  * Modification :
1135  *
1136  * - ajout des tests de faisabilites pour le systeme initial,
1137  * avant la projection. Yi-Qing (18/10/91)
1138  *
1139  * - decoupage de la procedure par Beatrice Creusillet
1140  *
1141  * - (indirect) build_and_test_dependence_context(), in fact system, no
1142  * longer has side effects on sc1 and sc2 thru sc_normalize(); FI (12/12/95)
1143  *
1144  * - sc_rm() uncommented out after call to gcd_and_constant_dependence_test()
1145  *
1146  * - base_rm(tmp_base) added after call to sc_proj_optim_on_di_ofl() just
1147  * before returning with levels==NIL
1148  *
1149  * - sc_rm() added for dep_syst, dep_syst1, dep_syst_op and dep_syst2
1150  */
1152  Psysteme sc1,
1153  statement s1,
1154  effect ef1,
1155  reference r1,
1156  list n2,
1157  Psysteme sc2,
1158  statement s2,
1159  effect ef2,
1160  reference r2,
1161  list llv,
1162  Ptsg * gs,
1163  list * levelsop,
1164  Ptsg * gsop) {
1165  Psysteme dep_syst = SC_UNDEFINED;
1166  Psysteme dep_syst1 = SC_UNDEFINED;
1167  Psysteme dep_syst2 = SC_UNDEFINED;
1168  volatile Psysteme dep_syst_op = SC_UNDEFINED;
1169  Pbase b, coord;
1170  /* Automatic variables read in a CATCH block need to be declared volatile as
1171  * specified by the documentation*/
1172  Pbase volatile tmp_base;
1173 
1174  int l, cl;
1175  list levels;
1176  Pvecteur DiIncNonCons = NULL;
1177 
1178  /* Elimination of loop indices from loop variants llv */
1179  /* We use n2 because we take care of variables modified in
1180  an iteration only for the second system. */
1181  FOREACH(STATEMENT, s, n2) {
1183  gen_remove(&llv,i); /* llv is dead, must be freed... */
1184  }
1185 
1186  ifdebug(6) {
1187  pips_debug(6, "loop variants after removing loop indices :\n");
1188  print_arguments(llv);
1189  }
1190 
1191  /* Build the dependence context system from the two initial context systems
1192  * sc1 and sc2. BC
1193  */
1194  if(!build_and_test_dependence_context(r1, r2, sc1, sc2, &dep_syst, llv, n2)) {
1195  /* the context system is not feasible : no dependence. BC */
1196  /* No dep_syst() to deallocate either, FI */
1197  NbrIndepFind++;
1198  pips_debug(4, "context system not feasible\n");
1199  *levelsop = NIL;
1200 
1201  gen_free_list(llv);
1202  return NIL;
1203  }
1204 
1205  /* Further construction of the dependence system; Constant and GCD tests
1206  * at the same time.
1207  */
1208 
1209  // FI: why is dep_syst only weekly consistent here?
1210  assert(sc_weak_consistent_p(dep_syst));
1211 
1212  if(gcd_and_constant_dependence_test(r1, r2, llv, n2, &dep_syst)) {
1213  /* independence proved */
1214  /* FI: the next statement was commented out... */
1215  sc_rm(dep_syst);
1216  NbrIndepFind++;
1217  *levelsop = NIL;
1218 
1219  gen_free_list(llv);
1220  return NIL;
1221  }
1222 
1223  pips_assert("The dependence system is consistent", sc_consistent_p(dep_syst));
1224 
1225  gen_free_list(llv);
1226 
1227  dependence_system_add_lci_and_di(&dep_syst, n1, &DiIncNonCons);
1228 
1229  ifdebug(6) {
1230  fprintf(stderr, "\ninitial system is:\n");
1231  sc_syst_debug(dep_syst);
1232  }
1233 
1234  pips_assert("The dependence system is consistent", sc_consistent_p(dep_syst));
1235 
1236  /* Consistency Test */
1237  if(sc_empty_p(dep_syst = sc_normalize(dep_syst))) {
1238  sc_rm(dep_syst);
1239  NbrTestSimple++;
1240  NbrIndepFind++;
1241  pips_debug(4, "initial normalized system not feasible\n");
1242  *levelsop = NIL;
1243 
1244  return (NIL);
1245  }
1246 
1247  cl = FindMaximumCommonLevel(n1, n2);
1248 
1249  pips_assert("The dependence system is consistent", sc_consistent_p(dep_syst));
1250 
1251  if(TestDiCnst(dep_syst, cl, s1, ef1, s2, ef2) == true) {
1252  /* find independences (non loop carried dependence, intra-statement).*/
1253  /* Such dependences are counted here as independence, but other
1254  * parallelizer preserve them because they are useful for
1255  * (assembly) instructon level scheduling
1256  */
1257  NbrTestDiCnst++;
1258  NbrIndepFind++;
1259  pips_debug(4,"\nTestDiCnst succeeded!\n");
1260  *levelsop = NIL;
1261 
1262  return (NIL);
1263  }
1264 
1265  pips_assert("The dependence system is consistent", sc_consistent_p(dep_syst));
1266 
1267  is_test_exact = true;
1268  is_test_inexact_eq = false;
1269  is_test_inexact_fm = false;
1270  is_dep_cnst = false;
1271 
1272  tmp_base = base_dup(dep_syst->base);
1273 
1275  /* Some kind of arithmetic error, e.g. an integer overflow
1276  * has occured. Assume dependence to be conservative.
1277  */
1278  Pbase dep_syst_base = BASE_UNDEFINED;
1279 
1280  /* FI: wouldn't it be simpler to enumerate the useful di
1281  * variables?!?
1282  */
1283  /* eliminate non di variables from the basis */
1284  for (coord = tmp_base; !VECTEUR_NUL_P(coord); coord = coord->succ) {
1285  Variable v = vecteur_var(coord);
1286  l = DiVarLevel((entity)v);
1287  if(l <= 0 || l > cl)
1288  base_add_variable(dep_syst_base, v);
1289  }
1290  dep_syst = sc_rn(dep_syst_base);
1291  } TRY {
1292  if(sc_proj_optim_on_di_ofl(cl, &dep_syst) == false) {
1293  pips_debug(4,
1294  "projected system by sc_proj_optim_on_di() is not feasible\n");
1295  sc_rm(dep_syst);
1296  NbrIndepFind++;
1297  *levelsop = NIL;
1298 
1300  base_rm(tmp_base);
1301  return (NIL);
1302  } else
1304  }
1305 
1306  ifdebug(6) {
1307  fprintf(stderr, "projected system is:\n");
1308  sc_syst_debug(dep_syst);
1309  }
1310 
1311  pips_assert("The dependence system is consistent", sc_consistent_p(dep_syst));
1312 
1313  base_rm(tmp_base); // FI: delayed to help with debugging
1314 
1315  if(!sc_faisabilite_optim(dep_syst)) {
1316  /* Here, the long jump overflow buffer is handled at a lower level! */pips_debug(4, "projected system not feasible\n");
1317  NbrIndepFind++;
1318  *levelsop = NIL;
1319 
1320  return (NIL);
1321  }
1322 
1323  ifdebug(6) {
1324  fprintf(stderr, "normalised projected system is:\n");
1325  sc_syst_debug(dep_syst);
1326  fprintf(stderr, "The list of DiIncNonCons is :\n");
1327  vect_debug(DiIncNonCons);
1328  }
1329 
1330  /* keep DiIncNonCons variables if their value is unknown or different
1331  * from zero. Otherwise eliminate them from the dep_syst
1332  *
1333  * FI: I'm lost for this step. My guess DiIncNonCons==VECTEUR_NUL
1334  * in 99.99 % of all cases...
1335  */
1336  if(dep_syst != NULL) {
1337  while(DiIncNonCons != NULL) {
1338  Variable di;
1339  Value val;
1340 
1341  di = DiIncNonCons->var;
1342  if(sc_value_of_variable(dep_syst, di, &val) == true)
1343  if(value_notzero_p(val)) {
1344  sc_elim_var(dep_syst, di);
1345  }
1346  DiIncNonCons = DiIncNonCons->succ;
1347  }
1348  }
1349 
1350  ifdebug(4) {
1351  fprintf(stderr,
1352  "normalised projected system after DiIncNonCons elimination is:\n");
1353  sc_syst_debug(dep_syst);
1354  }
1355 
1356  /* Compute the levels for dependence arc s1 to s2 and of the opposite
1357  * dependence arc s2 to s1. Also compute the dependence cones if some
1358  * level exists (FI: shouldn't it be a loop-carried level?).
1359  *
1360  * For both cases, two systems are allocated, one is used to find the
1361  * dependence levels, the other one to compute the dependence cone.
1362  *
1363  * For s1->s2, dep_syst is used to compute the levels and dep_syst1
1364  * the cone.
1365  *
1366  * For s2->s1, dep_syst_op (op==oppposite) is used to find the dependence
1367  * levels, and dep_syst2 the dependence cone.
1368  */
1369 
1370  /* Build the dependence system for the opposite arc s2->s1
1371  * before dep_syst is modified
1372  */
1373 
1374  *levelsop = NIL;
1375  if(Finds2s1)
1376  dep_syst_op = sc_invers(sc_dup(dep_syst));
1377 
1378  /* Start processing for arc s1->s2 */
1379 
1380  ifdebug(4) {
1381  debug(4, "", "\nComputes the levels and DC for dep: (s1,e1)->(s2,e2)\n");
1382  fprintf(stderr, "\nThe distance system for dep is:\n");
1383  sc_syst_debug(dep_syst);
1384  }
1385 
1386  /* Make a proper copy of dep_syst before it is destroyed to compute
1387  * dependence levels. The basis must be in a specific order to check
1388  * lexico-positivity.
1389  */
1390  dep_syst1 = sc_dup(dep_syst);
1391  b = MakeDibaseinorder(cl);
1392  base_rm(dep_syst1->base);
1393  dep_syst1->base = b;
1394  dep_syst1->dimension = cl;
1395 
1396  if(dep_syst1->dimension == dep_syst1->nb_eq)
1397  is_dep_cnst = true;
1398 
1399  /* Compute dependence levels for s1->s2 */
1400  levels = TestDiVariables(dep_syst, cl, s1, ef1, s2, ef2);
1401  /* dep_syst is unfeasible or almost empty, and now useless */
1402  sc_rm(dep_syst);
1403 
1404  /* if (levels == NIL) NbrTestDiVar++; Qui l'a enleve', pourquoi ? */
1405 
1406  if(levels != NIL) {
1407 
1408  *gs = dependence_cone_positive(dep_syst1);
1409 
1410  /* If the cone is not feasible, there are no loop-carried dependences.
1411  * (FI: the cone is strictly positive then...)
1412  *
1413  * This might not havebeen found by the previous test when computing
1414  * levels.
1415  *
1416  * But the dependence cone construction does not consider non-loop
1417  * carried dependences; so we can only remove those levels that are
1418  * smaller than the number of common levels
1419  */
1420  if(sg_empty(*gs)) {
1421  list l_tmp = levels;
1422  bool ok = false;
1423 
1424  pips_debug(5, "dependence cone not feasible\n");
1425  MAP(INT, ll, {if (ll == cl+1) ok = true;}, l_tmp);
1426 
1427  if(ok) {
1428  pips_debug(5, "innermost level found and kept\n");
1429  levels = CONS(INT, cl+1, NIL);
1430  } else {
1431  pips_debug(5, "innermost level not found, no dependences");
1432  levels = NIL;
1433  }
1434  gen_free_list(l_tmp);
1435  sg_rm(*gs);
1436  *gs = SG_UNDEFINED;
1437  }
1438  }
1439  sc_rm(dep_syst1);
1440 
1441  /* print results for arc s1->s2 */
1442 
1443  ifdebug(4) {
1444  fprintf(stderr, "\nThe levels for dep (s1,s2) are:");
1445  MAP(INT, pl,
1446  {
1447  fprintf(stderr, " %d", pl);
1448  }, levels);
1449 
1450  if(!SG_UNDEFINED_P(*gs)) {
1451  fprintf(stderr, "\nThe lexico-positive dependence cone for"
1452  " dep (s1,s2) :\n");
1453  print_dependence_cone(stderr, *gs, b);
1454  } else
1455  fprintf(stderr, "\nLexico-positive dependence cone"
1456  " doesn't exist for dep (s1,s2).\n");
1457  }
1458 
1459  /* Start the processing for arc s2->s1 */
1460 
1461  if(Finds2s1) {
1462 
1463  pips_debug(4,"Computes the levels and DC for dep_op: (s2,e2)->(s1,e1)\n");
1464  ifdebug(4) {
1465  fprintf(stderr, "\nThe invers distance system for dep_op is:\n");
1466  sc_syst_debug(dep_syst_op);
1467  }
1468 
1469  dep_syst2 = sc_dup(dep_syst_op);
1470  b = MakeDibaseinorder(cl);
1471  base_rm(dep_syst2->base);
1472  dep_syst2->base = b;
1473  dep_syst2->dimension = cl;
1474 
1475  *levelsop = TestDiVariables(dep_syst_op, cl, s2, ef2, s1, ef1);
1476  sc_rm(dep_syst_op);
1477  if(*levelsop != NIL) {
1478  /* if (*levelsop == NIL) NbrTestDiVar++; Pourquoi? */
1479  *gsop = dependence_cone_positive(dep_syst2);
1480  sc_rm(dep_syst2);
1481 
1482  /* if the cone is not feasible, there are no loop-carried dependences;
1483  * this was not found by the previous test when computing levels;
1484  * but the dependence cone construction does not consider non-loop
1485  * carried dependences; so we can only remove those levels that are
1486  * smaller than the number of common levels
1487  */
1488  if(sg_empty(*gsop)) {
1489  list l_tmp = *levelsop;
1490  bool ok = false;
1491 
1492  MAP(INT, ll, {if (ll == cl+1) ok = true;}, l_tmp);
1493 
1494  if(ok) {
1495  *levelsop = CONS(INT, cl+1, NIL);
1496  } else {
1497  *levelsop = NIL;
1498  }
1499  gen_free_list(l_tmp);
1500  sg_rm(*gsop);
1501  *gsop = SG_UNDEFINED;
1502  }
1503  }
1504 
1505  ifdebug(4) {
1506  fprintf(stderr, "\nThe levels for dep_op (s2,s1) is:");
1507  MAP(INT, pl,
1508  {
1509  fprintf(stderr, " %d", pl);
1510  }, *levelsop);
1511 
1512  if(!SG_UNDEFINED_P(*gsop)) {
1513  fprintf(stderr, "\nThe lexico-positive Dependence "
1514  "cone for dep_op (s2,s1):\n");
1515  print_dependence_cone(stderr, *gsop, b);
1516  } else
1517  fprintf(stderr, "\nLexico-positive dependence cone "
1518  "does not exist for dep_op (s2,s1).\n");
1519 
1520  }
1521  }
1522 
1523  if(levels == NIL && *levelsop == NIL) {
1524  NbrTestDiVar++;
1525  NbrIndepFind++;
1526  if(s1 == s2) {
1527  /* the case of "all equals" independence at the same statement*/
1528  NbrAllEquals++;
1529  }
1530 
1531  return (NIL);
1532  }
1533 
1534  return (levels);
1535 }
1536 
1537 
1538 /* static bool build_and_test_dependence_context(reference r1, r2,
1539  * Psystem sc1, sc2, *psc_dep,
1540  * list llv, s2_enc_loops)
1541  * input :
1542  * reference r1, r2 : current array references;
1543  * Psystem sc1, sc2 : context systems for r1 and r2;
1544  * they might be modified and even be freed (!)
1545  * by normalization procedures
1546  * Psystem *psc_dep : pointer toward the dependence context systeme;
1547  * list llv : current loop nest variant list;
1548  * list s2_enc_loops : statement s2 enclosing loops;
1549  *
1550  * output :
1551  * bool : false if one of the initial systems is unfeasible
1552  * after normalization;
1553  * true otherwise;
1554  * *psc_dep : dependence system is the function value is true;
1555  * SC_EMPTY otherwise; no need to sc_rm() in the
1556  * latter case.
1557  *
1558  * side effects :
1559  * psc_dep : points toward the dependence context system built
1560  * from sc1 and sc2, r1 and r2, and llv.
1561  * Dependence distance variables (di) are introduced
1562  * in sc2, along with the dsi variables to take care
1563  * of variables in llv
1564  * modified in the loop nest;
1565  * irrelevant (?) existencial constraints are removed.
1566  * in order to make further manipulations easier.
1567  * sc1 : side_effect of sc_normalize()
1568  * sc2 : side_effect of sc_normalize()
1569  *
1570  * Comment :
1571  *
1572  * Modifications:
1573  * - sc1 and sc2 cannot be sc_normalized because they may be part of
1574  * statement preconditions or regions; sc_normalize() is replaced by
1575  * sc_empty_p(); since regions and preconditions are normalized with
1576  * stronger normalization procedure, and since the feasibility of the
1577  * dependence test will be tested with an even stronger test, this
1578  * should have no accuracy impact (FI, 12 December 1995)
1579  */
1581  reference r2,
1582  Psysteme sc1,
1583  Psysteme sc2,
1584  Psysteme * psc_dep,
1585  list llv,
1586  list s2_enc_loops) {
1587  Psysteme sc_dep, sc_tmp;
1588  list pc;
1589  int l, inc;
1590 
1591  /* *psc_dep must be undefined */pips_assert("build_and_test_dependence_context", SC_UNDEFINED_P(*psc_dep));
1592 
1593  /* Construction of initial systems sc_dep and sc_tmp from sc1 and sc2
1594  if not undefined
1595  */
1596  if(SC_UNDEFINED_P(sc1) && SC_UNDEFINED_P(sc2)) {
1597  sc_dep = sc_new();
1598  } else {
1599  if(SC_UNDEFINED_P(sc1))
1600  sc_dep = sc_new();
1601  else {
1602  /* sc_dep = sc1, but:
1603  * we keep only useful constraints in the predicate
1604  * (To avoid overflow errors, and to make projections easier)
1605  */
1607 
1608  if(sc_empty_p(sc1)) {
1609  *psc_dep = SC_EMPTY;
1610  pips_debug(4,
1611  "first initial normalized system sc1 not feasible\n");
1612  return (false);
1613  }
1614 
1615  ifdebug(6) {
1616  debug(6, "", "Initial system sc1 before restrictions : \n");
1617  sc_syst_debug(sc1);
1618  }
1619 
1621  normalized x1 = NORMALIZE_EXPRESSION(ex1);
1622 
1623  if(normalized_linear_p(x1)) {
1624  Pvecteur v1;
1625  Pvecteur v;
1626  v1 = (Pvecteur)normalized_linear(x1);
1627  for (v = v1; !VECTEUR_NUL_P(v); v = v->succ) {
1628  if(vecteur_var(v) != TCST)
1630  }
1631  }
1632  }
1633 
1635  }
1636 
1637  if(SC_UNDEFINED_P(sc2))
1638  sc_tmp = sc_new();
1639  else {
1640  /* sc_tmp = sc2, but:
1641  * we keep only useful constraints in the predicate
1642  * (To avoid overflow errors, and to make projections easier)
1643  *
1644  * FI: I'm not sure this is correct. I'm afraid sc2 might
1645  * be unfeasible and become feasible due to a careless
1646  * elimination... It all depends on:
1647  *
1648  * sc_restricted_to_variables_transitive_closure()
1649  *
1650  * There might be a better function for that purpose
1651  */
1653 
1654  if(sc_empty_p(sc2)) {
1655  *psc_dep = SC_EMPTY;
1656  pips_debug(4,
1657  "second initial normalized system not feasible\n");
1658  return (false);
1659  }
1660 
1661  ifdebug(6) {
1662  debug(6, "", "Initial system sc2 before restrictions : \n");
1663  sc_syst_debug(sc2);
1664  }
1665 
1666  FOREACH(EXPRESSION, ex2, reference_indices(r2)) {
1667  normalized x2 = NORMALIZE_EXPRESSION(ex2);
1668 
1669  if(normalized_linear_p(x2)) {
1670  Pvecteur v2;
1671  Pvecteur v;
1672 
1673  v2 = (Pvecteur)normalized_linear(x2);
1674  for (v = v2; !VECTEUR_NUL_P(v); v = v->succ) {
1675  if(vecteur_var(v) != TCST)
1677  }
1678 
1679  }
1680  }
1681 
1682 
1684  }
1685 
1686  ifdebug(6) {
1687  debug(6, "", "Initial systems after restrictions : \n");
1688  sc_syst_debug(sc_dep);
1689  sc_syst_debug(sc_tmp);
1690  }
1691 
1692  /* introduce dependence distance variable if loop increment value
1693  is known or ... */
1694  for (pc = s2_enc_loops, l = 1; pc != NIL; pc = CDR(pc), l++) {
1695  loop lo = statement_loop(STATEMENT(CAR(pc)));
1696  entity i2 = loop_index(lo);
1697  /* FI: a more powerful evaluation function for inc should be called
1698  * when preconditions are available. For instance, mdg could
1699  * be handled without having to partial_evaluate it
1700  *
1701  * It's not clear whether sc1 or sc2 should be used to
1702  * estimate a variable increment like N.
1703  *
1704  * It's not clear whether it's correct or not. You would like
1705  * N (or other variables in the increment expression) to be
1706  * constant within the loop nest.
1707  *
1708  * It would be better to know the precondition associated
1709  * to the corresponding loop statement, but the information
1710  * is lost in this low-level function.
1711  *
1712  * FI: this is not true, you have sc1 and sc2 at hand to call
1713  * sc_minmax_of_variable()
1714  */
1715  inc = loop_increment_value(lo);
1716  if(inc != 0)
1717  sc_add_di(l, i2, sc_tmp, inc);
1718  else
1719  sc_chg_var(sc_tmp, (Variable)i2, (Variable)GetLiVar(l));
1720  }
1721 
1722  /* take care of variables modified in the loop */
1723  for (pc = llv, l = 1; pc != NIL; pc = CDR(pc), l++) {
1724  sc_add_dsi(l, ENTITY(CAR(pc)), sc_tmp);
1725  }
1726 
1727  /* sc_tmp is emptied and freed by sc_fusion() */
1728  sc_dep = sc_fusion(sc_dep, sc_tmp);
1729  vect_rm(sc_dep->base);
1730  sc_dep->base = BASE_NULLE;
1731  sc_creer_base(sc_dep);
1732 
1733  }
1734 
1735  ifdebug(6) {
1736  pips_debug(6,
1737  "\ndependence context is:\n");
1738  sc_syst_debug(sc_dep);
1739  }
1740 
1741  *psc_dep = sc_dep;
1742  return (true);
1743 }
1744 
1745 /* static bool gcd_and_constant_dependence_test(references r1, r2,
1746  * list llv, s2_enc_loops,
1747  * Psysteme *psc_dep)
1748  * input :
1749  * references r1, r2 : current references;
1750  * list llv : loop nest variant list;
1751  * list s2_enc_loops : enclosing loops for statement s2;
1752  * Psysteme *psc_dep : pointer toward the depedence system;
1753  * output : true if there is no dependence (GCD and constant test successful);
1754  * false if independence could not be proved.
1755  * modifies : *psc_dep; at least adds dependence equations on phi variables
1756  * comment :
1757  * - *psc_dep must be defined on entry; it must have been initialized
1758  * by build_and_test_dependence_context.
1759  * - no side effects on r1, r2,...
1760  */
1762  reference r2,
1763  list llv,
1764  list s2_enc_loops,
1765  Psysteme * psc_dep) {
1766  list pc1, pc2, pc;
1767  int l;
1768 
1769  /* Further construction of the dependence system; Constant and GCD tests
1770  * at the same time.
1771  */
1772  pc1 = reference_indices(r1);
1773  pc2 = reference_indices(r2);
1774 
1775  while(pc1 != NIL && pc2 != NIL) {
1776  expression ex1, ex2;
1777  normalized x1, x2;
1778 
1779  ex1 = EXPRESSION(CAR(pc1));
1780  x1 = NORMALIZE_EXPRESSION(ex1);
1781 
1782  ex2 = EXPRESSION(CAR(pc2));
1783  x2 = NORMALIZE_EXPRESSION(ex2);
1784 
1785  if(normalized_linear_p(x1) && normalized_linear_p(x2)) {
1786  Pvecteur v1, v2, v;
1787 
1788  v1 = (Pvecteur)normalized_linear(x1);
1789  v2 = vect_dup((Pvecteur)normalized_linear(x2));
1790 
1791  for (pc = s2_enc_loops, l = 1; pc != NIL; pc = CDR(pc), l++) {
1792  loop lo = statement_loop(STATEMENT(CAR(pc)));
1793  entity i = loop_index(lo);
1794  int li = loop_increment_value(lo);
1795  Value vli = int_to_value(li);
1796  if(value_notzero_p(vli)) {
1797  Value v = vect_coeff((Variable)i, v2);
1798  value_product(v,vli);
1799  vect_add_elem(&v2, (Variable)GetDiVar(l), v);
1800  } else
1801  vect_chg_var(&v2, (Variable)i, (Variable)GetLiVar(l));
1802  }
1803 
1804  for (pc = llv, l = 1; pc != NIL; pc = CDR(pc), l++) {
1805  vect_add_elem(&v2,
1806  (Variable)GetDsiVar(l),
1807  vect_coeff((Variable)ENTITY(CAR(pc)), v2));
1808  }
1809 
1810  if(!VECTEUR_UNDEFINED_P(v = vect_substract(v1, v2))) {
1812 
1813  /* case of T(3)=... et T(4)=... */
1815  NbrTestCnst++;
1816  pips_debug(4,"TestCnst succeeded!");
1817  return (true);
1818  }
1819  /* test of GCD */
1820  if(egalite_normalize(c) == false) {
1821  NbrTestGcd++;
1822  pips_debug(4,"TestGcd succeeded!\n");
1823  return (true);
1824  }
1825  sc_add_eg(*psc_dep, c);
1826  }
1827  vect_rm(v2);
1828  }
1829 
1830  pc1 = CDR(pc1);
1831  pc2 = CDR(pc2);
1832  }
1833 
1834  if(pc1 != NIL || pc2 != NIL) {
1836  pips_internal_error("numbers of subscript expressions differ");
1837  } else {
1838  /* C assumed */
1839  pips_user_warning("dependence tested between two memory access paths"
1840  " of different lengths for variable \"%s\".\n",
1842  }
1843  }
1844 
1845  /* Update base of *psc_dep */
1846  Pbase mb = sc_to_minimal_basis(*psc_dep);
1847  Pbase cb = sc_base(*psc_dep);
1848  if(!vect_in_basis_p(mb, cb)) {
1849  Pbase nb = base_union(cb, mb);
1850  sc_base(*psc_dep) = nb;
1851  sc_dimension(*psc_dep) = vect_size(nb); // base_dimension(nb);
1852  vect_rm(cb);
1853  }
1854  vect_rm(mb);
1855 
1856  pips_assert("The dependence system is consistent", sc_consistent_p(*psc_dep));
1857 
1858  return (false);
1859 }
1860 
1861 /* static void dependence_system_add_lci_and_di(Psysteme *psc_dep,
1862  * list s1_enc_loops,
1863  * Pvecteur *p_DiIncNonCons)
1864  * input :
1865  * Psysteme *psc_dep : pointer toward the dependence system;
1866  * list s1_enc_loops : statement s1 enclosing loops;
1867  * Pvecteur *p_DiIncNonCons : pointer toward DiIncNonCons.
1868  *
1869  * output : none
1870  *
1871  * modifies :
1872  *
1873  * *psc_dep, the dependence systeme (addition of constraints with lci and di
1874  * variables, if useful; lci is a loop counter, di an iteration
1875  * difference variable);
1876  *
1877  * DiIncNonCons: di variables are added to DiIncNonCons (means Di variables
1878  * for loops with non constant increment, i.e. unknown increment),
1879  * if any such loop exists.
1880  *
1881  * comment : DiIncNonCons must be undefined on entry.
1882  */
1884  s1_enc_loops,
1885  p_DiIncNonCons)
1886  Psysteme *psc_dep;list s1_enc_loops;Pvecteur *p_DiIncNonCons; {
1887  int l;
1888  list pc;
1889 
1890  pips_assert("dependence_system_add_lci_and_di",
1891  VECTEUR_UNDEFINED_P(*p_DiIncNonCons));
1892 
1893  /* Addition of lck, the loop counters, and di, the iteration difference,
1894  * variables (if useful).
1895  */
1896  for (pc = s1_enc_loops, l = 1; pc != NIL; pc = CDR(pc), l++) {
1897  loop lo = statement_loop(STATEMENT(CAR(pc)));
1898  entity ind = loop_index(lo);
1899  int inc = loop_increment_value(lo);
1900 
1901  expression lb = range_lower(loop_range(lo));
1903 
1904  /* If the loop increment is not trivial, express the current
1905  * index value as the sum of the lower bound and the product
1906  * of the loop counter by the loop increment.
1907  *
1908  * Else, this new equation would be redundant
1909  */
1910  /* make nl + inc*lc# - ind = 0 */
1911  if(inc != 0 && inc != 1 && inc != -1 && normalized_linear_p(nl)) {
1912  Pcontrainte pc;
1913  entity lc;
1914  Pvecteur pv;
1915 
1916  lc = MakeLoopCounter();
1917  pv = vect_dup((Pvecteur)normalized_linear(nl));
1918  vect_add_elem(&pv, (Variable)lc, inc);
1919  vect_add_elem(&pv, (Variable)ind, -1);
1920  pc = contrainte_make(pv);
1921  sc_add_eg(*psc_dep, pc);
1922  }
1923 
1924  /* If the loop increment is unknown, which is expressed by inc==0,
1925  * well, I do not understand what li variables are, not how they work
1926  */
1927  /* make d#i - l#i + ind = 0 ,
1928  add d#i in list of DiIncNonCons*/
1929  if(inc == 0) {
1930  Pcontrainte pc;
1931  Pvecteur pv = NULL;
1932  entity di;
1933 
1934  di = GetDiVar(l);
1935  vect_add_elem(&pv, (Variable)di, 1);
1936  vect_add_elem(&pv, (Variable)GetLiVar(l), -1);
1937  vect_add_elem(&pv, (Variable)ind, 1);
1938  pc = contrainte_make(pv);
1939  sc_add_eg(*psc_dep, pc);
1940 
1941  vect_add_elem(p_DiIncNonCons, (Variable)di, 1);
1942  }
1943 
1944  }
1945 
1946  /* Update basis */
1947  if(!BASE_NULLE_P((*psc_dep)->base)) {
1948  vect_rm((*psc_dep)->base);
1949  (*psc_dep)->base = BASE_UNDEFINED;
1950  }
1951  sc_creer_base(*psc_dep);
1952 }
1953 
1954 
1955 
1956 /*
1957  * This function implements one of the last steps of the CRI dependence test.
1958  *
1959  * System ps has been projected on di variables. ps is examined to find
1960  * out the set of possible values for di variables, the iteration differences
1961  * for which a dependence exist.
1962  *
1963  * Loops are numbered from 1 to cl, the maximum nesting level.
1964  * At each step, the di variable corresponding to the current nesting level
1965  * is examined.
1966  *
1967  * Dependences levels added to the graph depend on the sign of the values
1968  * computed for di. There is a dependence from s1 to s2 if di can be
1969  * positive and from s2 to s1 if di can be negative.
1970  *
1971  * There are no loop-carried dependence if di is equal to zero. The
1972  * corresponding level is cl+1.
1973  *
1974  * Finally, di is set to 0 at the end of the loop since
1975  * dependences at level l are examined assuming the enclosing loops are
1976  * at the same iteration.
1977  *
1978  * Input:
1979  *
1980  * ps is the projected system (the distance system for the dep: (s1->s2).
1981  * a copy of ps, pss is allocated to compute di's value, but ps is
1982  * modified until it is empty (all di variables have been projected),
1983  * or until it is unfeasible (this is detected on pss)
1984  *
1985  * cl is the common nesting level of statement s1 and s2.
1986  *
1987  * Temporaries:
1988  *
1989  * pss is deallocated by sc_minmax_of_variable_optim()
1990  *
1991  * Modification :
1992  *
1993  * - variable NotPositive added to take into acounnt the case di<=0.
1994  * Yi Qing (10/91)
1995  */
1996 
1998  int cl,
1999  statement s1,
2000  effect ef1 __attribute__ ((unused)),
2001  statement s2,
2002  effect ef2 __attribute__ ((unused))) {
2003  list levels = NIL;
2004  _int l;
2005  bool all_level_founds = false;
2006 
2007  pips_debug(7, "maximum common level (cl): %d\n", cl);
2008 
2009  for (l = 1; !all_level_founds && l <= cl; l++) {
2010  Variable di = (Variable)GetDiVar(l);
2011  Value min, max;
2012  int IsPositif, IsNegatif, IsNull, NotPositif;
2013  /* FI: Keep a consistent interface in memory allocation */
2014  /* Psysteme pss = (l==cl) ? ps : sc_dup(ps); */
2015  Psysteme pss = sc_dup(ps);
2016 
2017  ifdebug(7) {
2018  pips_debug(7, "current level: %td, variable: %s\n",
2019  l, entity_local_name((entity) di));
2020  }
2021 
2022  if(sc_minmax_of_variable_optim(pss, di, &min, &max) == false) {
2023  pips_debug(7,"sc_minmax_of_variable_optim: non feasible system\n");
2024  all_level_founds = true;
2025  break;
2026  }
2027 
2028  IsPositif = value_pos_p(min);
2029  IsNegatif = value_neg_p(max);
2030  IsNull = value_zero_p(min) && value_zero_p(max);
2031  NotPositif = value_zero_p(max) && value_neg_p(min);
2032 
2033  ifdebug(7) {
2034  pips_debug(7, "values: ");
2035  fprint_string_Value(stderr, "min = ", min);
2036  fprint_string_Value(stderr, " max = ", max);
2037  fprintf(stderr,
2038  " ==> %s\n",
2039  IsPositif ? "positive" : (IsNegatif ? "negative"
2040  : (IsNull ? "null"
2041  : "undefined")));
2042  }
2043 
2044  if(IsNegatif) {
2045  all_level_founds = true;
2046  break;
2047  }
2048 
2049  if(IsPositif) {
2050  pips_debug(7, "adding level %td\n", l);
2051  levels = gen_nconc(levels, CONS(INT, l, NIL));
2052  all_level_founds = true;
2053  break;
2054  }
2055 
2056  if(!IsNull && !NotPositif) {
2057  pips_debug(7, "adding level %td\n", l);
2058  levels = gen_nconc(levels, CONS(INT, l, NIL));
2059  }
2060 
2061  if(!all_level_founds && l <= cl - 1) {
2062  pips_debug(7, "forcing variable %s to 0 (l < cl)\n",
2063  entity_local_name((entity) di));
2064  /* This function does not test feasibility and does not
2065  * deallocate ps
2066  */
2067  sc_force_variable_to_zero(ps, di);
2068  }
2069  }
2070 
2071  /* If there is no dependence at a common loop level: since the system
2072  * is feasible, it can be a dependence at the innermost level (inside the
2073  * common loop nest).
2074  *
2075  * WARNING:
2076  *
2077  * If the source and target statements are identical, we do not
2078  * add the innermost level because the parallelization phase
2079  * (rice) does not appreciate. In order to be correct, we should
2080  * add this level 1) because the statement may be a call to an
2081  * external routine, in which case we cannot be sure that all the
2082  * writes are performed before the reads and 2) even in the case
2083  * of a single assignement, the generated code must preserve the
2084  * order of the write and read memory operations. BC.
2085  */
2086  if(!all_level_founds && s1 != s2 && statement_possible_less_p(s1, s2)) {
2087  pips_debug(7, "adding innermost level %td\n", l);
2088  levels = gen_nconc(levels, CONS(INT, l, NIL));
2089  }
2090 
2091  return (levels);
2092 }
2093 
2094 /* Ptsg dependence_cone_positive(Psysteme dept_syst)
2095  */
2097  Psysteme dep_sc; {
2098  Psysteme volatile sc_env = SC_UNDEFINED;
2099  Ptsg volatile sg_env = NULL;
2100  Pbase b;
2101  int n, j;
2102  int volatile i;
2103 
2104  if(SC_UNDEFINED_P(dep_sc))
2105  return (sg_new());
2106 
2107  sc_env = sc_empty(base_dup(dep_sc->base));
2108  n = dep_sc->dimension;
2109  b = dep_sc->base;
2110 
2111  for (i = 1; i <= n; i++) {
2112  volatile Psysteme sub_sc = sc_dup(dep_sc);
2113  Pvecteur v;
2114  Pcontrainte pc;
2115  Pbase b1;
2116 
2117  for (j = 1, b1 = b; j <= i - 1; j++, b1 = b1->succ) {
2118  /* add the contraints bj = 0 (1<=j<i) */
2119  v = vect_new(b1->var, 1);
2120  pc = contrainte_make(v);
2121  sc_add_eg(sub_sc,pc);
2122  }
2123  /* add the contraints - bi <= -1 (1<=j<i) */
2124  v = vect_new(b1->var, -1);
2125  vect_add_elem(&v, TCST, 1);
2126  pc = contrainte_make(v);
2127  sc_add_ineg(sub_sc,pc);
2128 
2129  ifdebug(7) {
2130  fprintf(stderr, "\nInitial sub lexico-positive dependence system:\n");
2131  sc_syst_debug(sub_sc);
2132  }
2133 
2134  /* dans le cas d'une erreur d'overflow, on fait comme si le test
2135  * avait renvoye' true. bc.
2136  */CATCH(overflow_error) {
2137  pips_debug(1, "overflow error.\n");
2138  } TRY
2139  {
2140  if(!sc_integer_feasibility_ofl_ctrl(sub_sc, FWD_OFL_CTRL, true)) {
2141  sc_rm(sub_sc);
2142  pips_debug(7,"sub lexico-positive dependence system not feasible\n");
2143 
2145  continue;
2146  } else
2148 
2149  }
2150 
2151  if(sc_empty_p(sub_sc = sc_normalize(sub_sc))) {
2152  sc_rm(sub_sc); /* to mimic previous behavior of sc_normalize */
2153  pips_debug(7, "normalized system not feasible\n");
2154 
2155  continue;
2156  }
2157 
2158  /* We get a normalized sub lexico-positive dependence system */ifdebug(7) {
2159  fprintf(stderr, "Normalized sub lexico-positive dependence system :\n");
2160  sc_syst_debug(sub_sc);
2161  }
2162 
2163  {
2164  Psysteme old_sc_env = sc_env;
2165  sc_env = sc_enveloppe_chernikova(sc_env, sub_sc);
2166  sc_rm(old_sc_env);
2167  }
2168 
2169  sc_rm(sub_sc);
2170 
2171  ifdebug(7) {
2172  fprintf(stderr, "Dependence system of the enveloppe of subs "
2173  "lexico-positive dependence:\n");
2174  sc_syst_debug(sc_env);
2175 
2176  if(!SC_UNDEFINED_P(sc_env) && !sc_rn_p(sc_env)) {
2177  sg_env = sc_to_sg_chernikova(sc_env);
2178  fprintf(stderr, "Enveloppe of the subs lexico-positive "
2179  "dependence cones:\n");
2180  if(!SG_UNDEFINED_P(sg_env) && vect_size(sg_env->base) != 0) {
2181  print_dependence_cone(stderr, sg_env, sg_env->base);
2182  sg_rm(sg_env);
2183  sg_env = (Ptsg)NULL;
2184  }
2185  }
2186  }
2187 
2188  }
2189 
2190  if(!SC_UNDEFINED_P(sc_env) && sc_dimension(sc_env) != 0) {
2191 
2192  sg_env = sc_to_sg_chernikova(sc_env);
2193  sc_rm(sc_env);
2194  } else {
2195  sg_env = sg_new();
2196  }
2197 
2198  return (sg_env);
2199 }
2200 
2202  statement stat; {
2203  list lv = NIL;
2204  loop l;
2205  list locals;
2206 
2207  pips_assert("statement stat is a loop", statement_loop_p(stat));
2209  entity en = effect_entity(ef);
2211  && entity_integer_scalar_p(en))
2212  lv = gen_nconc(lv, CONS(ENTITY, en, NIL));
2213  }
2214  l = statement_loop(stat);
2215  locals = loop_locals(l);
2216  FOREACH (ENTITY, v, locals) {
2217  if(gen_find_eq(v, lv) == entity_undefined)
2218  lv = CONS(ENTITY, v, lv);
2219  }
2220  locals = statement_declarations(loop_body(l));
2221  FOREACH (ENTITY, v, locals) {
2222  if(gen_find_eq(v, lv) == entity_undefined)
2223  lv = CONS(ENTITY, v, lv);
2224  }
2225  return (lv);
2226 }
2227 
2228 /* this function detects intra-statement, non loop carried dependence
2229  * ( Di=(0,0,...0) and s1 = s2).
2230  */
2231 static bool TestDiCnst(Psysteme ps,
2232  int cl,
2233  statement s1,
2234  effect ef1 __attribute__ ((unused)),
2235  statement s2,
2236  effect ef2 __attribute__ ((unused))) {
2237  int l;
2238 
2239  for (l = 1; l <= cl; l++) {
2240  Variable di = (Variable)GetDiVar(l);
2241  Psysteme pss;
2242  Value val;
2243  bool success_p = true;
2244 
2245  pss = sc_dup(ps);
2246  success_p = sc_value_of_variable(pss, di, &val);
2247  sc_rm(pss);
2248 
2249  if(success_p) {
2250  if(value_notzero_p(val)) {
2251  return (false);
2252  }
2253  } else {
2254  return (false);
2255  }
2256  }
2257 
2258  /* case of di zero */
2259  if(s1 == s2) {
2260  NbrAllEquals++;
2261  return (true);
2262  } else
2263  return (false);
2264 }
2265 
2266 
2267 
2268 void writeresult(char *mod_name) {
2269  FILE *fp;
2270  string filename;
2271  int i, j;
2272 
2273  switch(dg_type) {
2274  case DG_FAST:
2275  filename = "resulttestfast";
2276  break;
2277  case DG_FULL:
2278  filename = "resulttestfull";
2279  break;
2280  case DG_SEMANTICS:
2281  filename = "resulttestseman";
2282  break;
2283  default:
2284  pips_internal_error("erroneous dg type.");
2285  return; /* to avoid warnings from compiler */
2286  }
2287 
2289  "/",
2290  mod_name,
2291  ".",
2292  filename,
2293  0));
2294 
2295  fp = safe_fopen(filename, "w");
2296 
2297  fprintf(fp, "%s", mod_name);
2298  fprintf(fp,
2299  " %d %d %d %d %d %d %d %d %d %d",
2301  NbrIndepFind,
2302  NbrAllEquals,
2303  NbrDepCnst,
2304  NbrTestExact,
2308  NbrScalDep,
2309  NbrIndexDep);
2310  for (i = 0; i <= 4; i++)
2311  for (j = 0; j <= 2; j++)
2312  fprintf(fp, " %d", deptype[i][j]);
2313  for (i = 0; i <= 4; i++)
2314  for (j = 0; j <= 2; j++)
2315  fprintf(fp, " %d", constdep[i][j]);
2316  fprintf(fp,
2317  " %d %d %d %d %d %d %d %d %d %d %d",
2318  NbrTestCnst,
2319  NbrTestGcd,
2320  NbrTestSimple,
2321  NbrTestDiCnst,
2324  NbrTestProjEq,
2325  NbrTestProjFM,
2326  NbrTestDiVar,
2328  NbrFMSystNonAug);
2329  for (i = 0; i < 18; i++)
2330  fprintf(fp, " %d", FMComp[i]);
2331  fprintf(fp, "\n");
2332 
2333  safe_fclose(fp, filename);
2334  free(filename);
2335 }
2336 
2337 
2338 // have to be done before call :
2339 // * set_ordering_to_statement
2340 // * set_enclosing_loops_map
2341 // * loading cumulated effects
2343  dg = chains;
2344  dg_type = DG_FAST; //FIXME
2345 
2346  debug_on("QUICK_PRIVATIZER_DEBUG_LEVEL");
2348  debug_off();
2349 
2350  memset(deptype,0,sizeof(deptype));
2351  memset(constdep,0,sizeof(deptype));
2352 
2353  rdg_statement(s);
2354 
2355  return dg;
2356 }
2357 
2358 
2359 // have to be done before call :
2360 // * set_ordering_to_statement
2361 // * set_enclosing_loops_map
2362 // * loading cumulated effects
2364  dg = copy_graph(chains);
2366 }
2367 
2368 
float a2sf[2] __attribute__((aligned(16)))
USER generates a user error (i.e., non fatal) by printing the given MSG according to the FMT.
Definition: 3dnow.h:3
void free_conflict(conflict p)
Definition: dg.c:63
cone make_cone(list a1, Ptsg a2)
Definition: dg.c:54
sccflags make_sccflags(scc a1, intptr_t a2, intptr_t a3, intptr_t a4)
Definition: dg.c:222
bool graph_consistent_p(graph p)
Definition: graph.c:29
void free_successor(successor p)
Definition: graph.c:65
graph copy_graph(graph p)
GRAPH.
Definition: graph.c:20
dg_arc_label arc_label
Definition: delay.c:63
bool entity_all_locations_p(entity e)
test if an entity is the top of the lattice
#define CATCH(what)
@ overflow_error
#define UNCATCH(what)
#define TRY
#define value_pos_p(val)
#define int_to_value(i)
end LINEAR_VALUE_IS_INT
#define value_notzero_p(val)
#define value_zero_p(val)
int Value
#define value_product(v, w)
#define value_neg_p(val)
void fprint_string_Value(FILE *, char *, Value)
Definition: io.c:47
@ INT
Definition: atomic.c:48
Pbase base_add_variable(Pbase b, Variable var)
Pbase base_add_variable(Pbase b, Variable v): add variable v as a new dimension to basis b at the end...
Definition: base.c:88
bool vect_in_basis_p(Pvecteur v, Pbase b)
Pvecteur vect_in_basis_p(Pvecteur v, Pbase b): check that all coordinates in v are in b,...
Definition: base.c:342
Pbase base_union(Pbase b1, Pbase b2)
Pbase base_union(Pbase b1, Pbase b2): compute a new basis containing all elements of b1 and all eleme...
Definition: base.c:428
static bool chains(char *module_name, enum chain_type use)
Compute chain dependence for a module according different kinds of store-like effects.
Definition: chains.c:1397
Ptsg sc_to_sg_chernikova(Psysteme sc)
chernikova_mulprec.c
Definition: chernikova.c:42
void vect_debug(Pvecteur v)
constraint.c
Definition: constraint.c:43
void sc_syst_debug(Psysteme s)
constraint_to_text.c
statement_mapping contexts_mapping_of_nest(statement stat)
contexts.c
Definition: contexts.c:162
#define COEFF_CST(c)
int COEFF_CST(Pcontrainte c): terme constant d'une contrainte
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
bool egalite_normalize(Pcontrainte)
bool egalite_normalize(Pcontrainte eg): reduction d'une equation diophantienne par le pgcd de ses coe...
Definition: normalize.c:136
bool contrainte_constante_p(Pcontrainte)
bool contrainte_constante_p(Pcontrainte c): test de contrainte triviale sans variables (ie du type 0<...
Definition: predicats.c:192
struct _newgen_struct_dg_arc_label_ * dg_arc_label
Definition: dg.h:60
#define conflict_sink(x)
Definition: dg.h:167
#define CONFLICT(x)
CONFLICT.
Definition: dg.h:134
#define dg_vertex_label_sccflags(x)
Definition: dg.h:237
#define dg_arc_label_conflicts(x)
Definition: dg.h:201
#define conflict_source(x)
Definition: dg.h:165
#define cone_undefined
Definition: dg.h:104
#define conflict_undefined
Definition: dg.h:140
struct _newgen_struct_dg_vertex_label_ * dg_vertex_label
Definition: dg.h:68
#define dg_arc_label_undefined
Definition: dg.h:179
#define scc_undefined
Definition: dg.h:321
#define conflict_cone(x)
Definition: dg.h:169
#define region
simulation of the type region
#define min(a, b)
#define max(a, b)
void set_cumulated_rw_effects(statement_effects)
list load_cumulated_rw_effects_list(statement)
void reset_cumulated_rw_effects(void)
list words_effect(effect)
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
#define effect_system(e)
entity effect_entity(effect)
cproto-generated files
Definition: effects.c:52
#define effect_action(x)
Definition: effects.h:642
#define effect_undefined
Definition: effects.h:614
#define action_write_p(x)
Definition: effects.h:314
#define action_read_p(x)
Definition: effects.h:311
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
FILE * safe_fopen(const char *filename, const char *what)
Definition: file.c:67
int safe_fclose(FILE *stream, const char *filename)
Definition: file.c:77
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
int current_shared_obj_table_size(void)
for debug
Definition: genClib.c:654
int gen_allocated_memory(gen_chunk *obj)
re-entry is automatic for this function.
Definition: genClib.c:2690
void free(void *)
#define successor_vertex(x)
Definition: graph.h:118
#define successor_undefined
Definition: graph.h:92
#define vertex_undefined
Definition: graph.h:128
#define successor_arc_label(x)
Definition: graph.h:116
struct _newgen_struct_graph_ * graph
Definition: graph.h:31
#define vertex_vertex_label(x)
Definition: graph.h:152
#define vertex_successors(x)
Definition: graph.h:154
#define newgen_arc_label(p)
Definition: graph.h:20
#define SUCCESSOR(x)
SUCCESSOR.
Definition: graph.h:86
#define graph_vertices(x)
Definition: graph.h:82
#define VERTEX(x)
VERTEX.
Definition: graph.h:122
#define successor_arc_label_(x)
Definition: graph.h:115
#define CONTROL_MAP(ctl, code, c, list)
Macro to walk through all the controls reachable from a given control node of an unstructured.
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
set distributable_loop(statement l)
this functions checks if Kennedy's algorithm can be applied on the loop passed as argument.
Definition: loop.c:221
set region_of_loop(statement l)
this function returns the set of all statements belonging to the given loop even if the loop contains...
Definition: loop.c:254
int loop_increment_value(loop l)
Definition: loop.c:714
void clean_enclosing_loops(void)
Definition: loop.c:58
int Nbrdo
loop.c
Definition: loop.c:54
statement_mapping loops_mapping_of_statement(statement stat)
Definition: loop.c:155
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
Definition: list.c:685
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
size_t gen_length(const list l)
Definition: list.c:150
#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
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
void * gen_find_eq(const void *item, const list seq)
Definition: list.c:422
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
loop statement_loop(statement)
Get the loop of a statement.
Definition: statement.c:1374
bool statement_loop_p(statement)
Definition: statement.c:349
bool statement_possible_less_p(statement, statement)
Definition: statement.c:306
void hash_warn_on_redefinition(void)
these function set the variable should_i_warn_on_redefinition to the value true or false
Definition: hash.c:183
statement vertex_to_statement(vertex v)
Vertex_to_statement looks for the statement that is pointed to by vertex v.
Definition: util.c:45
static statement mod_stat
We want to keep track of the current statement inside the recurse.
Definition: impact_check.c:41
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
#define rule_phase(x)
Definition: makefile.h:244
void * memset(void *str, int c, size_t len)
memset.c – set an area of memory to a given value Copyright (C) 1991, 2003, 2009-2011 Free Software F...
Definition: memset.c:23
#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 pips_user_warning
Definition: misc-local.h:146
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define pips_internal_error
Definition: misc-local.h:149
#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
void print_arguments(list args)
Definition: naming.c:228
#define DEFINE_CURRENT_MAPPING(name, type)
Definition: newgen-local.h:58
#define assert(ex)
Definition: newgen_assert.h:41
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define same_string_p(s1, s2)
#define set_undefined
Definition: newgen_set.h:48
void set_free(set)
Definition: set.c:332
bool set_belong_p(const set, const void *)
Definition: set.c:194
#define false
Definition: newgen_types.h:80
intptr_t _int
_INT
Definition: newgen_types.h:53
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...
Definition: ordering.c:172
void reset_ordering_to_statement(void)
Reset the mapping from ordering to statement.
Definition: ordering.c:185
static char * module
Definition: pips.c:74
string db_get_current_workspace_directory(void)
Definition: workspace.c:96
rule find_rule_by_resource(const char *rname)
This function returns the active rule to produce resource rname.
Definition: pipsmake.c:694
Psysteme sc_enveloppe_chernikova(Psysteme, Psysteme)
Definition: sc_enveloppe.c:127
void print_statement_set(FILE *, set)
statement.c
Definition: statement.c:49
#define RICEDG_PROVIDE_STATISTICS
static hash_table pl
properties are stored in this hash table (string -> property) for fast accesses.
Definition: properties.c:783
void quick_privatize_graph(graph dep_graph)
quick_privatize.c
#define NORMALIZE_EXPRESSION(e)
#define unstructured_control
After the modification in Newgen: unstructured = entry:control x exit:control we have create a macro ...
#define is_instruction_block
soft block->sequence transition
#define instruction_block(i)
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
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 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
bool fortran_module_p(entity m)
Test if a module is in Fortran.
Definition: entity.c:2799
type ultimate_type(type)
Definition: type.c:3466
list load_statement_enclosing_loops(statement)
bool pointer_type_p(type)
Check for scalar pointers.
Definition: type.c:2993
bool entity_atomic_reference_p(entity)
Any reference r such that reference_variable(r)==e accesses all bytes (or bits) allocated to variable...
Definition: variable.c:1163
void set_enclosing_loops_map(statement_mapping)
bool entity_integer_scalar_p(entity)
for variables (like I), not constants (like 1)! use integer_constant_p() for constants
Definition: variable.c:1130
#define loop_body(x)
Definition: ri.h:1644
#define normalized_linear_p(x)
Definition: ri.h:1779
#define instruction_loop_p(x)
Definition: ri.h:1518
#define reference_variable(x)
Definition: ri.h:2326
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define test_false(x)
Definition: ri.h:2837
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define entity_undefined
Definition: ri.h:2761
@ is_instruction_goto
Definition: ri.h:1473
@ is_instruction_unstructured
Definition: ri.h:1475
@ is_instruction_whileloop
Definition: ri.h:1472
@ is_instruction_expression
Definition: ri.h:1478
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_forloop
Definition: ri.h:1477
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define transformer_relation(x)
Definition: ri.h:2873
#define test_true(x)
Definition: ri.h:2835
#define reference_indices(x)
Definition: ri.h:2328
#define instruction_forloop(x)
Definition: ri.h:1538
#define loop_locals(x)
Definition: ri.h:1650
#define instruction_whileloop(x)
Definition: ri.h:1523
#define range_lower(x)
Definition: ri.h:2288
#define whileloop_body(x)
Definition: ri.h:3162
#define statement_declarations(x)
Definition: ri.h:2460
#define statement_instruction(x)
Definition: ri.h:2458
#define loop_range(x)
Definition: ri.h:1642
#define control_statement(x)
Definition: ri.h:941
#define instruction_test(x)
Definition: ri.h:1517
#define entity_type(x)
Definition: ri.h:2792
#define statement_number(x)
Definition: ri.h:2452
#define normalized_linear(x)
Definition: ri.h:1781
#define forloop_body(x)
Definition: ri.h:1372
#define predicate_system(x)
Definition: ri.h:2069
#define whileloop_undefined
Definition: ri.h:3134
#define instruction_unstructured(x)
Definition: ri.h:1532
#define loop_index(x)
Definition: ri.h:1640
#define statement_undefined
Definition: ri.h:2419
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
#define forloop_undefined
Definition: ri.h:1340
static list TestDiVariables(Psysteme, int, statement, effect, statement, effect)
int NbrAllEquals
Definition: ricedg.c:66
bool rice_full_dependence_graph(char *mod_name)
Definition: ricedg.c:144
int FMComp[18]
Definition: ricedg.c:86
static void rdg_unstructured(unstructured)
STATIC FUNCTION DECLARATIONS
Definition: ricedg.c:399
int NbrTestProjFMDi
Definition: ricedg.c:80
bool rice_semantics_dependence_graph(char *mod_name)
Definition: ricedg.c:149
static void dependence_system_add_lci_and_di(Psysteme *, list, Pvecteur *)
static void dependence_system_add_lci_and_di(Psysteme *psc_dep, list s1_enc_loops,...
Definition: ricedg.c:1883
int NbrArrayDepInit
Dependence Graph computation for Allen & Kennedy algorithm.
Definition: ricedg.c:64
#define DG_FULL
Definition: ricedg.c:125
#define DG_SEMANTICS
Definition: ricedg.c:126
int NbrTestExact
Definition: ricedg.c:68
static list TestDependence(list, Psysteme, statement, effect, reference, list, Psysteme, statement, effect, reference, list, Ptsg *, list *, Ptsg *)
static list TestDependence(list n1, n2, Psysteme sc1, sc2, statement s1, s2, effect ef1,...
Definition: ricedg.c:1151
int NbrFMSystNonAug
Definition: ricedg.c:85
static list TestCoupleOfEffects(statement, effect, statement, effect, list, Ptsg *, list *, Ptsg *)
DEPENDENCE TEST
Definition: ricedg.c:821
int NbrScalDep
Definition: ricedg.c:72
int NbrIndepFind
Definition: ricedg.c:65
static list loop_variant_list(statement)
Definition: ricedg.c:2201
int constdep[5][3]
Definition: ricedg.c:74
static int dg_type
Definition: ricedg.c:128
int NbrTestDiCnst
by sc_normalize()
Definition: ricedg.c:78
int NbrProjFMTotal
Definition: ricedg.c:84
bool Finds2s1
Definition: ricedg.c:97
int NbrTestGcd
Definition: ricedg.c:76
static bool rice_dependence_graph(char *)
INTERFACE FUNCTIONS
Definition: ricedg.c:230
#define DG_FAST
Different types of dependence tests:
Definition: ricedg.c:124
bool is_dep_cnst
Definition: ricedg.c:95
bool is_test_inexact_eq
Definition: ricedg.c:93
bool is_test_inexact_fm
Definition: ricedg.c:94
static bool build_and_test_dependence_context(reference, reference, Psysteme, Psysteme, Psysteme *, list, list)
static bool build_and_test_dependence_context(reference r1, r2, Psystem sc1, sc2, *psc_dep,...
Definition: ricedg.c:1580
int NbrTestProjEq
Definition: ricedg.c:81
static bool TestDiCnst(Psysteme, int, statement, effect, statement, effect)
static void rdg_loop(statement)
Definition: ricedg.c:452
int NbrDepInexactEFM
Definition: ricedg.c:71
int NbrTestCnst
Definition: ricedg.c:75
static Ptsg dependence_cone_positive(Psysteme)
Ptsg dependence_cone_positive(Psysteme dept_syst)
Definition: ricedg.c:2096
int NbrTestSimple
Definition: ricedg.c:77
int NbrIndexDep
Definition: ricedg.c:73
bool rice_fast_dependence_graph(char *mod_name)
Definition: ricedg.c:139
void writeresult(char *mod_name)
Definition: ricedg.c:2268
static bool PRINT_RSDG
Definition: ricedg.c:112
bool rice_regions_dependence_graph(char *mod_name)
Definition: ricedg.c:154
bool is_test_exact
or counting the number of F-M complexity less than 16.
Definition: ricedg.c:92
list TestCoupleOfReferences(list n1, Psysteme sc1 __attribute__((unused)), statement s1, effect ef1, reference r1, list n2, Psysteme sc2 __attribute__((unused)), statement s2, effect ef2, reference r2, list llv, Ptsg *gs __attribute__((unused)), list *levelsop __attribute__((unused)), Ptsg *gsop __attribute__((unused)))
Definition: ricedg.c:905
int deptype[5][3]
Definition: ricedg.c:74
graph compute_dg_on_statement_from_chains_in_place(statement s, graph chains)
Definition: ricedg.c:2342
int NbrDepCnst
Definition: ricedg.c:67
int NbrTestDiVar
Definition: ricedg.c:83
int NbrDepInexactEq
Definition: ricedg.c:69
int NbrTestProjEqDi
Definition: ricedg.c:79
static void rice_update_dependence_graph(statement, set)
Update of dependence graph.
Definition: ricedg.c:560
static bool gcd_and_constant_dependence_test(reference, reference, list, list, Psysteme *)
static bool gcd_and_constant_dependence_test(references r1, r2, list llv, s2_enc_loops,...
Definition: ricedg.c:1761
int NbrDepInexactFM
Definition: ricedg.c:70
static void rdg_statement(statement)
Definition: ricedg.c:409
int NbrTestProjFM
Definition: ricedg.c:82
graph compute_dg_on_statement_from_chains(statement s, graph chains)
Definition: ricedg.c:2363
static graph dg
to map statements to enclosing loops
Definition: ricedg.c:110
bool is_test_Di
Definition: ricedg.c:96
void print_dependence_cone(FILE *, Ptsg, Pbase)
Definition: util.c:974
Psysteme sc_invers(Psysteme)
Psysteme sc_invers(Psysteme ps): calcul un systeme des contraintes qui est l'invers du systeme initia...
Pbase MakeDibaseinorder(int)
Pbase MakeDibaseinorder(int n) make a base of D#1 ...
Definition: testdep_util.c:296
int sc_proj_optim_on_di_ofl(int, Psysteme *)
int sc_proj_optim_on_di_ofl(cl, sc)
Definition: testdep_util.c:415
void set_context_map(statement_mapping)
bool sc_faisabilite_optim(Psysteme)
bool sc_faisabilite_optim (Psysteme sc) :
Definition: testdep_util.c:484
void sc_add_di(int, entity, Psysteme, int)
Definition: testdep_util.c:209
void prettyprint_dependence_graph(FILE *, statement, graph)
Print all edges and arcs.
Definition: util.c:177
void ResetLoopCounter(void)
Definition: testdep_util.c:329
entity GetDiVar(int)
This functions looks up a di variable of nesting level l in table DiVars.
Definition: testdep_util.c:79
int dep_type(action, action)
int dep_type(action ac1,action ac2) This function test the type of the dependence.
Definition: testdep_util.c:378
int DiVarLevel(entity)
this function returns the nesting level of a given di variable e.
Definition: testdep_util.c:185
bool sc_minmax_of_variable_optim(Psysteme volatile, Variable, Value *, Value *)
void sc_minmax_of_variable_optim(Psysteme ps, Variable var, Value *pmin, *pmax): examine un systeme p...
Definition: testdep_util.c:975
void sc_add_dsi(int, entity, Psysteme)
Definition: testdep_util.c:238
entity GetDsiVar(int)
Definition: testdep_util.c:164
Psysteme load_statement_context(statement)
void reset_context_map(void)
int FindMaximumCommonLevel(cons *, cons *)
Definition: testdep_util.c:307
entity GetLiVar(int)
Definition: testdep_util.c:121
entity MakeLoopCounter(void)
Create a new loop counter variable.
Definition: testdep_util.c:334
struct Ssysteme * Psysteme
bool sc_consistent_p(Psysteme sc)
bool sc_consistent_p(Psysteme sc): check that sc is well defined, that the numbers of equalities and ...
Definition: sc.c:282
bool sc_weak_consistent_p(Psysteme sc)
check that sc is well defined, that the numbers of equalities and inequalities are consistent with th...
Definition: sc.c:362
bool sc_rn_p(Psysteme sc)
bool sc_rn_p(Psysteme sc): check if the set associated to sc is the whole space, rn
Definition: sc_alloc.c:369
Psysteme sc_empty(Pbase b)
Psysteme sc_empty(Pbase b): build a Psysteme with one unfeasible constraint to define the empty subsp...
Definition: sc_alloc.c:319
Psysteme sc_rn(Pbase b)
Psysteme sc_rn(Pbase b): build a Psysteme without constraints to define R^n, where n is b's dimension...
Definition: sc_alloc.c:336
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
void sc_rm(Psysteme ps)
void sc_rm(Psysteme ps): liberation de l'espace memoire occupe par le systeme de contraintes ps;
Definition: sc_alloc.c:277
Pbase sc_to_minimal_basis(Psysteme ps)
creation d'une base contenant toutes les variables apparaissant avec des coefficients non-nuls dans l...
Definition: sc_alloc.c:76
Psysteme sc_new(void)
Psysteme sc_new(): alloue un systeme vide, initialise tous les champs avec des valeurs nulles,...
Definition: sc_alloc.c:55
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.
Definition: sc_alloc.c:350
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
void sc_force_variable_to_zero(Psysteme ps, Variable var)
void sc_force_variable_to_zero(Psysteme ps, Variable var): force la variable var a prendre la valeur ...
Definition: sc_eval.c:251
bool sc_value_of_variable(Psysteme ps, Variable var, Value *pval)
bool sc_value_for_variable(Psysteme ps, Variable var, Value *pval): examine les egalites du systeme p...
Definition: sc_eval.c:70
bool sc_integer_feasibility_ofl_ctrl(Psysteme sc, int ofl_ctrl, bool ofl_res)
Value b2
Definition: sc_gram.c:105
Value b1
booleen indiquant quel membre est en cours d'analyse
Definition: sc_gram.c:105
Psysteme sc_fusion(Psysteme s1, Psysteme s2)
package sc
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
char * strdup()
Psysteme sc_restricted_to_variables_transitive_closure(Psysteme sc, Pbase variables)
for an improved dependence test (Beatrice Creusillet)
Definition: sc_misc.c:64
Psysteme sc_normalize(Psysteme ps)
Psysteme sc_normalize(Psysteme ps): normalisation d'un systeme d'equation et d'inequations lineaires ...
static int variables[MAX_VAR]
Psysteme sc_elim_var(Psysteme sc, Variable v)
package sur les systemes de contraintes sc
Definition: sc_unaires.c:49
void sc_chg_var(Psysteme s, Variable v_old, Variable v_new)
void sc_chg_var(Psysteme s, Variable v_old, Variable v_new) this function replace the variable v_old ...
Definition: sc_unaires.c:98
transformer load_statement_precondition(statement)
void reset_precondition_map(void)
void set_precondition_map(statement_mapping)
s1
Definition: set.c:247
struct type_sg * Ptsg
Representation d'un systeme generateur par trois ensembles de sommets de rayons et de droites.
#define sg_empty(sg)
Test for an empty generating system, which corresponds to an empty set.
Definition: sg-local.h:108
#define SG_UNDEFINED
Definition: sg-local.h:73
#define SG_UNDEFINED_P(sg)
Definition: sg-local.h:74
Ptsg sg_new()
Ptsg sg_new(): allocation d'un systeme generateur et initialisation a la valeur ensemble vide.
Definition: sg.c:55
#define ifdebug(n)
Definition: sg.c:47
void sg_rm(Ptsg sg)
void sg_rm(Ptsg sg): liberation de l'espace memoire occupe par un systeme generateur
Definition: sg.c:249
static bool ok
Pbase base
Definition: sc-local.h:75
int dimension
Definition: sc-local.h:74
int nb_eq
Definition: sc-local.h:72
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
FI: I do not understand why the type is duplicated at the set level.
Definition: set.c:59
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
Definition: delay.c:253
Representation d'un systeme generateur par trois ensembles de sommets de rayons et de droites.
Definition: sg-local.h:66
Pbase base
Definition: sg-local.h:70
void print_words(FILE *fd, cons *lw)
Definition: print.c:263
A gen_chunk is used to store every object.
Definition: genC.h:58
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define vecteur_var(v)
struct Svecteur * Pvecteur
#define VECTEUR_NUL_P(v)
#define base_rm(b)
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 FWD_OFL_CTRL
#define BASE_UNDEFINED
#define BASE_NULLE
MACROS SUR LES BASES.
#define BASE_NULLE_P(b)
#define VECTEUR_UNDEFINED_P(v)
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
Pbase base_dup(Pbase b)
Pbase base_dup(Pbase b) Note: this function changes the value of the pointer.
Definition: alloc.c:268
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
void vect_rm(Pvecteur v)
void vect_rm(Pvecteur v): desallocation des couples de v;
Definition: alloc.c:78
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...
Definition: binaires.c:75
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_var(Pvecteur *ppv, Variable v_old, Variable v_new)
void vect_chg_var(Pvecteur *ppv, Variable v_old, Variable v_new) replace the variable v_old by v_new
Definition: unaires.c:168