PIPS
reductions.c
Go to the documentation of this file.
1 /*
2 
3  $Id: reductions.c 23495 2018-10-24 09:19:47Z 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 
28 #include "genC.h"
29 #include "linear.h"
30 #include "ri.h"
31 #include "effects.h"
32 
33 #include "resources.h"
34 
35 #include "misc.h"
36 #include "ri-util.h"
37 #include "prettyprint.h"
38 #include "effects-util.h"
39 #include "pipsdbm.h"
40 
41 #include "effects-generic.h"
42 
43 #include "accel-util.h"
44 #include "reductions.h"
45 #include "sac.h"
46 #include "ricedg.h"
47 
48 #include "effects-convex.h"
49 #include "effects-simple.h"
50 
51 #include "control.h"
52 #include "callgraph.h"
53 #include "properties.h"
54 
56  if(expression_reference_p(e)) {
57  const char* refname = entity_user_name(reference_variable(expression_reference(e)));
58  if(refname==strstr(refname,get_string_property("SIMD_REMOVE_REDUCTIONS_PREFIX")))
59  return true;
60  }
61  return false;
62 }
63 
65 {
67  entity new_ent, mod_ent;
68  static int counter = 0;
69  const char *prefix = get_string_property("SIMD_REMOVE_REDUCTIONS_PREFIX") ;
70  char buffer[ 1 + 3 + strlen(prefix) ];
71  pips_assert("buffer does not overflow",counter < 1000);
72  sprintf(buffer,"%s%u",prefix,counter++);
73 
78  return new_ent;
79 }
80 
81 /* The first part of the function check that the reduction is allowed. If not,
82  the function returns undefined.
83  If the reduction is allowed, the function updates the
84  reductionInfo list reds or add the reduction to the list.*/
86 {
88 
89  pips_debug(1, "reduction reference %s\n", entity_local_name(reference_variable(reduction_reference(r))));
90 
91  //See if the reduction has already been encountered
92  FOREACH(REDUCTIONINFO,ri,*reds)
93  {
95  {
96  //The reduction has already been encountered: update the counter
97  reductionInfo_count(ri)++;
98 
101 
102  return ri;
103  }
104  }
105 
106  //First time we see this reduction: initialize a reductionInfo structure
108 
109  //Add to the list of reductions encountered
110  *reds=CONS(REDUCTIONINFO,ri,*reds);
111 
112  return ri;
113 }
114 
116  if(same_entity_p(
118  reductionInfo_vector(ri))) {
123  }
124 }
125 
127 {
128  syntax s = expression_syntax(e);
129 
130  if (syntax_reference_p(s) &&
132  {
136  }
137 }
138 
139 /* finds out expression with reduction */
140 typedef struct {
144 
146 {
148  return ! p->has_reduction_p;
149 }
150 
152 {
153  reduction_in_statement_param p ={ red, false };
155  return p.has_reduction_p;
156 }
157 
158 
159 /* This function gets the possible reduction thanks to load_cumulated_reductions() function.
160  Then, for each possible reduction, the function call add_reduction() to know if
161  the reduction is allowed and if it is, the function calls rename_reduction_ref()
162  to do the reduction. */
163 static void rename_statement_reductions(statement s, list * reductions_info, list reductions)
164 {
165  ifdebug(3) {
166  pips_debug(3,"considering statement:\n");
167  print_statement(s);
168  }
170  {
171  ifdebug(3) {
172  pips_debug(3,"considering reduction:\n");
174  fprintf(stderr,"\n");
175  }
176  if(reduction_star_p(r))
177  pips_debug(3,"can do nothing with star reductions ...\n");
178  else if(reduction_in_statement_p(r,s))
179  {
180  pips_debug(3,"found in the statement ! Rewriting ...\n");
182  if(!basic_undefined_p(b))
183  {
184  free_basic(b);
185  reductionInfo ri = add_reduction(reductions_info, r);
186  if( ! reductionInfo_undefined_p(ri))
188  }
189  }
190  else
191  pips_debug(3,"not found in the statement ! Skipping ...\n");
192  }
193 }
194 
195 /*
196  This function make an expression that represents
197  the maximum value
198  */
200 {
201  switch(basic_tag(b))
202  {
203  case is_basic_float:
204  return expression_undefined;
205 
206  case is_basic_int:
207  {
208  long long max = (2 << (basic_int(b) - 2)) - 1;
209  return int_to_expression(max);
210  }
211 
212  default:
213  return expression_undefined;
214  }
215 }
216 
217 /*
218  This function make an expression that represents
219  the minimum value
220  */
222 {
223  switch(basic_tag(b))
224  {
225  case is_basic_float:
226  return expression_undefined;
227 
228  case is_basic_int:
229  {
230  long long min = -(2 << (basic_int(b) - 2));
231  return int_to_expression(min);
232  }
233 
234  default:
235  return expression_undefined;
236  }
237 }
238 
239 /*
240  This function make an expression that represents
241  a zero value
242  */
244 {
245  switch(basic_tag(b))
246  {
247  case is_basic_float:
248  return float_to_expression(0);
249 
250  case is_basic_int:
251  return int_to_expression(0);
252 
253  case is_basic_complex:
254  return complex_to_expression(0,0);
255 
256  default:
257  pips_internal_error("function not implemented for this basic ");
258  }
259  return expression_undefined;
260 }
261 
262 /*
263  This function make an expression that represents
264  a one value
265  */
267 {
268  switch(basic_tag(b))
269  {
270  case is_basic_float:
271  return float_to_expression(1);
272 
273  case is_basic_int:
274  return int_to_expression(1);
275 
276  case is_basic_complex:
277  return complex_to_expression(0,1);
278 
279  default:
280  return expression_undefined;
281  }
282 }
283 
284 /*
285  This function generate the reduction prelude
286  */
288 {
289  expression initval;
290  list prelude = NIL;
291  int i;
293 
294  // According to the operator, get the correct initialization value
295  // should use operator_neutral_element
297  {
298  default:
300  return statement_undefined;
301  break;
302 
304  initval = make_maxval_expression(bas);
305  break;
306 
308  initval = make_minval_expression(bas);
309  break;
310 
312  initval = make_0val_expression(bas);
313  break;
314 
316  initval = make_1val_expression(bas);
317  break;
318 
320  initval = bool_to_expression(true);
321  break;
322 
324  initval = bool_to_expression(false);
325  break;
326  }
327 
328  // For each reductionInfo_vector reference, make an initialization
329  // assign statement and add it to the prelude
330  // do nothing if no init val exist
331  for(i=0; i<reductionInfo_count(ri); i++)
332  {
333  instruction is;
334 
339  NIL))),
340  copy_expression(initval));
341 
342  prelude = CONS(STATEMENT,
344  prelude);
345  }
346 
347  free_expression(initval);
348 
350 }
351 
352 /*
353  This function generate the reduction postlude
354  */
356 {
357  expression rightExpr;
358  entity operator;
359  instruction compact;
360  int i;
361 
362  // According to the operator, get the correct entity
364  {
365  default:
367  return statement_undefined; //nothing to generate
368  break;
369 
372  break;
373 
376  break;
377 
380  break;
381 
384  break;
385 
388  break;
389 
392  break;
393 
396  break;
397  }
398 
399  // Get the reduction variable
401 
402  const char* spostlude = get_string_property("SIMD_REMOVE_REDUCTIONS_POSTLUDE");
403  statement postlude = statement_undefined;
405  // For each reductionInfo_vector reference, add it to the compact statement
406  for(i=0; i<reductionInfo_count(ri); i++)
407  {
408  call c;
409  expression e;
410 
413  c = make_call(operator, CONS(EXPRESSION, e,
414  CONS(EXPRESSION, rightExpr, NIL)));
415 
416  rightExpr = call_to_expression(c);
417  }
418 
419  // Make the compact assignment statement
420  compact = make_assign_instruction(
422  rightExpr);
423 
424  postlude= instruction_to_statement(compact);
425  }
426  else {
427  entity epostlude = FindEntity(TOP_LEVEL_MODULE_NAME,spostlude);
428  if(entity_undefined_p(epostlude)) {
429  pips_user_warning("%s not found, using a dummy one",spostlude);
431  }
432  postlude=call_to_statement(
433  make_call(
434  epostlude,
439  ),
446  )
447  )
448  )
449  )
450  )
451  );
452  }
453  return postlude;
454 }
455 static
456 bool simd_gather_reduction(statement body, list reductions, list *reductions_info) {
457  instruction ibody = statement_instruction(body);
458  switch(instruction_tag(ibody))
459  {
461  {
463  rename_statement_reductions(curStat, reductions_info, reductions);
464  } break;
465 
466  default:
467  return false;
468  }
469  return !ENDP(*reductions_info);
470 }
471 
472 /*
473  This function attempts to find reductions for each loop
474  */
475 static void reductions_rewrite(statement s, set skip)
476 {
477  if(set_belong_p(skip,s)) return;
479  statement body;
480  bool is_loop=true;
481 
482  //We are only interested in loops
483  switch(instruction_tag(i))
484  {
485  case is_instruction_loop:
486  body = loop_body(instruction_loop(i));
487  break;
488 
491  break;
492 
495  break;
496 
498  body = s;
499  is_loop=false;
500  break;
501 
502  default:
503  return;
504  }
505  {
506 
507  list reductions_info = NIL;
508  list preludes = NIL;
509  list compacts = NIL;
510 
511  //Compute the reductions list for the loop
513  ifdebug(2) {
514  if(!ENDP(reductions))
515  pips_debug(2,"found reductions for loop:\n");
516  else
517  pips_debug(2,"no reduction for loop:\n");
518  print_statement(s);
519  }
520  //Lookup the reductions in the loop's body, and change the loop body accordingly
521  if(!simd_gather_reduction(body,reductions,&reductions_info)) {
522  /* we may have failed to find any reduction info, in that case try again with the inner reductions */
524  simd_gather_reduction(body,reductions,&reductions_info);
525  s=body;
526  }
527 
528 
529  //Generate prelude and compact code for each of the reductions
530  FOREACH(REDUCTIONINFO, ri,reductions_info)
531  {
532  if(entity_memory_size(reductionInfo_vector(ri))*8 >= get_int_property("SAC_SIMD_REGISTER_WIDTH")) {
533  statement curStat = generate_prelude(ri);
534  if (curStat != statement_undefined)
535  preludes = CONS(STATEMENT, curStat, preludes);
536 
537  curStat = generate_compact(ri);
538  if (curStat != statement_undefined)
539  compacts = CONS(STATEMENT, curStat, compacts);
540  }
541  /* not enough elements: undo the change */
542  else {
544  }
545  };
546  gen_full_free_list(reductions_info);
547 
548  // Replace the old statement instruction by the new one
549  gen_recurse_stop(compacts);
550  insert_statement(s,make_block_statement(compacts),false);
551  insert_statement(s,make_block_statement(preludes),true);
552 
553  }
554  if(is_loop) gen_recurse_stop(statement_instruction(s));
555 }
556 
558 {
559  if (statement_loop_p(s))
561  return true;
562 }
563 
564 /**
565  * remove reductions by expanding reduced scalar to an array
566  *
567  * @param mod_name module to remove reductions from
568  *
569  * @return true
570  */
571 bool simd_remove_reductions(char * mod_name)
572 {
573 
574  /* get the resources */
577  set_cumulated_reductions((pstatement_reductions) db_get_memory_resource(DBR_CUMULATED_REDUCTIONS, mod_name, true));
578 
579  debug_on("SIMDREDUCTION_DEBUG_LEVEL");
580 
581  /* Now do the job */
582  set skip = set_make(set_pointer);
584  set_free(skip);
585 
586  pips_assert("Statement is consistent after remove reductions", statement_consistent_p(get_current_module_statement()));
587 
588  /* Reorder the module, because new statements have been added */
593 
594  /* update/release resources */
598 
599  debug_off();
600 
601  return true;
602 }
603 
604 #if 0
605 static bool statement_reduction_prelude_p(statement s) {
606  if (statement_undefined_p(s))
607  return false;
608  if(statement_call_p(s)) {
609  call c =statement_call(s);
610  entity op = call_function(c);
611  if(same_string_p(entity_user_name(op),get_string_property("SIMD_REMOVE_REDUCTIONS_PRELUDE")))
612  return true;
613  }
614  return false;
615 }
616 static bool statement_reduction_postlude_p(statement s) {
617  if (statement_undefined_p(s))
618  return false;
619  if(statement_call_p(s)) {
620  call c =statement_call(s);
621  entity op = call_function(c);
622  if(same_string_p(entity_user_name(op),get_string_property("SIMD_REMOVE_REDUCTIONS_POSTLUDE")))
623  return true;
624  }
625  return false;
626 }
627 
628 static statement the_strict_successor = statement_undefined;
629 static void do_strict_successor(statement s, statement target)
630 {
631  if (s == target) {
633  if (statement_block_p(parent)) {
634  for (list iter = statement_block(parent); ! ENDP(iter); POP(iter)) {
635  if (! ENDP(CDR(iter))) {
636  statement next = STATEMENT(CAR(CDR(iter)));
637  statement current = STATEMENT(CAR(iter));
638  if (current == target ) {
639  list tail = CDR(CDR(iter));
640  while(empty_statement_or_continue_p(next)) {
641  if(ENDP(tail)) break;
642  else {
643  next = STATEMENT(CAR(tail));
644  POP(tail);
645  }
646  }
647  the_strict_successor = next;
648  gen_recurse_stop(0);
649  return;
650  }
651  }
652  }
653  }
654  }
655 }
656 
657 static statement strict_successor(statement s) {
658  the_strict_successor = statement_undefined;
660  statement_domain, gen_true, do_strict_successor);
661  return the_strict_successor;
662 }
663 
664 static void redundant_load_store_elimination_move_vectors(statement s, set moved_vectors)
665 {
666  if(statement_block_p(s)) {
668  FOREACH(ENTITY,e,tmp) {
669  if(set_belong_p(moved_vectors,e)) {
672  }
673  }
674  }
675 
676 }
677 
678 static void do_sac_reduction_optimizations(graph dg)
679 {
680  set moved_vectors = set_make(set_pointer);
681  FOREACH(VERTEX, a_vertex, graph_vertices(dg) )
682  {
683  statement stat0 = vertex_to_statement(a_vertex);
684  if(statement_reduction_prelude_p(stat0)) {
685  statement stat1 = strict_successor(stat0);
686  if(simd_load_stat_p(stat1)) {
688  statement_call(stat1) ) =
690  statement_call(stat0)
691  );
695  }
696  }
697  else if(simd_store_stat_p(stat0)) {
698  statement stat1 = strict_successor(stat0);
699  if(statement_reduction_postlude_p(stat1)) {
700  expression loaded_exp =
702  if(expression_call_p(loaded_exp))
703  loaded_exp=EXPRESSION(CAR(call_arguments(expression_call(loaded_exp))));
704 
707  set_add_element(moved_vectors,moved_vectors,expression_to_entity(loaded_exp));
708  }
709  }
710  }
712  statement_domain,gen_true,redundant_load_store_elimination_move_vectors);
713 }
714 #endif
715 
716 static bool no_write_read_conflicts_p(list succs) {
717  FOREACH(SUCCESSOR, succ, succs) {
721  return false;
722  }
723  }
724  return true;
725 }
726 
728  FOREACH(EFFECT,eff,load_proper_rw_effects_list(s)) if(io_effect_p(eff)) return true;
729  if(get_bool_property("REDUNDANT_LOAD_STORE_ELIMINATION_CONSERVATIVE")) {
731  bool out_effect = false;
734  if( anywhere_effect_p(eff) ||
737  ) {
738  out_effect=true;break;
739  }
740  }
742  return out_effect;
743  }
744  else {
745 
746  list out_effects = load_cumulated_rw_effects_list(s /* get_current_module_statement() */);
747  return !ENDP(out_effects);
748  }
749 
750 }
751 
753  bool did_something ;
754  set deleted_vertex = set_make(set_pointer);
755  do {
756  did_something=false;
757  statement deleted = statement_undefined;
759  if(!set_belong_p(deleted_vertex,v) && no_write_read_conflicts_p(vertex_successors(v))) {
761  if(statement_call_p(s) &&
762  !return_statement_p(s) &&
766  did_something=true;
767  deleted=s;
768  set_add_element(deleted_vertex,deleted_vertex,v);
769  break;
770  }
771  }
772  }
773 
774  if(!statement_undefined_p(deleted)) {
776  if(!set_belong_p(deleted_vertex,v)) {
778  FOREACH(SUCCESSOR,s,tmp) {
779  if(vertex_to_statement(successor_vertex(s)) == deleted )
781  }
782  }
783  }
784  }
785  } while(did_something);
786 }
787 
789 {
790  /* Get the code of the module. */
792  statement module_stat = (statement)db_get_memory_resource(DBR_CODE, module_name, true);
793  set_ordering_to_statement(module_stat);
795  set_current_module_statement( module_stat);
798 
800 
801  // buggy and incomplete
802  //do_sac_reduction_optimizations(dependence_graph);
804 
805  unnormalize_expression(module_stat);
806  module_reorder(module_stat);
807  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module_name, module_stat);
809 
810 
816 
817  return true;
818 }
int get_int_property(const string)
void write_effects(FILE *f, effects p)
Definition: effects.c:562
call make_call(entity a1, list a2)
Definition: ri.c:269
void free_reference(reference p)
Definition: ri.c:2050
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
bool statement_consistent_p(statement p)
Definition: ri.c:2195
language copy_language(language p)
LANGUAGE.
Definition: ri.c:1202
dimension make_dimension(expression a1, expression a2, list a3)
Definition: ri.c:565
instruction make_instruction_sequence(sequence _field_)
Definition: ri.c:1169
void free_expression(expression p)
Definition: ri.c:853
reference copy_reference(reference p)
REFERENCE.
Definition: ri.c:2047
void free_basic(basic p)
Definition: ri.c:107
sequence make_sequence(list a)
Definition: ri.c:2125
reductionInfo make_reductionInfo(reduction a1, intptr_t a2, entity a3)
Definition: sac_private.c:376
static graph dependence_graph
Definition: delay.c:93
bool simd_load_stat_p(statement)
Definition: delay.c:111
bool simd_store_stat_p(statement)
Definition: delay.c:119
static entity mod_ent
bdt base
Current expression.
Definition: bdt_read_paf.c:100
callees compute_callees(const statement stat)
Recompute the callees of a module statement.
Definition: callgraph.c:355
static graph dg
dg is the dependency graph ; FIXME : should not be static global ?
Definition: chains.c:124
bool clean_up_sequences(statement s)
Recursively clean up the statement sequences by fusing them if possible and by removing useless one.
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
#define conflict_sink(x)
Definition: dg.h:167
#define CONFLICT(x)
CONFLICT.
Definition: dg.h:134
#define dg_arc_label_conflicts(x)
Definition: dg.h:201
#define conflict_source(x)
Definition: dg.h:165
#define min(a, b)
#define max(a, b)
list load_proper_rw_effects_list(statement)
void reset_proper_rw_effects(void)
void set_proper_rw_effects(statement_effects)
void set_cumulated_rw_effects(statement_effects)
list load_cumulated_rw_effects_list(statement)
list effects_write_effects(list)
void reset_cumulated_rw_effects(void)
bool out_effects(const string)
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
#define effect_write_p(eff)
#define effect_read_p(eff)
#define effect_scalar_p(eff) entity_scalar_p(effect_entity(eff))
bool anywhere_effect_p(effect)
Is it an anywhere effect? ANYMMODULE:ANYWHERE
Definition: effects.c:346
bool io_effect_p(effect)
Definition: effects.c:501
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
bool empty_string_p(const char *s)
Definition: entity_names.c:239
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
char * get_string_property(const char *)
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
Definition: genC.h:285
void gen_full_free_list(list l)
Definition: genClib.c:1023
#define successor_vertex(x)
Definition: graph.h:118
#define successor_arc_label(x)
Definition: graph.h:116
struct _newgen_struct_graph_ * graph
Definition: graph.h:31
#define vertex_successors(x)
Definition: graph.h:154
#define SUCCESSOR(x)
SUCCESSOR.
Definition: graph.h:86
#define graph_vertices(x)
Definition: graph.h:82
#define VERTEX(x)
VERTEX.
Definition: graph.h:122
statement make_block_statement(list)
Make a block statement from a list of statement.
Definition: statement.c:616
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
Definition: statement.c:597
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
void gen_recurse_stop(void *obj)
Tells the recursion not to go in this object.
Definition: genClib.c:3251
gen_chunk * gen_get_ancestor(int, const void *)
return the first ancestor object found of the given type.
Definition: genClib.c:3560
void gen_null2(__attribute__((unused)) void *u1, __attribute__((unused)) void *u2)
idem with 2 args, to please overpeaky compiler checks
Definition: genClib.c:2758
bool gen_true2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
Definition: genClib.c:2785
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
instruction make_continue_instruction()
Creates a CONTINUE instruction, that is the FORTRAN nop, the ";" in C or the "pass" in Python for exa...
Definition: instruction.c:79
instruction make_assign_instruction(expression l, expression r)
Definition: instruction.c:87
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
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 POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
#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
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#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
list gen_full_copy_list(list l)
Copy a list structure with element copy.
Definition: list.c:535
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
list statement_block(statement)
Get the list of block statements of a statement sequence.
Definition: statement.c:1338
loop statement_loop(statement)
Get the loop of a statement.
Definition: statement.c:1374
call statement_call(statement)
Get the call of a statement.
Definition: statement.c:1406
bool statement_call_p(statement)
Definition: statement.c:364
bool empty_statement_or_continue_p(statement)
Return true if the statement is an empty instruction block or a continue or a recursive combination o...
Definition: statement.c:474
bool statement_loop_p(statement)
Definition: statement.c:349
statement update_statement_instruction(statement, instruction)
Replace the instruction in statement s by instruction i.
Definition: statement.c:3039
bool return_statement_p(statement)
Test if a statement is a C or Fortran "return".
Definition: statement.c:172
void insert_statement(statement, statement, bool)
This is the normal entry point.
Definition: statement.c:2570
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
Definition: statement.c:224
statement vertex_to_statement(vertex v)
Vertex_to_statement looks for the statement that is pointed to by vertex v.
Definition: util.c:45
#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
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
Definition: naming-local.h:101
#define same_string_p(s1, s2)
void set_free(set)
Definition: set.c:332
bool set_belong_p(const set, const void *)
Definition: set.c:194
@ set_pointer
Definition: newgen_set.h:44
set set_make(set_type)
Create an empty set of any type but hash_private.
Definition: set.c:102
set set_add_element(set, const set, const void *)
Definition: set.c:152
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
bool same_reduction_p(reduction r1, reduction r2)
Definition: reductions.c:611
void unnormalize_expression(void *st)
void unnormalize_expression(expression exp): puts all the normalized field of expressions in "st" to ...
Definition: normalize.c:452
static void rename_reduction_ref_walker(expression e, reductionInfo ri)
Definition: reductions.c:126
static void undo_rename_reference(reference r, reductionInfo ri)
Definition: reductions.c:115
static bool reduction_in_statement_p(reduction red, statement stat)
Definition: reductions.c:151
static entity make_reduction_vector_entity(reduction r)
Definition: reductions.c:64
static bool simd_gather_reduction(statement body, list reductions, list *reductions_info)
Definition: reductions.c:456
bool redundant_load_store_elimination(char *module_name)
Definition: reductions.c:788
static expression make_minval_expression(basic b)
Definition: reductions.c:221
static reductionInfo add_reduction(list *reds, reduction r)
The first part of the function check that the reduction is allowed.
Definition: reductions.c:85
static void rename_statement_reductions(statement s, list *reductions_info, list reductions)
This function gets the possible reduction thanks to load_cumulated_reductions() function.
Definition: reductions.c:163
static statement generate_compact(reductionInfo ri)
Definition: reductions.c:355
static bool no_write_read_conflicts_p(list succs)
Definition: reductions.c:716
static expression make_0val_expression(basic b)
Definition: reductions.c:243
static void do_redundant_load_store_elimination(graph dg)
Definition: reductions.c:752
static bool reduction_in_statement_walker(reference r, reduction_in_statement_param *p)
Definition: reductions.c:145
bool simd_remove_reductions(char *mod_name)
remove reductions by expanding reduced scalar to an array
Definition: reductions.c:571
static bool reduction_rewrite_filter(statement s, set skip)
Definition: reductions.c:557
bool sac_expression_reduction_p(expression e)
reductions.c
Definition: reductions.c:55
static expression make_1val_expression(basic b)
Definition: reductions.c:266
static statement generate_prelude(reductionInfo ri)
Definition: reductions.c:287
static bool potential_out_effects_p(statement s)
Definition: reductions.c:727
static void reductions_rewrite(statement s, set skip)
Definition: reductions.c:475
static expression make_maxval_expression(basic b)
Definition: reductions.c:199
static char * module
Definition: pips.c:74
void print_reference(reference r)
Definition: expression.c:142
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
void reset_cumulated_reductions(void)
bool reduction_star_p(reduction)
utils.c
Definition: utils.c:46
void set_cumulated_reductions(pstatement_reductions)
reductions load_cumulated_reductions(statement)
#define reduction_operator_sum_p(x)
@ is_reduction_operator_none
@ is_reduction_operator_min
@ is_reduction_operator_max
@ is_reduction_operator_csum
@ is_reduction_operator_prod
@ is_reduction_operator_or
@ is_reduction_operator_and
@ is_reduction_operator_sum
#define REDUCTION(x)
REDUCTION.
#define reduction_operator_tag(x)
#define reduction_op(x)
#define reduction_reference(x)
#define reductions_list(x)
static const char * prefix
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
#define make_expression_list(stats...)
#define MAX_OPERATOR_NAME
#define PLUS_OPERATOR_NAME
#define statement_block_p(stat)
#define call_to_statement(c)
#define AND_OPERATOR_NAME
FI: intrinsics are defined at a third place after bootstrap and effects! I guess the name should be d...
#define ADDRESS_OF_OPERATOR_NAME
#define module_language(e)
implemented as a macro to allow lhs
#define MULTIPLY_OPERATOR_NAME
#define OR_OPERATOR_NAME
#define PLUS_C_OPERATOR_NAME
#define MIN_OPERATOR_NAME
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
Definition: entity.c:1503
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
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
entity make_empty_subroutine(const char *name, language l)
Definition: entity.c:268
bool top_level_entity_p(entity e)
Check if the scope of entity e is global.
Definition: entity.c:1130
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression reference_to_expression(reference r)
Definition: expression.c:196
bool expression_call_p(expression e)
Definition: expression.c:415
expression float_to_expression(float c)
Definition: expression.c:1229
call expression_call(expression e)
Definition: expression.c:445
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188
bool reference_equal_p(reference r1, reference r2)
Definition: expression.c:1500
expression MakeUnaryCall(entity f, expression a)
Creates a call expression to a function with one argument.
Definition: expression.c:342
bool expression_reference_p(expression e)
Test if an expression is a reference.
Definition: expression.c:528
reference expression_reference(expression e)
Short cut, meaningful only if expression_reference_p(e) holds.
Definition: expression.c:1832
expression complex_to_expression(float re, float im)
Definition: expression.c:1234
entity expression_to_entity(expression e)
just returns the entity of an expression, or entity_undefined
Definition: expression.c:3140
expression bool_to_expression(bool b)
Definition: expression.c:1238
expression call_to_expression(call c)
Build an expression that call a function or procedure.
Definition: expression.c:309
void AddLocalEntityToDeclarations(entity, entity, statement)
Add the variable entity e to the list of variables of the function module.
Definition: variable.c:233
entity make_new_array_variable_with_prefix(const char *, entity, basic, list)
J'ai ameliore la fonction make_new_scalar_variable_with_prefix
Definition: variable.c:785
void RemoveLocalEntityFromDeclarations(entity, entity, statement)
Definition: variable.c:120
int entity_memory_size(entity)
Definition: size.c:239
bool formal_parameter_p(entity)
Definition: variable.c:1489
basic basic_of_reference(reference)
Retrieves the basic of a reference in a newly allocated basic object.
Definition: type.c:1459
#define loop_body(x)
Definition: ri.h:1644
@ is_basic_float
Definition: ri.h:572
@ is_basic_int
Definition: ri.h:571
@ is_basic_complex
Definition: ri.h:575
#define syntax_reference_p(x)
Definition: ri.h:2728
#define expression_domain
newgen_execution_domain_defined
Definition: ri.h:154
#define syntax_reference(x)
Definition: ri.h:2730
#define call_function(x)
Definition: ri.h:709
#define reference_variable(x)
Definition: ri.h:2326
#define basic_int(x)
Definition: ri.h:616
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define instruction_loop(x)
Definition: ri.h:1520
#define basic_tag(x)
Definition: ri.h:613
#define type_variable(x)
Definition: ri.h:2949
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
#define basic_undefined_p(x)
Definition: ri.h:557
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define entity_undefined_p(x)
Definition: ri.h:2762
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338
#define expression_undefined
Definition: ri.h:1223
@ is_instruction_whileloop
Definition: ri.h:1472
@ is_instruction_sequence
Definition: ri.h:1469
@ is_instruction_forloop
Definition: ri.h:1477
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define sequence_statements(x)
Definition: ri.h:2360
#define dimension_upper(x)
Definition: ri.h:982
#define reference_indices(x)
Definition: ri.h:2328
#define instruction_sequence(x)
Definition: ri.h:1514
#define instruction_forloop(x)
Definition: ri.h:1538
#define instruction_whileloop(x)
Definition: ri.h:1523
#define variable_dimensions(x)
Definition: ri.h:3122
#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 call_arguments(x)
Definition: ri.h:711
#define statement_undefined_p(x)
Definition: ri.h:2420
#define entity_type(x)
Definition: ri.h:2792
#define expression_syntax(x)
Definition: ri.h:1247
#define forloop_body(x)
Definition: ri.h:1372
#define statement_undefined
Definition: ri.h:2419
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
#define reductionInfo_reduction(x)
Definition: sac_private.h:451
#define reductionInfo_count(x)
Definition: sac_private.h:453
#define reductionInfo_undefined_p(x)
Definition: sac_private.h:427
#define reductionInfo_undefined
Definition: sac_private.h:426
#define REDUCTIONINFO(x)
REDUCTIONINFO.
Definition: sac_private.h:420
#define reductionInfo_vector(x)
Definition: sac_private.h:455
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
#define ifdebug(n)
Definition: sg.c:47
static size_t current
Definition: string.c:115
static string buffer
Definition: string.c:113
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
finds out expression with reduction
Definition: reductions.c:140