PIPS
optimize.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "linear.h"
#include "genC.h"
#include "ri.h"
#include "effects.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "effects-util.h"
#include "misc.h"
#include "properties.h"
#include "resources.h"
#include "pipsdbm.h"
#include "control.h"
#include "eole_private.h"
#include "expressions.h"
+ Include dependency graph for optimize.c:

Go to the source code of this file.

Data Structures

struct  optimization_strategy
 this structure defines a strategy for eole. More...
 
struct  extract_expr_t
 extract expressions with loop level information. More...
 
struct  binary_to_nary_t
 
struct  symetric_opertor_t
 
struct  cost_expression
 

Macros

#define DEBUG_NAME   "TRANSFORMATION_OPTIMIZE_EXPRESSIONS_DEBUG_LEVEL"
 
#define OUT_FILE_NAME   "/tmp/pips_to_eole"
 file name prefixes to deal with eole. More...
 
#define IN_FILE_NAME   "/tmp/eole_to_pips"
 
#define EOLE   "EOLE" /**eole binary */
 property names. More...
 
#define EOLE_FLAGS   "EOLE_FLAGS" /**default options */
 
#define EOLE_OPTIONS   "EOLE_OPTIONS" /**additionnal options */
 
#define SIZE_OF_BUFFER   100
 
#define MAX_NAME   "MAX"
 
#define MIN_NAME   "MIN"
 
#define GRAPH_PREFIX   "optimize_expressions_"
 
#define GRAPH_SUFFIX   ".daVinci"
 

Typedefs

typedef struct optimization_strategypoptimization_strategy
 
typedef struct extract_expr_textract_expr_p
 

Enumerations

enum  asocom_operator_t {
  not_asocom , is_plus , is_mult , is_max ,
  is_min , is_and , is_or
}
 switch binary to nary expressions where possible. More...
 

Functions

static string get_eole_command (const char *in, const char *out, const char *flags)
 returns the eole command to be executed in an allocated string. More...
 
static bool is_string_constant (entity e)
 
static void eole_okay_call_rwt (call c, bool *okay)
 
static bool eole_manageable_expression (expression e)
 
static void add_one_more_expression (expression e, extract_expr_p context)
 
static bool loop_flt (loop l, extract_expr_p context)
 
static void loop_rwt (loop l, extract_expr_p context)
 
static bool call_filter (call c, extract_expr_p context)
 rhs expressions of assignments. More...
 
static bool expr_filter (expression e, extract_expr_p context)
 other expressions may be found in loops and so? More...
 
static list get_list_of_rhs (statement s)
 of expressionwithlevel More...
 
static void write_list_of_rhs (FILE *out, list le)
 export a list of expression of the current module. More...
 
static void write_to_eole (const char *module, list le, const char *file_name)
 export expressions to eole thru the newgen format. More...
 
static string read_and_allocate_string_from_file (FILE *file)
 
static void read_new_entities_from_eole (FILE *file, const char *module)
 import a list of entity that have been created during the eole transformations and create them More...
 
static list read_from_eole (const char *module, const char *file_name)
 import expressions from eole. More...
 
static void swap_syntax_in_expression (list lcode, list lnew)
 swap term to term syntax field in expression list, as a side effect... More...
 
static void apply_eole_on_statement (const char *module_name, statement s, const char *flags)
 apply eole on all expressions in s. More...
 
static expression is_uminus (expression e)
 returns B if uminus(B), else 0 More...
 
static void call_simplify_rwt (call c)
 
static void generate_bminus (statement s)
 
static void optimize_simplify_patterns (statement s)
 look for some expressions in s and simplify some patterns. More...
 
static bool is_inverse (expression e)
 
static void call_nary_rwt (call c)
 
static void optimize_simplify_nary_patterns (statement s)
 
static double expression_gravity_rc (expression e, double depth)
 forward substitute if only there once. More...
 
static double expression_gravity (expression e)
 
static double expression_gravity_inv (expression e)
 
static entity binary_to_nary (entity e)
 
static bool nary_operator_p (entity e)
 
static bool nary_call_flt (call c)
 top-down: switch calls to nary form. More...
 
static void nary_call_rwt (call c)
 bottom-up: + + -> + More...
 
void naryfication_of_expressions (statement s)
 optimize.c More...
 
static symetric_opertor_twhat_operator (entity e, int which_one)
 
entity inverse_operator_of (entity e)
 
static bool inv_call_flt (call c)
 
void inverse_normalization_of_expressions (statement s)
 
static int cost_expression_cmp (const void *v1, const void *v2)
 comparison function for qsort. More...
 
static void debug_cost_expression_array (string s, cost_expression *tce, int size)
 debug function More...
 
static cost_expressionlist_of_expressions_to_array (list le, double(*cost)(expression))
 build an cost_expression array from an expression list. More...
 
static void insert_sorted_into_array (cost_expression *tce, int n, cost_expression ce)
 insert ce in tce[0..n-1] by decreassing order. More...
 
static void insert_last_into_array (cost_expression *tce, int n, cost_expression ce)
 simply insert. More...
 
static void call_rwt (call c)
 apply huffman balancing algorithm if it is a call to huffman_nary_operator. More...
 
static void build_binary_operators_with_huffman (statement s, entity nary_operator, entity binary_operator, double(*cost)(expression), bool mode)
 apply the huffman balancing on every call to nary_operator and build calls to binary_operator instead, with cost to chose. More...
 
static void switch_nary_to_binary (statement s)
 switch nary operators to binary ones. More...
 
static void set_current_optimization_strategy (void)
 
static void reset_current_optimization_strategy (void)
 
static void davinci_dump_expressions (const char *module_name, string phase, statement s)
 dump all expressions in s as davinci graphs. More...
 
static void do_convert_to_c_operator (call c)
 
void convert_to_c_operators (void *v)
 
static void do_convert_to_standard_operators (call c)
 
void convert_to_standard_operators (void *v)
 
bool optimize_expressions (const char *module_name)
 pipsmake interface to apply expression optimization according to various strategy. More...
 

Variables

static poptimization_strategy strategy = NULL
 current strategy. More...
 
static entity bplus = NULL
 A + (–B) -> A - B FMA -> FMS. More...
 
static entity uminus = NULL
 
static entity bminus = NULL
 
static entity fmaop = NULL
 
static entity fmsop = NULL
 
static entity multiply = NULL
 
static entity inverse = NULL
 
static entity divide = NULL
 
static binary_to_nary_t bton []
 
static symetric_opertor_t symop []
 
static entity huffman_nary_operator = NULL
 switch nary to binary with huffman algorithm. More...
 
static entity huffman_binary_operator = NULL
 
static double(* huffman_cost )(expression) = NULL
 
static bool huffman_mode = true
 true: Huffman. More...
 
static optimization_strategy strategies []
 predefined optimization strategies. More...
 

Macro Definition Documentation

◆ DEBUG_NAME

#define DEBUG_NAME   "TRANSFORMATION_OPTIMIZE_EXPRESSIONS_DEBUG_LEVEL"

Definition at line 50 of file optimize.c.

◆ EOLE

#define EOLE   "EOLE" /**eole binary */

property names.

Definition at line 106 of file optimize.c.

◆ EOLE_FLAGS

#define EOLE_FLAGS   "EOLE_FLAGS" /**default options */

Definition at line 107 of file optimize.c.

◆ EOLE_OPTIONS

#define EOLE_OPTIONS   "EOLE_OPTIONS" /**additionnal options */

Definition at line 108 of file optimize.c.

◆ GRAPH_PREFIX

#define GRAPH_PREFIX   "optimize_expressions_"

Definition at line 1309 of file optimize.c.

◆ GRAPH_SUFFIX

#define GRAPH_SUFFIX   ".daVinci"

Definition at line 1310 of file optimize.c.

◆ IN_FILE_NAME

#define IN_FILE_NAME   "/tmp/eole_to_pips"

Definition at line 102 of file optimize.c.

◆ MAX_NAME

#define MAX_NAME   "MAX"

Definition at line 722 of file optimize.c.

◆ MIN_NAME

#define MIN_NAME   "MIN"

Definition at line 723 of file optimize.c.

◆ OUT_FILE_NAME

#define OUT_FILE_NAME   "/tmp/pips_to_eole"

file name prefixes to deal with eole.

/tmp should be fast (may be mapped into memory).

Definition at line 101 of file optimize.c.

◆ SIZE_OF_BUFFER

#define SIZE_OF_BUFFER   100

Definition at line 256 of file optimize.c.

Typedef Documentation

◆ extract_expr_p

typedef struct extract_expr_t * extract_expr_p

◆ poptimization_strategy

Enumeration Type Documentation

◆ asocom_operator_t

switch binary to nary expressions where possible.

this is normally done in eole anyway.

Enumerator
not_asocom 
is_plus 

0

is_mult 
is_max 
is_min 
is_and 
is_or 

Definition at line 706 of file optimize.c.

707 {
708  not_asocom, /* 0 */
709  is_plus, is_mult,
710  is_max, is_min,
711  is_and, is_or
712 }
@ is_mult
Definition: optimize.c:709
@ is_plus
0
Definition: optimize.c:709
@ is_max
Definition: optimize.c:710
@ is_min
Definition: optimize.c:710
@ is_and
Definition: optimize.c:711
@ not_asocom
Definition: optimize.c:708
@ is_or
Definition: optimize.c:711

Function Documentation

◆ add_one_more_expression()

static void add_one_more_expression ( expression  e,
extract_expr_p  context 
)
static

Definition at line 166 of file optimize.c.

167 {
168  expressionwithlevel ewl =
170  context->rhs = CONS(EXPRESSIONWITHLEVEL, ewl, context->rhs);
171 }
expressionwithlevel make_expressionwithlevel(list a1, expression a2)
Definition: eole_private.c:94
#define EXPRESSIONWITHLEVEL(x)
EXPRESSIONWITHLEVEL.
Definition: eole_private.h:105
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
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
Definition: delay.c:253

References CONS, EXPRESSIONWITHLEVEL, gen_copy_seq(), gen_nreverse(), and make_expressionwithlevel().

Referenced by call_filter(), and expr_filter().

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

◆ apply_eole_on_statement()

static void apply_eole_on_statement ( const char *  module_name,
statement  s,
const char *  flags 
)
static

apply eole on all expressions in s.

of expressionwithlevel/expression

not empty list

create temporary files

write informations in out file for EOLE

run eole (Evaluation Optimization for Loops and Expressions) as a separate process.

read optimized expressions from eole

replace the syntax values inside le by the syntax values from ln

must now free the useless expressions

remove temorary files and free allocated memory.

free strings

free lists

Definition at line 383 of file optimize.c.

384 {
385  list /* of expressionwithlevel/expression */ le, ln;
386 
387  ln = NIL;
388  le = get_list_of_rhs(s);
389 
390  if (gen_length(le)) /* not empty list */
391  {
392  string in, out, cmd;
393 
394  /* create temporary files */
397 
398  /* write informations in out file for EOLE */
400 
401  /* run eole (Evaluation Optimization for Loops and Expressions)
402  * as a separate process.
403  */
404  cmd = get_eole_command(in, out, flags);
405 
406  pips_debug(2, "executing: %s\n", cmd);
407 
408  safe_system(cmd);
409 
410  /* read optimized expressions from eole */
411  ln = read_from_eole(module_name, in);
412 
413  /* replace the syntax values inside le by the syntax values from ln */
415 
416  /* must now free the useless expressions */
417 
418 
419  /* remove temorary files and free allocated memory.
420  */
421  safe_unlink(out);
422  safe_unlink(in);
423 
424  /* free strings */
425  free(out), out = NULL;
426  free(in), in = NULL;
427  free(cmd), cmd = NULL;
428  }
429  else
430  pips_debug(3, "no expression for module %s\n", module_name);
431 
432  pips_debug(3,"EOLE transformations done for module %s\n", module_name);
433 
434  /* free lists */
435  gen_free_list(ln);
436  gen_free_list(le);
437 }
static FILE * out
Definition: alias_check.c:128
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
char * safe_new_tmp_file(char *prefix)
SunOS forgets to declare this one.
Definition: file.c:935
void safe_unlink(const char *file_name)
Delete the given file.
Definition: file.c:852
void free(void *)
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
size_t gen_length(const list l)
Definition: list.c:150
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
void safe_system(string)
system.c
Definition: system.c:38
static void write_to_eole(const char *module, list le, const char *file_name)
export expressions to eole thru the newgen format.
Definition: optimize.c:243
#define OUT_FILE_NAME
file name prefixes to deal with eole.
Definition: optimize.c:101
static list read_from_eole(const char *module, const char *file_name)
import expressions from eole.
Definition: optimize.c:335
#define IN_FILE_NAME
Definition: optimize.c:102
static list get_list_of_rhs(statement s)
of expressionwithlevel
Definition: optimize.c:210
static string get_eole_command(const char *in, const char *out, const char *flags)
returns the eole command to be executed in an allocated string.
Definition: optimize.c:114
static void swap_syntax_in_expression(list lcode, list lnew)
swap term to term syntax field in expression list, as a side effect...
Definition: optimize.c:361
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References free(), gen_free_list(), gen_length(), get_eole_command(), get_list_of_rhs(), IN_FILE_NAME, module_name(), NIL, out, OUT_FILE_NAME, pips_debug, read_from_eole(), safe_new_tmp_file(), safe_system(), safe_unlink(), swap_syntax_in_expression(), and write_to_eole().

Referenced by optimize_expressions().

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

◆ binary_to_nary()

static entity binary_to_nary ( entity  e)
static

Definition at line 748 of file optimize.c.

749 {
750  const char* lname = entity_local_name(e);
751  binary_to_nary_t * pbn;
752 
753  for (pbn = bton; pbn->binary; pbn++)
754  if (same_string_p(pbn->binary, lname))
755  return entity_intrinsic(pbn->nary);
756 
757  return e;
758 }
#define same_string_p(s1, s2)
static binary_to_nary_t bton[]
Definition: optimize.c:725
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
static int lname(char *s, int look_for_entry)
check for keywords for subprograms return 0 if comment card, 1 if found name and put in arg string.
Definition: split_file.c:283

References binary_to_nary_t::binary, bton, entity_intrinsic(), entity_local_name(), lname(), binary_to_nary_t::nary, and same_string_p.

Referenced by nary_call_flt().

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

◆ build_binary_operators_with_huffman()

static void build_binary_operators_with_huffman ( statement  s,
entity  nary_operator,
entity  binary_operator,
double(*)(expression cost,
bool  mode 
)
static

apply the huffman balancing on every call to nary_operator and build calls to binary_operator instead, with cost to chose.

Definition at line 1108 of file optimize.c.

1114 {
1115  huffman_nary_operator = nary_operator;
1116  huffman_binary_operator = binary_operator;
1117  huffman_cost = cost;
1118  huffman_mode = mode;
1119 
1120  ifdebug(8) print_statement(s);
1121 
1124  NULL);
1125 
1126  huffman_nary_operator = NULL;
1127  huffman_binary_operator = NULL;
1128  huffman_cost = NULL;
1129  huffman_mode = true;
1130 }
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
Definition: genClib.c:3428
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
#define true
Definition: newgen_types.h:81
static entity huffman_binary_operator
Definition: optimize.c:950
static entity huffman_nary_operator
switch nary to binary with huffman algorithm.
Definition: optimize.c:949
static double(* huffman_cost)(expression)
Definition: optimize.c:951
static void call_rwt(call c)
apply huffman balancing algorithm if it is a call to huffman_nary_operator.
Definition: optimize.c:1046
static bool huffman_mode
true: Huffman.
Definition: optimize.c:955
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
#define call_domain
newgen_callees_domain_defined
Definition: ri.h:58
struct _newgen_struct_mode_ * mode
Definition: ri.h:231
#define ifdebug(n)
Definition: sg.c:47

References call_domain, call_rwt(), gen_multi_recurse(), gen_true(), huffman_binary_operator, huffman_cost, huffman_mode, huffman_nary_operator, ifdebug, and print_statement().

Referenced by switch_nary_to_binary().

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

◆ call_filter()

static bool call_filter ( call  c,
extract_expr_p  context 
)
static

rhs expressions of assignments.

put all manageable expressions arguments...

Definition at line 191 of file optimize.c.

192 {
193  /* put all manageable expressions arguments... */
194  MAP(EXPRESSION, e,
196  call_arguments(c));
197  return false;
198 }
#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
static void add_one_more_expression(expression e, extract_expr_p context)
Definition: optimize.c:166
static bool eole_manageable_expression(expression e)
Definition: optimize.c:147
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define call_arguments(x)
Definition: ri.h:711

References add_one_more_expression(), call_arguments, eole_manageable_expression(), EXPRESSION, and MAP.

Referenced by get_list_of_rhs().

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

◆ call_nary_rwt()

static void call_nary_rwt ( call  c)
static

it is a multiply

nothing to change

Definition at line 562 of file optimize.c.

563 {
564  entity func = call_function(c);
565  list numerator = NIL, denominator = NIL;
566  int nnum, nden;
567  expression enu, eden;
568 
569  if (func != multiply) return;
570  /* it is a multiply */
571 
572  MAP(EXPRESSION, e,
573  {
574  if (is_inverse(e))
575  denominator =
576  CONS(EXPRESSION,
578  denominator);
579  else
580  numerator = CONS(EXPRESSION, e, numerator);
581  },
582  call_arguments(c));
583 
584  nden = gen_length(denominator);
585  nnum = gen_length(numerator);
586 
587  switch (nden)
588  {
589  case 0: /* nothing to change */
590  gen_free_list(denominator);
591  gen_free_list(numerator);
592  return;
593  case 1:
594  eden = EXPRESSION(CAR(denominator));
595  gen_free_list(denominator);
596  break;
597  default:
598  eden = call_to_expression(make_call(multiply, denominator));
599  break;
600  }
601 
602  switch (nnum)
603  {
604  case 0:
605  enu = int_to_expression(1);
606  break;
607  case 1:
608  enu = EXPRESSION(CAR(numerator));
609  gen_free_list(numerator);
610  break;
611  default:
612  enu = call_to_expression(make_call(multiply, numerator));
613  break;
614  }
615 
616  call_function(c) = divide;
618  call_arguments(c) = CONS(EXPRESSION, enu, CONS(EXPRESSION, eden, NIL));
619 }
call make_call(entity a1, list a2)
Definition: ri.c:269
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
static entity divide
Definition: optimize.c:553
static entity multiply
Definition: optimize.c:551
static bool is_inverse(expression e)
Definition: optimize.c:555
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
expression call_to_expression(call c)
Build an expression that call a function or procedure.
Definition: expression.c:309
#define call_function(x)
Definition: ri.h:709
#define syntax_call(x)
Definition: ri.h:2736
#define expression_syntax(x)
Definition: ri.h:1247

References call_arguments, call_function, call_to_expression(), CAR, CONS, divide, EXPRESSION, expression_syntax, gen_free_list(), gen_length(), int_to_expression(), is_inverse(), make_call(), MAP, multiply, NIL, and syntax_call.

Referenced by optimize_simplify_nary_patterns().

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

◆ call_rwt()

static void call_rwt ( call  c)
static

apply huffman balancing algorithm if it is a call to huffman_nary_operator.

the prettyprint may only reflect this if the PRETTYPRINT_ALL_PARENTHESES property is set to true.

let us switch to a binary tree.

the call is already binary.

else

drop initial list:

last one is done in place.

Definition at line 1046 of file optimize.c.

1047 {
1049  {
1050  /* let us switch to a binary tree. */
1051  list args = call_arguments(c);
1052  int nargs = gen_length(args);
1053  cost_expression * tce;
1054 
1055  pips_debug(4, "dealing with operator %s\n",
1057 
1058  //pips_assert("several arguments to nary operator", nargs>=2);
1059  if (nargs < 2)
1060  {
1061  fprintf(stderr,"\n[call_rwt] --- (nargs=%d) < 2; Call = %s \n",
1062  nargs, entity_name(call_function(c)));
1064  return;
1065  }
1066 
1067  if (nargs==2) /* the call is already binary. */
1068  {
1070  return;
1071  }
1072  /* else */
1073 
1075  /* drop initial list: */
1076  gen_free_list(args), args = NIL, call_arguments(c) = NIL;
1077 
1078  while (nargs>2)
1079  {
1080  cost_expression ce;
1082  tce[nargs-1].expr, tce[nargs-2].expr);
1083  ce.cost = huffman_cost(ce.expr);
1084 
1085  if (huffman_mode) insert_sorted_into_array(tce, nargs-2, ce);
1086  else insert_last_into_array(tce, nargs-2, ce);
1087 
1088  ifdebug(3) debug_cost_expression_array("insert done", tce, nargs-1);
1089 
1090  nargs--;
1091  }
1092 
1093  /* last one is done in place. */
1095  call_arguments(c) = CONS(EXPRESSION, tce[0].expr,
1096  CONS(EXPRESSION, tce[1].expr, NIL));
1097  free(tce), tce = NULL;
1098  }
1099  else
1100  pips_debug(3,"non huffman operator : %s\n ",
1102 }
static void insert_last_into_array(cost_expression *tce, int n, cost_expression ce)
simply insert.
Definition: optimize.c:1035
static void insert_sorted_into_array(cost_expression *tce, int n, cost_expression ce)
insert ce in tce[0..n-1] by decreassing order.
Definition: optimize.c:1024
static void debug_cost_expression_array(string s, cost_expression *tce, int size)
debug function
Definition: optimize.c:980
static cost_expression * list_of_expressions_to_array(list le, double(*cost)(expression))
build an cost_expression array from an expression list.
Definition: optimize.c:998
void print_expression(expression e)
no file descriptor is passed to make is easier to use in a debugging stage.
Definition: expression.c:58
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354
#define entity_name(x)
Definition: ri.h:2790
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
else
Definition: set.c:239
expression expr
Definition: optimize.c:959

References call_arguments, call_function, CAR, CONS, cost_expression::cost, debug_cost_expression_array(), entity_local_name(), entity_name, cost_expression::expr, EXPRESSION, fprintf(), free(), gen_free_list(), gen_length(), huffman_binary_operator, huffman_cost, huffman_mode, huffman_nary_operator, ifdebug, insert_last_into_array(), insert_sorted_into_array(), list_of_expressions_to_array(), MakeBinaryCall(), NIL, pips_debug, and print_expression().

Referenced by build_binary_operators_with_huffman().

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

◆ call_simplify_rwt()

static void call_simplify_rwt ( call  c)
static

memory leak

memory leak

FMA(A,B,-C) => FMS(A,B,C)

avoid memory leak

Definition at line 466 of file optimize.c.

467 {
468  if (call_function(c)==bplus)
469  {
470  list la = call_arguments(c);
471  expression e1, e2, me;
472 
473  pips_assert("2 args to binary plus", gen_length(la)==2);
474 
475  e1 = EXPRESSION(CAR(la));
476  e2 = EXPRESSION(CAR(CDR(la)));
477 
478  me = is_uminus(e2);
479  if (me)
480  {
481  EXPRESSION_(CAR(CDR(la))) = me; /* memory leak */
482  call_function(c) = bminus;
483  return;
484  }
485 
486  me = is_uminus(e1);
487  if (me)
488  {
489  EXPRESSION_(CAR(CDR(la))) = me;
490  EXPRESSION_(CAR(la)) = e2; /* memory leak */
491  call_function(c) = bminus;
492  return;
493  }
494  }
495  else if (call_function(c)==fmaop) /* FMA(A,B,-C) => FMS(A,B,C) */
496  {
497  list la = call_arguments(c);
498  expression e3 = EXPRESSION(CAR(CDR(CDR(la)))), me;
499 
500  me = is_uminus(e3);
501  if (me)
502  {
503  /* avoid memory leak */
506  free_expression(e3);
507 
508  call_function(c) = fmsop;
509  EXPRESSION_(CAR(CDR(CDR(la)))) = me;
510  }
511  }
512 }
void free_expression(expression p)
Definition: ri.c:853
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
static entity fmaop
Definition: optimize.c:449
static entity fmsop
Definition: optimize.c:450
static expression is_uminus(expression e)
returns B if uminus(B), else 0
Definition: optimize.c:454
static entity bplus
A + (–B) -> A - B FMA -> FMS.
Definition: optimize.c:446
static entity bminus
Definition: optimize.c:448
#define EXPRESSION_(x)
Definition: ri.h:1220

References bminus, bplus, call_arguments, call_function, CAR, CDR, EXPRESSION, EXPRESSION_, expression_syntax, fmaop, fmsop, free_expression(), gen_free_list(), gen_length(), is_uminus(), NIL, pips_assert, and syntax_call.

Referenced by generate_bminus().

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

◆ convert_to_c_operators()

void convert_to_c_operators ( void *  v)

Definition at line 1343 of file optimize.c.

1343  {
1345 }
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
static void do_convert_to_c_operator(call c)
Definition: optimize.c:1336

References call_domain, do_convert_to_c_operator(), gen_recurse, and gen_true().

Referenced by do_gather_all_expressions_perms(), and optimize_expressions().

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

◆ convert_to_standard_operators()

void convert_to_standard_operators ( void *  v)

Definition at line 1364 of file optimize.c.

1364  {
1366 }
static void do_convert_to_standard_operators(call c)
Definition: optimize.c:1348

References call_domain, do_convert_to_standard_operators(), gen_recurse, and gen_true().

Referenced by expression_substitution(), optimize_expressions(), and set_pattern().

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

◆ cost_expression_cmp()

static int cost_expression_cmp ( const void *  v1,
const void *  v2 
)
static

comparison function for qsort.

descending order.

when they are equals another criterion may be used, so as to favor double loads (with neighbor references).

Definition at line 965 of file optimize.c.

966 {
967  cost_expression * c1 = (cost_expression *) v1;
968  cost_expression * c2 = (cost_expression *) v2;
969  if (c1->cost==c2->cost)
970  /* when they are equals another criterion may be used, so as
971  to favor double loads (with neighbor references).
972  */
973  return 0;
974  return 2*(c1->cost<c2->cost) - 1;
975 }

References cost_expression::cost.

Referenced by list_of_expressions_to_array().

+ Here is the caller graph for this function:

◆ davinci_dump_expressions()

static void davinci_dump_expressions ( const char *  module_name,
string  phase,
statement  s 
)
static

dump all expressions in s as davinci graphs.

filename: $current.database/$module/$prefix_$phase.$suffix

directory MUST exist

Definition at line 1314 of file optimize.c.

1316 {
1317  string dir, filename;
1318  FILE * out;
1319 
1320  /* filename: $current.database/$module/$prefix_$phase.$suffix
1321  */
1323  filename = strdup(concatenate
1324  (dir, "/", module_name, "/", GRAPH_PREFIX, phase, GRAPH_SUFFIX, NULL));
1325  free(dir), dir = NULL;
1326 
1327  out = safe_fopen(filename, "w"); /* directory MUST exist */
1329  safe_fclose(out, filename);
1330 
1331  free(filename), filename = NULL;
1332 }
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
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define GRAPH_SUFFIX
Definition: optimize.c:1310
#define GRAPH_PREFIX
Definition: optimize.c:1309
string db_get_current_workspace_directory(void)
Definition: workspace.c:96
void davinci_dump_all_expressions(FILE *out, statement s)
dump all expressions in s to out.
Definition: expression.c:2728
char * strdup()

References concatenate(), davinci_dump_all_expressions(), db_get_current_workspace_directory(), free(), GRAPH_PREFIX, GRAPH_SUFFIX, module_name(), out, safe_fclose(), safe_fopen(), and strdup().

Referenced by optimize_expressions().

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

◆ debug_cost_expression_array()

static void debug_cost_expression_array ( string  s,
cost_expression tce,
int  size 
)
static

debug function

print informations from an cost_expressions array

Definition at line 980 of file optimize.c.

983 {
984  int i;
985  pips_debug(9,"%s \n", s);
986  pips_debug(9," %d elements in cost_expression array \n", size);
987 
988  for (i=0; i<size; i++) {
989  pips_debug(9," - %d - expression : ", i);
990  print_expression(tce[i].expr);
991  pips_debug(9,"\n - %d - cost : %f \n", i, tce[i].cost);
992  }
993 }

References pips_debug, and print_expression().

Referenced by call_rwt(), and list_of_expressions_to_array().

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

◆ do_convert_to_c_operator()

static void do_convert_to_c_operator ( call  c)
static

Definition at line 1336 of file optimize.c.

1336  {
1337  entity op = call_function(c);
1338  if(ENTITY_PLUS_P(op))
1340  if(ENTITY_MINUS_P(op))
1342 }
#define ENTITY_MINUS_P(e)
#define ENTITY_PLUS_P(e)
#define MINUS_C_OPERATOR_NAME
#define PLUS_C_OPERATOR_NAME

References call_function, entity_intrinsic(), ENTITY_MINUS_P, ENTITY_PLUS_P, MINUS_C_OPERATOR_NAME, and PLUS_C_OPERATOR_NAME.

Referenced by convert_to_c_operators().

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

◆ do_convert_to_standard_operators()

static void do_convert_to_standard_operators ( call  c)
static

Definition at line 1348 of file optimize.c.

1348  {
1349  entity op = call_function(c);
1350  if(ENTITY_PLUS_C_P(op) || ENTITY_MINUS_C_P(op) ) {
1353  if(!basic_pointer_p(b0) && !basic_pointer_p(b1)) {
1354  if(ENTITY_PLUS_C_P(op))
1356  if(ENTITY_MINUS_C_P(op))
1358  }
1359  free_basic(b0);
1360  free_basic(b1);
1361  }
1362 }
void free_basic(basic p)
Definition: ri.c:107
#define binary_call_rhs(c)
#define MINUS_OPERATOR_NAME
#define PLUS_OPERATOR_NAME
#define ENTITY_PLUS_C_P(e)
#define ENTITY_MINUS_C_P(e)
#define binary_call_lhs(c)
basic basic_of_expression(expression)
basic basic_of_expression(expression exp): Makes a basic of the same basic as the expression "exp".
Definition: type.c:1383
#define basic_pointer_p(x)
Definition: ri.h:635
Value b1
booleen indiquant quel membre est en cours d'analyse
Definition: sc_gram.c:105

References b1, basic_of_expression(), basic_pointer_p, binary_call_lhs, binary_call_rhs, call_function, entity_intrinsic(), ENTITY_MINUS_C_P, ENTITY_PLUS_C_P, free_basic(), MINUS_OPERATOR_NAME, and PLUS_OPERATOR_NAME.

Referenced by convert_to_standard_operators().

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

◆ eole_manageable_expression()

static bool eole_manageable_expression ( expression  e)
static

Definition at line 147 of file optimize.c.

148 {
149  bool okay = true;
150  gen_context_multi_recurse(e, &okay,
152  NULL);
153  return okay;
154 }
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
Definition: genClib.c:3373
static void eole_okay_call_rwt(call c, bool *okay)
Definition: optimize.c:139

References call_domain, eole_okay_call_rwt(), gen_context_multi_recurse(), and gen_true().

Referenced by call_filter(), and expr_filter().

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

◆ eole_okay_call_rwt()

static void eole_okay_call_rwt ( call  c,
bool okay 
)
static

IMPLIED-DO ? others ?

Definition at line 139 of file optimize.c.

140 {
142  *okay = false;
143 
144  /* IMPLIED-DO ? others ? */
145 }
static bool is_string_constant(entity e)
Definition: optimize.c:127

References call_function, and is_string_constant().

Referenced by eole_manageable_expression().

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

◆ expr_filter()

static bool expr_filter ( expression  e,
extract_expr_p  context 
)
static

other expressions may be found in loops and so?

Definition at line 202 of file optimize.c.

203 {
206  return false;
207 }

References add_one_more_expression(), and eole_manageable_expression().

Referenced by get_list_of_rhs().

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

◆ expression_gravity()

static double expression_gravity ( expression  e)
static

Definition at line 691 of file optimize.c.

692 {
693  return expression_gravity_rc(e, 0.0E0);
694 }
static double expression_gravity_rc(expression e, double depth)
forward substitute if only there once.
Definition: optimize.c:677

References expression_gravity_rc().

Referenced by expression_gravity_inv().

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

◆ expression_gravity_inv()

static double expression_gravity_inv ( expression  e)
static

Definition at line 696 of file optimize.c.

697 {
698  return -expression_gravity(e);
699 }
static double expression_gravity(expression e)
Definition: optimize.c:691

References expression_gravity().

+ Here is the call graph for this function:

◆ expression_gravity_rc()

static double expression_gravity_rc ( expression  e,
double  depth 
)
static

forward substitute if only there once.

not implemented. WG

?

too simple?

Definition at line 677 of file optimize.c.

678 {
679  double cost = 0.0E0;
680  syntax s = expression_syntax(e);
681  if (syntax_call_p(s))
682  {
683  MAP(EXPRESSION, e,
684  cost += expression_gravity_rc(e, depth+1.0E0), /* ? */
686  cost += 1.0E0; /* too simple? */
687  }
688  return cost;
689 }
#define syntax_call_p(x)
Definition: ri.h:2734
static int depth
la sequence de nids

References call_arguments, depth, EXPRESSION, expression_syntax, MAP, syntax_call, and syntax_call_p.

Referenced by expression_gravity().

+ Here is the caller graph for this function:

◆ generate_bminus()

static void generate_bminus ( statement  s)
static

Definition at line 514 of file optimize.c.

515 {
521 
523 
524  bplus = NULL;
525  uminus = NULL;
526  bminus = NULL;
527  fmaop = NULL;
528  fmsop = NULL;
529 }
static void call_simplify_rwt(call c)
Definition: optimize.c:466
static entity uminus
Definition: optimize.c:447
#define EOLE_FMA_OPERATOR_NAME
These operators are used within the optimize transformation in order to manipulate operators such as ...
#define EOLE_FMS_OPERATOR_NAME
#define UNARY_MINUS_OPERATOR_NAME

References bminus, bplus, call_domain, call_simplify_rwt(), entity_intrinsic(), EOLE_FMA_OPERATOR_NAME, EOLE_FMS_OPERATOR_NAME, fmaop, fmsop, gen_recurse, gen_true(), MINUS_OPERATOR_NAME, PLUS_OPERATOR_NAME, uminus, and UNARY_MINUS_OPERATOR_NAME.

Referenced by optimize_simplify_patterns().

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

◆ get_eole_command()

static string get_eole_command ( const char *  in,
const char *  out,
const char *  flags 
)
static

returns the eole command to be executed in an allocated string.

Parameters
outinput file from eole.
flagsoutput file to eole.

Definition at line 113 of file optimize.c.

117 {
119  flags, " ",
121  " -S ", strategy->eole_strategy,
122  " -o ", in, " ", out, NULL));
123 }
char * get_string_property(const char *)
#define EOLE_OPTIONS
Definition: optimize.c:108
static poptimization_strategy strategy
current strategy.
Definition: optimize.c:94
#define EOLE
property names.
Definition: optimize.c:106
string eole_strategy
EOLE.
Definition: optimize.c:69

References concatenate(), EOLE, EOLE_OPTIONS, optimization_strategy::eole_strategy, get_string_property(), out, strategy, and strdup().

Referenced by apply_eole_on_statement().

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

◆ get_list_of_rhs()

static list get_list_of_rhs ( statement  s)
static

of expressionwithlevel

Definition at line 210 of file optimize.c.

211 {
213 
214  context.rhs = NIL;
215  context.indices = NIL;
216 
221  NULL);
222 
223  pips_assert("no indices", context.indices==NIL);
224 
225  return gen_nreverse(context.rhs);
226 }
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
static void loop_rwt(loop l, extract_expr_p context)
Definition: optimize.c:180
static bool expr_filter(expression e, extract_expr_p context)
other expressions may be found in loops and so?
Definition: optimize.c:202
static bool call_filter(call c, extract_expr_p context)
rhs expressions of assignments.
Definition: optimize.c:191
static bool loop_flt(loop l, extract_expr_p context)
Definition: optimize.c:173
#define expression_domain
newgen_execution_domain_defined
Definition: ri.h:154
#define loop_domain
newgen_language_domain_defined
Definition: ri.h:218
extract expressions with loop level information.
Definition: optimize.c:161

References call_domain, call_filter(), expr_filter(), expression_domain, gen_context_multi_recurse(), gen_nreverse(), gen_null(), loop_domain, loop_flt(), loop_rwt(), NIL, and pips_assert.

Referenced by apply_eole_on_statement().

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

◆ insert_last_into_array()

static void insert_last_into_array ( cost_expression tce,
int  n,
cost_expression  ce 
)
static

simply insert.

Definition at line 1035 of file optimize.c.

1036 {
1037  tce[n] = ce;
1038 }

Referenced by call_rwt().

+ Here is the caller graph for this function:

◆ insert_sorted_into_array()

static void insert_sorted_into_array ( cost_expression tce,
int  n,
cost_expression  ce 
)
static

insert ce in tce[0..n-1] by decreassing order.

find where to insert.

shift tail.

insert.

Definition at line 1024 of file optimize.c.

1025 {
1026  int i=0;
1027  while (i<n && ce.cost<tce[i].cost) i++; /* find where to insert. */
1028  while (n>=i) tce[n]=tce[n-1], n--; /* shift tail. */
1029  tce[i] = ce; /* insert. */
1030 }

References cost_expression::cost.

Referenced by call_rwt().

+ Here is the caller graph for this function:

◆ inv_call_flt()

static bool inv_call_flt ( call  c)
static

switch asymetric operation if needed

should use the type_checker results... maybe it could be implemented also as an analyses and not only a transformation? Well, I don't know how to store expression to type data, as expressions cannot be shared and are not "named" as statements are. FC.

we have to substitute.

push down inverse operators if needed.

memory leak...

now insert invop

Definition at line 859 of file optimize.c.

860 {
861  entity op = call_function(c);
862  symetric_opertor_t * so;
863 
864  /* switch asymetric operation if needed */
865  so = what_operator(op, true);
866  if (so)
867  {
868  bool doit = true;
869 
870  if (so->not_ints)
871  {
872  /* should use the type_checker results...
873  * maybe it could be implemented also as an analyses
874  * and not only a transformation? Well, I don't know
875  * how to store expression to type data, as expressions
876  * cannot be shared and are not "named" as statements are. FC.
877  */
879  basic b = basic_of_expression(tmp);
880  if (basic_int_p(b)) doit = false;
882  free_expression(tmp);
883  }
884 
885  if (doit) /* we have to substitute. */
886  {
887  list largs = call_arguments(c);
888  expression second;
889  pips_assert("binary call", gen_length(largs)==2);
890  second = EXPRESSION(CAR(CDR(largs)));
891 
893  expression_syntax(second) =
896  CONS(EXPRESSION,
899  NIL)));
900  }
901  }
902 
903  /* push down inverse operators if needed. */
904  so = what_operator(op, false);
905  if (so)
906  {
907  list largs = call_arguments(c);
908  syntax s;
909  pips_assert("one arg to inverse op", gen_length(largs)==1);
910  s = expression_syntax(EXPRESSION(CAR(largs)));
911  if (syntax_call_p(s))
912  {
913  call called = syntax_call(s);
914  if (same_string_p(so->syme,
916  {
917  /* memory leak... */
918  entity invop = call_function(c);
919  call_function(c) = call_function(called);
920  call_arguments(c) = call_arguments(called);
921  /* now insert invop */
922  MAP(EXPRESSION, e,
923  {
924  expression_syntax(e) =
926  make_call(invop,
927  CONS(EXPRESSION,
930  NIL)));
931  },
932  call_arguments(called));
933  }
934  }
935  }
936 
937  return true;
938 }
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
syntax make_syntax(enum syntax_utype tag, void *val)
Definition: ri.c:2491
static symetric_opertor_t * what_operator(entity e, int which_one)
Definition: optimize.c:838
#define normalized_undefined
Definition: ri.h:1745
#define basic_int_p(x)
Definition: ri.h:614
@ is_syntax_call
Definition: ri.h:2693
#define call_undefined
Definition: ri.h:685

References basic_int_p, basic_of_expression(), call_arguments, call_function, call_to_expression(), call_undefined, CAR, CDR, CONS, entity_intrinsic(), entity_local_name(), EXPRESSION, expression_syntax, free_expression(), gen_length(), symetric_opertor_t::inv, is_syntax_call, make_call(), make_expression(), make_syntax(), MAP, NIL, normalized_undefined, symetric_opertor_t::not_ints, pips_assert, same_string_p, symetric_opertor_t::syme, syntax_call, syntax_call_p, and what_operator().

Referenced by inverse_normalization_of_expressions().

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

◆ inverse_normalization_of_expressions()

void inverse_normalization_of_expressions ( statement  s)

Definition at line 940 of file optimize.c.

941 {
943 }
static bool inv_call_flt(call c)
Definition: optimize.c:859

References call_domain, gen_null(), gen_recurse, and inv_call_flt().

+ Here is the call graph for this function:

◆ inverse_operator_of()

entity inverse_operator_of ( entity  e)

Definition at line 852 of file optimize.c.

853 {
854  symetric_opertor_t * sot = what_operator(e, 2);
855  if (sot) return entity_intrinsic(sot->inv);
856  else return NULL;
857 }

References entity_intrinsic(), symetric_opertor_t::inv, and what_operator().

+ Here is the call graph for this function:

◆ is_inverse()

static bool is_inverse ( expression  e)
static

Definition at line 555 of file optimize.c.

556 {
557  syntax s = expression_syntax(e);
558  if (!syntax_call_p(s)) return false;
559  return call_function(syntax_call(s)) == inverse;
560 }
static entity inverse
Definition: optimize.c:552

References call_function, expression_syntax, inverse, syntax_call, and syntax_call_p.

Referenced by call_nary_rwt().

+ Here is the caller graph for this function:

◆ is_string_constant()

static bool is_string_constant ( entity  e)
static

Definition at line 127 of file optimize.c.

128 {
129  basic b = entity_basic(e);
130 
131  if (type_functional_p(entity_type(e)) &&
133  !basic_undefined_p(b))
134  return basic_string_p(b);
135 
136  return false;
137 }
basic entity_basic(entity e)
return the basic associated to entity e if it's a function/variable/constant basic_undefined otherwis...
Definition: entity.c:1380
#define type_functional_p(x)
Definition: ri.h:2950
#define value_constant_p(x)
Definition: ri.h:3071
#define basic_undefined_p(x)
Definition: ri.h:557
#define basic_string_p(x)
Definition: ri.h:629
#define entity_type(x)
Definition: ri.h:2792
#define entity_initial(x)
Definition: ri.h:2796

References basic_string_p, basic_undefined_p, entity_basic(), entity_initial, entity_type, type_functional_p, and value_constant_p.

Referenced by eole_okay_call_rwt().

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

◆ is_uminus()

static expression is_uminus ( expression  e)
static

returns B if uminus(B), else 0

Definition at line 454 of file optimize.c.

455 {
456  syntax s = expression_syntax(e);
457  if (syntax_call_p(s))
458  {
459  call c = syntax_call(s);
460  if (call_function(c)==uminus && gen_length(call_arguments(c))==1)
461  return EXPRESSION(CAR(call_arguments(c)));
462  }
463  return NULL;
464 }

References call_arguments, call_function, CAR, EXPRESSION, expression_syntax, gen_length(), syntax_call, syntax_call_p, and uminus.

Referenced by call_simplify_rwt().

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

◆ list_of_expressions_to_array()

static cost_expression* list_of_expressions_to_array ( list  le,
double(*)(expression cost 
)
static

build an cost_expression array from an expression list.

Parameters
leof expression

Definition at line 998 of file optimize.c.

1001 {
1002  int len = gen_length(le), i=0;
1003  cost_expression * tce = malloc(len * sizeof(cost_expression));
1004  pips_assert("enough memory", tce!=NULL);
1005 
1006  MAP(EXPRESSION, e,
1007  {
1008  tce[i].expr = e;
1009  tce[i].cost = cost(e);
1010  i++;
1011  },
1012  le);
1013 
1014  qsort(tce, len, sizeof(cost_expression), cost_expression_cmp);
1015 
1016  ifdebug(3) debug_cost_expression_array("qsort output", tce, len);
1017 
1018  return tce;
1019 }
void * malloc(YYSIZE_T)
static int cost_expression_cmp(const void *v1, const void *v2)
comparison function for qsort.
Definition: optimize.c:965
return(s1)

References cost_expression::cost, cost_expression_cmp(), debug_cost_expression_array(), cost_expression::expr, EXPRESSION, gen_length(), ifdebug, malloc(), MAP, and pips_assert.

Referenced by call_rwt().

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

◆ loop_flt()

static bool loop_flt ( loop  l,
extract_expr_p  context 
)
static

keep on.

Definition at line 173 of file optimize.c.

174 {
175  entity index = loop_index(l);
176  context->indices = CONS(ENTITY, index, context->indices);
177  return true; /* keep on. */
178 }
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define loop_index(x)
Definition: ri.h:1640

References CONS, ENTITY, and loop_index.

Referenced by get_list_of_rhs().

+ Here is the caller graph for this function:

◆ loop_rwt()

static void loop_rwt ( loop  l,
extract_expr_p  context 
)
static

Definition at line 180 of file optimize.c.

181 {
182  list tmp = context->indices;
183  pips_assert("same index", ENTITY(CAR(context->indices))==loop_index(l));
184  context->indices = CDR(context->indices);
185  CDR(tmp) = NIL;
186  gen_free_list(tmp);
187 }

References CAR, CDR, ENTITY, gen_free_list(), loop_index, NIL, and pips_assert.

Referenced by get_list_of_rhs().

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

◆ nary_call_flt()

static bool nary_call_flt ( call  c)
static

top-down: switch calls to nary form.

Definition at line 774 of file optimize.c.

775 {
777  return true;
778 }
static entity binary_to_nary(entity e)
Definition: optimize.c:748

References binary_to_nary(), and call_function.

Referenced by naryfication_of_expressions().

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

◆ nary_call_rwt()

static void nary_call_rwt ( call  c)
static

bottom-up: + + -> +

Definition at line 782 of file optimize.c.

783 {
784  entity called = call_function(c);
785  list newl = NIL, oldl = call_arguments(c);
786 
787  if (nary_operator_p(called))
788  {
789  MAP(EXPRESSION, e,
790  {
791  syntax s = expression_syntax(e);
792  if (syntax_call_p(s) && call_function(syntax_call(s))==called)
793  {
794  newl = gen_nconc(newl, call_arguments(syntax_call(s)));
796  free_expression(e);
797  }
798  else
799  {
800  newl = gen_nconc(newl, CONS(EXPRESSION, e, NIL));
801  }
802  },
803  oldl);
804  }
805 
806  call_arguments(c) = newl;
807  gen_free_list(oldl);
808 }
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
static bool nary_operator_p(entity e)
Definition: optimize.c:760

References call_arguments, call_function, CONS, EXPRESSION, expression_syntax, free_expression(), gen_free_list(), gen_nconc(), MAP, nary_operator_p(), NIL, syntax_call, and syntax_call_p.

Referenced by naryfication_of_expressions().

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

◆ nary_operator_p()

static bool nary_operator_p ( entity  e)
static

Definition at line 760 of file optimize.c.

761 {
762  binary_to_nary_t * pbn;
763  const char* lname = entity_local_name(e);
764 
765  for (pbn = bton; pbn->nary; pbn++)
766  if (same_string_p(pbn->nary, lname))
767  return true;
768 
769  return false;
770 }

References bton, entity_local_name(), lname(), binary_to_nary_t::nary, and same_string_p.

Referenced by nary_call_rwt().

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

◆ naryfication_of_expressions()

void naryfication_of_expressions ( statement  s)

optimize.c

Definition at line 810 of file optimize.c.

811 {
813 }
static void nary_call_rwt(call c)
bottom-up: + + -> +
Definition: optimize.c:782
static bool nary_call_flt(call c)
top-down: switch calls to nary form.
Definition: optimize.c:774

References call_domain, gen_recurse, nary_call_flt(), and nary_call_rwt().

+ Here is the call graph for this function:

◆ optimize_expressions()

bool optimize_expressions ( const char *  module_name)

pipsmake interface to apply expression optimization according to various strategy.

The strategy to use is specified with the EOLE_OPTIMIZATION_STRATEGY property. The strategies themselves are defined into the strategies[] array.

In general, strategies involve an external optimization tool that is not provided with PIPS, so they cannot be used...

At least the CSE, ICM and ICMCSE work without this tool and can be safely used. See the common_subexpression_elimination and icm phase to have a direct access to these 2 common working case. Well, it is not clear that ICMCSE would work since it would need to refresh the effects, which is not done. So the safe way is to use separately these 2 phases.

Parameters
[in]module_name
Returns
true since it is supposed to always work

get needed stuff.

check consistency before optimizations

do something here.

Could perform more optimizations here...

EOLE Stuff

Could perform more optimizations here...

CSE/ICM + atom

EOLE Stuff, second pass for FMA.

others?

check consistency after optimizations

return result to pipsdbm

okay !

Parameters
module_nameodule_name

Definition at line 1391 of file optimize.c.

1392 {
1393  statement s;
1394 
1396 
1397  /* get needed stuff.
1398  */
1401  db_get_memory_resource(DBR_CODE, module_name, true));
1403 
1404 
1407 
1408  /* check consistency before optimizations */
1409  pips_assert("consistency checking before optimizations",
1411 
1412  ifdebug(1) davinci_dump_expressions(module_name, "initial", s);
1413 
1414  /* do something here.
1415  */
1416 
1417  /* Could perform more optimizations here...
1418  */
1419 
1420  /* EOLE Stuff
1421  */
1422 
1423  if (strategy->apply_eole1)
1425 
1426  /* Could perform more optimizations here...
1427  */
1428  /* CSE/ICM + atom
1429  */
1430 
1431  if (strategy->apply_gcm)
1433 
1434  if (strategy->apply_cse)
1436 
1437  /* EOLE Stuff, second pass for FMA.
1438  */
1439  if (strategy->apply_eole2)
1440  apply_eole_on_statement(module_name, s, strategy->apply_eole2_flags);
1441 
1442  if (strategy->apply_nary_simplify)
1444 
1445  if (strategy->apply_balancing)
1447 
1448  if (strategy->apply_simplify)
1450 
1451  /* others?
1452  */
1453 
1454  /* check consistency after optimizations */
1456  clean_up_sequences(s);
1459  pips_assert("consistency checking after optimizations",
1461 
1463 
1464  module_reorder(s);
1465 
1466  /* return result to pipsdbm
1467  */
1468  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module_name, s);
1469 
1473 
1474  debug_off();
1475 
1476  return true; /* okay ! */
1477 }
bool statement_consistent_p(statement p)
Definition: ri.c:2195
bool clean_up_sequences(statement s)
Recursively clean up the statement sequences by fusing them if possible and by removing useless one.
void perform_icm_association(const char *, statement)
sequence_gcm_cse.c
void perform_ac_cse(const char *, statement)
if(!(yy_init))
Definition: genread_lex.c:1029
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
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
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
static void optimize_simplify_nary_patterns(statement s)
Definition: optimize.c:621
static void optimize_simplify_patterns(statement s)
look for some expressions in s and simplify some patterns.
Definition: optimize.c:533
static void switch_nary_to_binary(statement s)
switch nary operators to binary ones.
Definition: optimize.c:1137
void convert_to_standard_operators(void *v)
Definition: optimize.c:1364
static void reset_current_optimization_strategy(void)
Definition: optimize.c:1297
#define EOLE_FLAGS
Definition: optimize.c:107
static void apply_eole_on_statement(const char *module_name, statement s, const char *flags)
apply eole on all expressions in s.
Definition: optimize.c:383
void convert_to_c_operators(void *v)
Definition: optimize.c:1343
#define DEBUG_NAME
Definition: optimize.c:50
static void davinci_dump_expressions(const char *module_name, string phase, statement s)
dump all expressions in s as davinci graphs.
Definition: optimize.c:1314
static void set_current_optimization_strategy(void)
Definition: optimize.c:1286
void unnormalize_expression(void *st)
void unnormalize_expression(expression exp): puts all the normalized field of expressions in "st" to ...
Definition: normalize.c:452
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
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
void simplify_expressions(void *obj)
Definition: expression.c:3801

References optimization_strategy::apply_balancing, optimization_strategy::apply_cse, optimization_strategy::apply_eole1, optimization_strategy::apply_eole2, optimization_strategy::apply_eole2_flags, apply_eole_on_statement(), optimization_strategy::apply_gcm, optimization_strategy::apply_nary_simplify, optimization_strategy::apply_simplify, clean_up_sequences(), convert_to_c_operators(), convert_to_standard_operators(), davinci_dump_expressions(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, DEBUG_NAME, debug_off, debug_on, EOLE_FLAGS, get_current_module_statement(), get_string_property(), ifdebug, local_name_to_top_level_entity(), module_name(), module_reorder(), optimize_simplify_nary_patterns(), optimize_simplify_patterns(), perform_ac_cse(), perform_icm_association(), pips_assert, reset_current_module_entity(), reset_current_module_statement(), reset_current_optimization_strategy(), set_current_module_entity(), set_current_module_statement(), set_current_optimization_strategy(), simplify_expressions(), statement_consistent_p(), strategy, switch_nary_to_binary(), and unnormalize_expression().

Referenced by common_subexpression_elimination(), and icm().

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

◆ optimize_simplify_nary_patterns()

static void optimize_simplify_nary_patterns ( statement  s)
static

N-ARY * and 1/ -> N-ARY* / N-ARY*

Definition at line 621 of file optimize.c.

622 {
623  /* N-ARY * and 1/ -> N-ARY* / N-ARY*
624  */
627  divide = entity_intrinsic("/");
628 
630 
631  multiply = NULL;
632  inverse = NULL;
633  divide = NULL;
634 }
static void call_nary_rwt(call c)
Definition: optimize.c:562
#define INVERSE_OPERATOR_NAME
#define EOLE_PROD_OPERATOR_NAME

References call_domain, call_nary_rwt(), divide, entity_intrinsic(), EOLE_PROD_OPERATOR_NAME, gen_recurse, gen_true(), inverse, INVERSE_OPERATOR_NAME, and multiply.

Referenced by optimize_expressions().

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

◆ optimize_simplify_patterns()

static void optimize_simplify_patterns ( statement  s)
static

look for some expressions in s and simplify some patterns.

not implemented yet.

a + (-b) -> a - b

(-b) + a -> a - b

fma(a,b,-c) => fms(a,b,c)

a * (1/ b) -> a / b

(1/ b) * a -> a / b

a + (-b * c) -> a - (b * c)

Definition at line 533 of file optimize.c.

534 {
535  /* not implemented yet. */
536 
537  /* a + (-b) -> a - b */
538  /* (-b) + a -> a - b */
539  /* fma(a,b,-c) => fms(a,b,c) */
540  generate_bminus(s);
541 
542  /* a * (1/ b) -> a / b */
543  /* (1/ b) * a -> a / b */
544  /* a + (-b * c) -> a - (b * c) */
545 }
static void generate_bminus(statement s)
Definition: optimize.c:514

References generate_bminus().

Referenced by optimize_expressions().

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

◆ read_and_allocate_string_from_file()

static string read_and_allocate_string_from_file ( FILE *  file)
static

Definition at line 259 of file optimize.c.

260 {
261  int test;
262  char buffer[SIZE_OF_BUFFER];
263 
264  test = fscanf(file, "%s",buffer);
265  pips_assert("fscanf - read string from file \n",(test==1));
266 
267  return strdup(buffer);
268 }
#define SIZE_OF_BUFFER
Definition: optimize.c:256
struct _newgen_struct_test_ * test
Definition: ri.h:423
static string buffer
Definition: string.c:113

References buffer, pips_assert, SIZE_OF_BUFFER, and strdup().

Referenced by read_new_entities_from_eole().

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

◆ read_from_eole()

static list read_from_eole ( const char *  module,
const char *  file_name 
)
static

import expressions from eole.

of expression

read entities to create... should use some newgen type to do so (to share buffers...)

Definition at line 335 of file optimize.c.

336 {
337  FILE * fromeole;
338  reference astuce;
339  list result;
340 
341  pips_debug(3, "reading from eole for module %s\n", module);
342 
343  fromeole = safe_fopen(file_name, "r");
344 
345  /* read entities to create...
346  * should use some newgen type to do so (to share buffers...)
347  */
349 
350  astuce = read_reference(fromeole);
351  result = reference_indices(astuce);
352  reference_indices(astuce) = NIL;
353  free_reference(astuce);
354 
355  return result;
356 }
void free_reference(reference p)
Definition: ri.c:2050
reference read_reference(FILE *f)
Definition: ri.c:2080
static void read_new_entities_from_eole(FILE *file, const char *module)
import a list of entity that have been created during the eole transformations and create them
Definition: optimize.c:275
static char * module
Definition: pips.c:74
#define reference_indices(x)
Definition: ri.h:2328
static string file_name

References file_name, free_reference(), module, NIL, pips_debug, read_new_entities_from_eole(), read_reference(), reference_indices, and safe_fopen().

Referenced by apply_eole_on_statement().

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

◆ read_new_entities_from_eole()

static void read_new_entities_from_eole ( FILE *  file,
const char *  module 
)
static

import a list of entity that have been created during the eole transformations and create them

read the number of new entities to create

constant

int

create integer entity

float

create float entity

double

Definition at line 275 of file optimize.c.

275  {
276  int num = 0;
277  int i, test;
278  string ent_type;
279  string const_type;
280  int const_size = 0;
281  string const_value;
282 
283  entity e;
284 
285  /* read the number of new entities to create */
286  test = fscanf(file,"%d\n",&num);
287  pips_assert("fscanf - read number of entity",(test==1));
288  pips_debug(3,"reading %d new entity from module %s\n", num, module);
289 
290  for (i=0;i<num;i++)
291  {
292  ent_type = read_and_allocate_string_from_file(file);
293 
294  if (!strcmp(ent_type,"constant")) { /* constant */
295 
296  const_type = read_and_allocate_string_from_file(file);
297 
298  test = fscanf(file," %d\n", &const_size);
299  pips_assert("fscanf - read entity basic type size\n",(test==1));
300 
301  const_value = read_and_allocate_string_from_file(file);
302 
303  if (same_string_p(const_type,"int")) {/* int */
304 
305  /* create integer entity */
306  e = make_constant_entity(const_value, is_basic_int, const_size);
307  pips_assert("make integer constant entity", entity_consistent_p(e));
308  }
309  else if (same_string_p(const_type,"float")) {/* float */
310  /* create float entity */
311  e = make_constant_entity(const_value, is_basic_float, const_size);
312  pips_assert("make float constant entity", entity_consistent_p(e));
313  }
314  else if (same_string_p(const_type, "double")) { /* double */
315  e = make_constant_entity(const_value, is_basic_float, const_size);
316  pips_assert("make float constant entity", entity_consistent_p(e));
317  }
318  else
319  pips_internal_error("can't create this kind of constant entity: %s",
320  const_type);
321  free(const_type);
322  free(const_value);
323  }
324  else
325  pips_internal_error("can't create this kind of entity: %s", ent_type);
326 
327  free(ent_type);
328  }
329 }
bool entity_consistent_p(entity p)
Definition: ri.c:2530
static int num
Definition: bourdoncle.c:137
entity make_constant_entity(string name, tag bt, size_t size)
For historical reason, call the Fortran version.
Definition: constant.c:301
#define pips_internal_error
Definition: misc-local.h:149
static string read_and_allocate_string_from_file(FILE *file)
Definition: optimize.c:259
@ is_basic_float
Definition: ri.h:572
@ is_basic_int
Definition: ri.h:571

References entity_consistent_p(), free(), is_basic_float, is_basic_int, make_constant_entity(), module, num, pips_assert, pips_debug, pips_internal_error, read_and_allocate_string_from_file(), and same_string_p.

Referenced by read_from_eole().

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

◆ reset_current_optimization_strategy()

static void reset_current_optimization_strategy ( void  )
static

Definition at line 1297 of file optimize.c.

1298 {
1299  strategy = NULL;
1300 }

References strategy.

Referenced by optimize_expressions().

+ Here is the caller graph for this function:

◆ set_current_optimization_strategy()

static void set_current_optimization_strategy ( void  )
static

Definition at line 1286 of file optimize.c.

1287 {
1288  const char* name = get_string_property("EOLE_OPTIMIZATION_STRATEGY");
1289  for (strategy = strategies; strategy->name!=NULL; strategy++)
1290  {
1291  if (same_string_p(name, strategy->name))
1292  return;
1293  }
1294  pips_user_warning("'%s' strategy not found, default assumed.\n", name);
1295 }
#define pips_user_warning
Definition: misc-local.h:146
static optimization_strategy strategies[]
predefined optimization strategies.
Definition: optimize.c:1160
string name
NAME of the strategy.
Definition: optimize.c:59

References get_string_property(), optimization_strategy::name, pips_user_warning, same_string_p, strategies, and strategy.

Referenced by optimize_expressions().

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

◆ swap_syntax_in_expression()

static void swap_syntax_in_expression ( list  lcode,
list  lnew 
)
static

swap term to term syntax field in expression list, as a side effect...

Parameters
lcodeof expressionwithlevel
lnewof expression

Definition at line 361 of file optimize.c.

363 {
364  pips_assert("equal length lists", gen_length(lcode)==gen_length(lnew));
365 
366  for(; lcode; lcode=CDR(lcode), lnew=CDR(lnew))
367  {
368  expression old, new;
369  syntax tmp;
370 
372  new = EXPRESSION(CAR(lnew));
373 
374  tmp = expression_syntax(old);
376  expression_syntax(new) = tmp;
377  }
378 }
#define expressionwithlevel_expression(x)
Definition: eole_private.h:137

References CAR, CDR, EXPRESSION, expression_syntax, EXPRESSIONWITHLEVEL, expressionwithlevel_expression, gen_length(), and pips_assert.

Referenced by apply_eole_on_statement().

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

◆ switch_nary_to_binary()

static void switch_nary_to_binary ( statement  s)
static

switch nary operators to binary ones.

n+ -> +, n* -> * missing: & | and so on.

options: another expression cost function could be used. for instance, defining -expression_gravity would build the most unbalanced possible expression tree wrt WG.

Definition at line 1137 of file optimize.c.

1138 {
1139  entity
1144 
1145  /* options: another expression cost function could be used.
1146  * for instance, defining -expression_gravity would build
1147  * the most unbalanced possible expression tree wrt WG.
1148  */
1150  (s, nplus, plus, strategy->huffman_cost, strategy->huffman_mode);
1152  (s, nmult, mult, strategy->huffman_cost, strategy->huffman_mode);
1153 }
static void build_binary_operators_with_huffman(statement s, entity nary_operator, entity binary_operator, double(*cost)(expression), bool mode)
apply the huffman balancing on every call to nary_operator and build calls to binary_operator instead...
Definition: optimize.c:1108
#define EOLE_SUM_OPERATOR_NAME
#define MULTIPLY_OPERATOR_NAME
double(* huffman_cost)(expression)
Definition: optimize.c:64

References build_binary_operators_with_huffman(), entity_intrinsic(), EOLE_PROD_OPERATOR_NAME, EOLE_SUM_OPERATOR_NAME, optimization_strategy::huffman_cost, optimization_strategy::huffman_mode, MULTIPLY_OPERATOR_NAME, PLUS_OPERATOR_NAME, and strategy.

Referenced by optimize_expressions().

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

◆ what_operator()

static symetric_opertor_t* what_operator ( entity  e,
int  which_one 
)
static

Definition at line 838 of file optimize.c.

839 {
840  const char* lname = entity_local_name(e);
841  symetric_opertor_t * sot;
842  for (sot = symop; sot->asym; sot++)
843  {
844  if ((which_one==1 && same_string_p(lname, sot->asym)) ||
845  (which_one==0 && same_string_p(lname, sot->inv)) ||
846  (which_one==2 && same_string_p(lname, sot->syme)))
847  return sot;
848  }
849  return NULL;
850 }
static symetric_opertor_t symop[]
Definition: optimize.c:832

References symetric_opertor_t::asym, entity_local_name(), symetric_opertor_t::inv, lname(), same_string_p, symetric_opertor_t::syme, and symop.

Referenced by inv_call_flt(), and inverse_operator_of().

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

◆ write_list_of_rhs()

static void write_list_of_rhs ( FILE *  out,
list  le 
)
static

export a list of expression of the current module.

done thru a convenient reference.

reference astuce = make_reference(get_current_module_entity(), le);

Parameters
leof expressionwithlevel

Definition at line 231 of file optimize.c.

232 {
233  /* reference astuce = make_reference(get_current_module_entity(), le);*/
238 }
void free_lexpressionwithlevel(lexpressionwithlevel p)
Definition: eole_private.c:145
lexpressionwithlevel make_lexpressionwithlevel(list a)
Definition: eole_private.c:178
void write_lexpressionwithlevel(FILE *f, lexpressionwithlevel p)
Definition: eole_private.c:172
#define lexpressionwithlevel_list(x)
Definition: eole_private.h:205

References free_lexpressionwithlevel(), lexpressionwithlevel_list, make_lexpressionwithlevel(), NIL, out, and write_lexpressionwithlevel().

Referenced by write_to_eole().

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

◆ write_to_eole()

static void write_to_eole ( const char *  module,
list  le,
const char *  file_name 
)
static

export expressions to eole thru the newgen format.

both entities and rhs expressions are exported.

Definition at line 243 of file optimize.c.

244 {
245  FILE * toeole;
246 
247  pips_debug(3, "writing to eole for module %s\n", module);
248 
249  toeole = safe_fopen(file_name, "w");
250  write_tabulated_entity(toeole);
251  write_list_of_rhs(toeole, le);
252 
253  safe_fclose(toeole, file_name);
254 }
void write_tabulated_entity(FILE *f)
Definition: ri.c:2554
static void write_list_of_rhs(FILE *out, list le)
export a list of expression of the current module.
Definition: optimize.c:231

References file_name, module, pips_debug, safe_fclose(), safe_fopen(), write_list_of_rhs(), and write_tabulated_entity().

Referenced by apply_eole_on_statement().

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

Variable Documentation

◆ bminus

entity bminus = NULL
static

Definition at line 448 of file optimize.c.

Referenced by call_simplify_rwt(), and generate_bminus().

◆ bplus

entity bplus = NULL
static

A + (–B) -> A - B FMA -> FMS.

Definition at line 446 of file optimize.c.

Referenced by call_simplify_rwt(), and generate_bminus().

◆ bton

binary_to_nary_t bton[]
static
Initial value:
=
{
{ "MAX", MAX_NAME },
{ "MIN", MIN_NAME },
{ "MAX0", MAX_NAME },
{ "DMAX1", MAX_NAME },
{ "AMAX1", MAX_NAME },
{ "AMAX0", MAX_NAME },
{ "MIN0", MIN_NAME },
{ "DMIN1", MIN_NAME },
{ "AMIN1", MIN_NAME },
{ "AMIN0", MIN_NAME },
{ NULL, NULL }
}
#define MIN_NAME
Definition: optimize.c:723
#define MAX_NAME
Definition: optimize.c:722

Definition at line 725 of file optimize.c.

Referenced by binary_to_nary(), and nary_operator_p().

◆ divide

entity divide = NULL
static

Definition at line 553 of file optimize.c.

Referenced by call_nary_rwt(), and optimize_simplify_nary_patterns().

◆ fmaop

entity fmaop = NULL
static

Definition at line 449 of file optimize.c.

Referenced by call_simplify_rwt(), and generate_bminus().

◆ fmsop

entity fmsop = NULL
static

Definition at line 450 of file optimize.c.

Referenced by call_simplify_rwt(), and generate_bminus().

◆ huffman_binary_operator

entity huffman_binary_operator = NULL
static

Definition at line 950 of file optimize.c.

Referenced by build_binary_operators_with_huffman(), and call_rwt().

◆ huffman_cost

double(* huffman_cost) (expression) ( expression  ) = NULL
static

Definition at line 951 of file optimize.c.

Referenced by build_binary_operators_with_huffman(), and call_rwt().

◆ huffman_mode

bool huffman_mode = true
static

true: Huffman.

false: rateau.

Definition at line 955 of file optimize.c.

Referenced by build_binary_operators_with_huffman(), and call_rwt().

◆ huffman_nary_operator

entity huffman_nary_operator = NULL
static

switch nary to binary with huffman algorithm.

Definition at line 949 of file optimize.c.

Referenced by build_binary_operators_with_huffman(), and call_rwt().

◆ inverse

entity inverse = NULL
static

Definition at line 552 of file optimize.c.

Referenced by is_inverse(), and optimize_simplify_nary_patterns().

◆ multiply

entity multiply = NULL
static

Definition at line 551 of file optimize.c.

Referenced by call_nary_rwt(), and optimize_simplify_nary_patterns().

◆ strategies

optimization_strategy strategies[]
static

predefined optimization strategies.

Definition at line 1160 of file optimize.c.

Referenced by set_current_optimization_strategy().

◆ strategy

◆ symop

symetric_opertor_t symop[]
static
Initial value:
=
{ { "-", "+", "--", false },
{ "/", "*", INVERSE_OPERATOR_NAME, true },
{ NULL, NULL, NULL, false }
}

Definition at line 832 of file optimize.c.

Referenced by what_operator().

◆ uminus

entity uminus = NULL
static

Definition at line 447 of file optimize.c.

Referenced by generate_bminus(), incrementation_expression_to_increment(), and is_uminus().