PIPS
guard_elimination.c File Reference
#include "genC.h"
#include "linear.h"
#include "matrice.h"
#include "sparse_sc.h"
#include "ri.h"
#include "database.h"
#include "resources.h"
#include "misc.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "pipsdbm.h"
#include "control.h"
#include "conversion.h"
#include "hyperplane.h"
+ Include dependency graph for guard_elimination.c:

Go to the source code of this file.

Data Structures

struct  context_p
 cette structure contient une pile. More...
 

Typedefs

typedef struct context_p context_t
 

Functions

static Value myceil (Value k, Value m)
 
static Value myfloor (Value k, Value m)
 
static Value eval (Pvecteur pv, Value val, Variable var)
 
static Value eval2 (Value val0, Value val1, Value val2, Value val)
 
static Value intersection (Pvecteur pv1, Pvecteur pv2, Variable var, floor)
 
static bool stmt_flt (statement s, context_p context)
 
static void stmt_rwt (statement s, context_p context)
 
static bool loop_flt (loop l, context_p context)
 
statement unimodular (s)
 
statement free_guards (statement s)
 
bool guard_elimination (string module)
 

Variables

Psysteme sc_newbase
 include <sys/ddi.h> More...
 
Ptsg sg
 
bool if1 =false
 
bool if2 =false
 

Typedef Documentation

◆ context_t

typedef struct context_p context_t

Function Documentation

◆ eval()

static Value eval ( Pvecteur  pv,
Value  val,
Variable  var 
)
static

Definition at line 82 of file guard_elimination.c.

86 {
87  Value coef, cons;
88  coef = vect_coeff(var,pv);
89  cons = vect_coeff(TCST,pv);
90  return (coef * val +cons ) ;
91 }
int Value
struct cons cons
The structure used to build lists in NewGen.
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
Value vect_coeff(Variable var, Pvecteur vect)
Variable vect_coeff(Variable var, Pvecteur vect): coefficient de coordonnee var du vecteur vect —> So...
Definition: unaires.c:228

References TCST, and vect_coeff().

Referenced by c_whileloop(), freia_alloc_stat_p(), html_print_whileloop(), loop_flt(), and text_whileloop().

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

◆ eval2()

static Value eval2 ( Value  val0,
Value  val1,
Value  val2,
Value  val 
)
static

Definition at line 93 of file guard_elimination.c.

95 {
96  return ( value_div(value_direct_multiply (val1,val)+val0,-val2 )) ;
97 }
#define value_direct_multiply(v1, v2)
#define value_div(v1, v2)

References value_direct_multiply, and value_div.

Referenced by free_guards().

+ Here is the caller graph for this function:

◆ free_guards()

statement free_guards ( statement  s)

sg_dump(sg);

fprint_lsom(stderr, vertice,variable_dump_name );

debut cas1

fins cas1

ebut cas2

fin cas2

debut cas3

s1

in cas3

debut cas4

in cas4

Definition at line 544 of file guard_elimination.c.

546 {
547  int isoler =-1,isoler2=-1;
548  instruction ins;
549  statement body1,body2,loop2=NULL;
550  sequence seqi,seqj,seq;
551  list lisi,lisj,lisjcopy,lis,lisjcopy2,lisp;
552  statement first, last=NULL;
553  expression exp;
555  Pvecteur pv1,pv2=NULL,pvif1=NULL,pvif2=NULL,pv_i_lower,pv_i_upper;
556  Pcontrainte cif1=NULL,cif2=NULL;
557  Value sommetg[4];
558  loop tab_loop[6], loop1;
559  instruction tab_instruction[6];
560  statement tab_statement[6];
561  int i=0,j;
562  Psommet vertice,e;
563  int nbr_vertice;
564  Variable indice1,indice2;
565  range range_i,range1,range2,range3;
566  /* sg_dump(sg); */
567  /* fprint_lsom(stderr, vertice,variable_dump_name ); */
568  ins =statement_instruction(s);
569  loop1=instruction_loop(ins);
570  body1=loop_body(instruction_loop(ins));
571  indice1=(Variable )loop_index(instruction_loop(ins));
572  range_i=loop_range(instruction_loop(ins));
576  vect_add_elem(&pv_i_lower,indice1,-1);
578  vect_add_elem(&pv_i_upper,indice1,-1);
579  ins =statement_instruction(body1);
580  seqi=instruction_sequence(ins);
581  lisi =sequence_statements(seqi);
582  MAP(STATEMENT,s1,{loop2 =s1; },lisi) ;
583  ins=statement_instruction(loop2);
584  indice2=(Variable )loop_index(instruction_loop(ins));
585  body2=loop_body(instruction_loop(ins));
586  ins =statement_instruction(body2);
587  seqj=instruction_sequence(ins);
588  lisj =sequence_statements(seqj);
589  lisjcopy= gen_full_copy_list(lisj);
590  first= (statement )CHUNK( CAR(lisj));
591  nbr_vertice=sg_nbre_sommets(sg);
592  printf(" le nombre de sommet est %d \n", nbr_vertice);
593  vertice= sg_sommets(sg);
594  for (e = vertice; e != NULL; e = e->succ) {
595  pv1=e->vecteur;
596  sommetg[i]=value_div (vect_coeff(indice1,pv1),e->denominateur);
597  i++;
598  };
599  for(i=0;i<=nbr_vertice-1;i++)
600  {
601  for(j=i+1;j<= nbr_vertice;j++)
602  if( sommetg[j]< sommetg[i] )
603  {
604  Value permut;
605  permut= sommetg[i];
606  sommetg[i]= sommetg[j];
607  sommetg[j]=permut;
608  };
609  };
610  for(i=0;i<= nbr_vertice-1;i++)
611  {
612  if( sommetg[i]== sommetg[i+1] )
613  {
614  for (j=i;j<=nbr_vertice-1;j++)
615  sommetg[j]=sommetg[j+1];
616  nbr_vertice--;
617  };
618  };
619  i=0;
620  MAP(STATEMENT,s1, { last =s1; },lisjcopy) ;
621  if (if1){
622  Pcontrainte peq;
623  syntax syntax;
624  call call;
625  list lis;
626  CHUNK(CAR(lisjcopy))= (gen_chunk *)
633  lis =call_arguments(call);
634  exp=(expression )CHUNK(CAR(lis));
636  pv1=normalized_linear(norm);
637  MAP(EXPRESSION,exp,{
639  pv2=normalized_linear(norm);
640  },lis) ;
641  pvif1=vect_substract(pv1,pv2);
643  for (peq = sc_newbase->inegalites;peq!=NULL;peq=peq->succ){
644  if( vect_oppos(pvif1,peq->vecteur))
645  pvif1=vect_substract(VECTEUR_NUL,vect_dup(pvif1));
646  };
647  cif1=contrainte_make(pvif1);
651  }
652  if(if2){
653  Pcontrainte peq;
654  syntax syntax;
655  call call;
656  list lis;
657  CHUNK(CAR(gen_last(lisjcopy)))= (gen_chunk *)
664  lis =call_arguments(call);
665  exp=(expression) CHUNK(CAR(lis));
667  pv1=normalized_linear(norm);
668  MAP(EXPRESSION,exp,{
670  pv2=normalized_linear(norm);
671  },lis) ;
672  pvif2=vect_substract(pv1,pv2);
673  for (peq = sc_newbase->inegalites;peq!=NULL;peq=peq->succ){
674  if( vect_oppos(pvif2,peq->vecteur))
675  pvif2= vect_substract(VECTEUR_NUL,vect_dup(pvif2)) ;
676  }
677  cif2=contrainte_make(pvif2);
681  (exp, int_to_expression(0) );
682  }
683  lis=NIL;
684  lisjcopy2= gen_full_copy_list(lisjcopy);
685  if(if1) CHUNK( CAR( (lisjcopy2)))= (gen_chunk *) make_block_statement(NIL);
686  if(if2)CHUNK(CAR(gen_last((lisjcopy))))= (gen_chunk *) make_block_statement(NIL);
687  for(i=0;i<=2*nbr_vertice-2;i++){
688  Pcontrainte peq,cinf=NULL,csup=NULL;
689  statement body1,body2;
690  instruction ins;
691  sequence seqi,seqj;
692  list lisi,lisj;
693  range range;
694  statement loop2=NULL;
695  bool condition1=false,condition2=false;
696  tab_loop[i]=copy_loop(loop1);
697  tab_instruction[i] = make_instruction_loop(tab_loop[i]);
698  tab_statement[i]=instruction_to_statement ( tab_instruction[i]);
699  lis=CONS(STATEMENT, tab_statement[i],lis);
700  if (i%2==0){
701  int indice;
702  Value minjp=-100,maxjp=100;
703  indice=i/2;
704  range_lower(loop_range(tab_loop[i]))=
705  int_to_expression( sommetg[indice]);
706  range_upper(loop_range(tab_loop[i]))=
707  int_to_expression( sommetg[indice]);
708  for (peq = sc_newbase->inegalites;peq!=NULL;peq=peq->succ){
709  Pvecteur v;
710  Value constante,val1,val2;
711  v = contrainte_vecteur(peq);
712  constante=vect_coeff(TCST,v);
713  val1=vect_coeff(indice1,v);
714  val2=vect_coeff(indice2,v);
715  if (val2 < 0){
716  if (eval2(constante,val1,val2, sommetg[indice])>minjp ){
717  minjp=eval2(constante,val1,val2, sommetg[indice]);
718  cinf=peq;
719  }
720  else {
721  if ( eval2(constante,val1,val2, sommetg[indice])==minjp ){
722  Pvecteur vp;
723  Value constantep,val1p,val2p;
724  vp=contrainte_vecteur(cinf);
725  constantep=vect_coeff(TCST,vp);
726  val1p=vect_coeff(indice1,vp);
727  val2p=vect_coeff(indice2,vp);
729  ( value_direct_multiply(val1,sommetg[indice])+ constante ,-val2p)
731  (value_direct_multiply(val1p,sommetg[indice])+constantep,-val2))
732  cinf=peq;
733  else
735  (value_direct_multiply(val1,sommetg[indice])+ constante,-val2p)
737  (value_direct_multiply(val1p,sommetg[indice])+constantep,-val2))
738  if(egalite_equal(peq,cif1)||egalite_equal(peq,cif2) )
739  cinf=peq;
740  };
741  };
742  };
743  if (val2 > 0){
744  if (eval2(constante,val1,val2, sommetg[indice])<maxjp ){
745  maxjp=eval2(constante,val1,val2, sommetg[indice]);
746  csup=peq;
747  }
748  else {
749  if (eval2(constante,val1,val2, sommetg[indice])==maxjp ){
750  Pvecteur vp;
751  Value constantep,val1p,val2p;
752  vp=contrainte_vecteur(csup);
753  constantep=vect_coeff(TCST,vp);
754  val1p=vect_coeff(indice1,vp);
755  val2p=vect_coeff(indice2,vp);;
757  (value_direct_multiply(val1,sommetg[indice])+ constante ,-val2p)
759  (value_direct_multiply (val1p,sommetg[indice])+ constantep,-val2))
760  csup=peq;
761  else
763  (value_direct_multiply(val1,sommetg[indice])+ constante ,-val2p)
765  (value_direct_multiply(val1p,sommetg[indice])+constantep,-val2))
766  if( ( egalite_equal(peq,cif1) )||(egalite_equal(peq,cif2)) )
767  csup=peq;
768  };
769  };
770  };
771  };
772  for (e = vertice; e != NULL; e = e->succ) {
773  Value j2;
774  Pvecteur pv1;
775  pv1=e->vecteur;
776  if (sommetg[indice]==vect_coeff(indice1,pv1)){
777  j2=vect_coeff(indice2,pv1);
778  if (
779  (value_direct_multiply(vect_coeff(indice1,pvif1),sommetg[indice])+
780  value_direct_multiply(vect_coeff(indice2,pvif1),j2)+
781  vect_coeff(TCST,pvif1)==0)&&
782  (value_direct_multiply(vect_coeff(indice1,pvif2),sommetg[indice])+
783  value_direct_multiply(vect_coeff(indice2,pvif2),j2)+
784  vect_coeff(TCST,pvif2)==0)){
785  if( vect_coeff(indice2,pvif2) < 0 )
786  condition1=true;
787  else{
788  if( vect_coeff(indice2,pvif1) > 0 ){
789  condition2=true;
790 
791  };
792  }
793  }
794  }
795  };
796 
797  }
798  else{
799  int indice;
800  Value minjp1=-100,minjp2=-100,maxjp1=100,maxjp2=100;
801  indice=i/2;
802  range_lower(loop_range(tab_loop[i]))=
803  int_to_expression( sommetg[indice]+1);
804  range_upper(loop_range(tab_loop[i]))=
805  int_to_expression( sommetg[indice+1]-1);
806  for (peq = sc_newbase->inegalites;peq!=NULL;peq=peq->succ){
807  Pvecteur v;
808  Value constante,val1,val2;
809  v = contrainte_vecteur(peq);
810  constante=vect_coeff(TCST,v);
811  val1=vect_coeff(indice1,v);
812  val2=vect_coeff(indice2,v);
813  if (val2 < 0){
814  if ( (eval2(constante,val1,val2, sommetg[indice])>=minjp1 )
815  &&( eval2(constante,val1,val2, sommetg[indice+1]) >=minjp2)){
816  if ( (eval2(constante,val1,val2, sommetg[indice])==minjp1 )
817  &&( eval2(constante,val1,val2, sommetg[indice+1]) ==minjp2))
818  {
819  Pvecteur vp;
820  Value constantep,val1p,val2p;
821  vp=contrainte_vecteur(cinf);
822  constantep=vect_coeff(TCST,vp);
823  val1p=vect_coeff(indice1,vp);
824  val2p=vect_coeff(indice2,vp);
826  (value_direct_multiply(val1,sommetg[indice])+constante,-val2p)
828  (value_direct_multiply(val1p,sommetg[indice])+constantep,-val2))||
830  ( value_direct_multiply(val1,sommetg[indice+1])+ constante ,-val2p)
833  (val1p,sommetg[indice+1])+ constantep ,-val2)))
834  {
835  minjp1=eval2(constante,val1,val2, sommetg[indice]);
836  minjp2=eval2(constante,val1,val2, sommetg[indice+1]);
837  cinf=peq;
838  }
839  }
840  else{
841  minjp1=eval2(constante,val1,val2, sommetg[indice]);
842  minjp2=eval2(constante,val1,val2, sommetg[indice+1]);
843  cinf=peq;
844  }
845  };
846  };
847  if (val2 > 0){
848  if ( (eval2(constante,val1,val2, sommetg[indice])<=maxjp1 )&&
849  ( eval2(constante,val1,val2, sommetg[indice+1]) <=maxjp2)){
850  if ( (eval2(constante,val1,val2, sommetg[indice])==maxjp1 )
851  &&( eval2(constante,val1,val2, sommetg[indice+1]) ==maxjp2))
852  {
853  Pvecteur vp;
854  Value constantep,val1p,val2p;
855  vp=contrainte_vecteur(csup);
856  constantep=vect_coeff(TCST,vp);
857  val1p=vect_coeff(indice1,vp);
858  val2p=vect_coeff(indice2,vp);
860  (value_direct_multiply(val1,sommetg[indice])+ constante ,-val2p)
862  (value_direct_multiply(val1p,sommetg[indice])+constantep,-val2)) ||
864  (value_direct_multiply(val1,sommetg[indice+1])+ constante ,-val2p)
866  (value_direct_multiply (val1p,sommetg[indice+1])+constantep,-val2)))
867  {
868  maxjp1=eval2(constante,val1,val2, sommetg[indice]);
869  maxjp2=eval2(constante,val1,val2, sommetg[indice+1]);
870  csup=peq;
871  };
872  }
873  else{
874  maxjp1=eval2(constante,val1,val2, sommetg[indice]);
875  maxjp2=eval2(constante,val1,val2, sommetg[indice+1]);
876  csup=peq;
877  };
878  };
879  };
880  };
881  };
882  body1=loop_body( tab_loop[i]);
883  ins =statement_instruction(body1);
884  seqi=instruction_sequence(ins);
885  lisi =sequence_statements(seqi);
886  MAP(STATEMENT,s,loop2=s,lisi);
887  ins=statement_instruction(loop2);
891  body2= loop_body(instruction_loop(ins));
893  lisj=sequence_statements(seqj);
894  if (condition1){
895  list lisjcopy;
896  Pvecteur v;
897  Value constante;
898  lisjcopy= gen_full_copy_list(lisj);
899  CHUNK(CAR(gen_last(lisjcopy)))= (gen_chunk *)
901  CHUNK(CAR(lisjcopy))= (gen_chunk *)
903  lisi= gen_concatenate(lisjcopy,lisi);
904  sequence_statements(seqi)=lisi;
905  v = vect_dup (contrainte_vecteur(cinf));
906  constante=vect_coeff(TCST,v);
907  vect_chg_coeff(&v,TCST,value_plus(1,constante));
908  cinf=contrainte_make(v);
910 
911  }
912  if (condition2){
913  Pvecteur v;
914  Value constante;
915  list lisjcopy;
916  lisjcopy= gen_full_copy_list(lisj);
917  CHUNK(CAR(gen_last(lisjcopy)))= (gen_chunk *)
919  CHUNK(CAR(lisjcopy))= (gen_chunk *)
921  lisi= gen_concatenate(lisi,lisjcopy);
922  sequence_statements(seqi)=lisi;
923  v=vect_dup( contrainte_vecteur(csup));
924  constante=vect_coeff(TCST,v);
925  vect_chg_coeff(&v,TCST,value_plus(1,constante));
926  csup=contrainte_make(v);
928  }
929  if (i==0){
930  if ( vect_equal(pvif1,pv_i_lower) ||
931  vect_oppos(pvif1,pv_i_lower)){
932  CHUNK( CAR((lisj)))= (gen_chunk * )
934  sequence_statements(seqj)=lisj;
935  isoler2=0;
936  }
937  else{
938  if ( vect_equal(pvif2,pv_i_lower) ||
939  vect_oppos(pvif2,pv_i_lower)) {
940  CHUNK( CAR(gen_last((lisj))))= (gen_chunk * )
942  sequence_statements(seqj)=lisj;
943  isoler2=0;
944  };
945  };
946  };
947  if (i==2*nbr_vertice-2){
948  if ( vect_equal(pvif1,pv_i_upper) ||
949  vect_oppos(pvif1,pv_i_upper))
950  {
951  CHUNK( CAR((lisj)))= (gen_chunk * )
953  sequence_statements(seqj)=lisj;
954  isoler=2*nbr_vertice-2;
955  }
956  else{
957  if ( vect_equal(pvif2,pv_i_upper) ||
958  vect_oppos(pvif2,pv_i_upper)) {
959  CHUNK( CAR(gen_last((lisj))))= (gen_chunk * )
961  sequence_statements(seqj)=lisj;
962  isoler=2*nbr_vertice-2;
963  };
964  };
965  };
966 
967  if ((condition1==false) && (condition2==false)){
968 
969  /* debut cas1 */
970 
971  if ( egalite_equal(cinf,cif1)){
972  if (value_abs (vect_coeff(indice2,pvif1))==1){
973  lisi=CONS(STATEMENT,
975  sequence_statements(seqi)=lisi;
976  }
977  else{
978  list lexp;
979  call ca;
980  expression exp1,exp2;
981  Pvecteur pv;
982  statement s;
983  pv=vect_dup (pvif1);
984  vect_erase_var( &pv,indice2);
985  exp1=Pvecteur_to_expression(pv);
986  s= copy_statement (first);
988  (-vect_coeff(indice2,pvif1)), NIL);
989  lexp = CONS(EXPRESSION, exp1, lexp);
993  exp2=int_to_expression(0);
994  exp1=eq_expression(exp1,exp2);
996  lisi=CONS(STATEMENT,s,lisi);
997  sequence_statements(seqi)=lisi;
998  };
999  };
1000 
1001  /* fins cas1 */
1002 
1003 
1004  /*debut cas2 */
1005 
1006  if ( egalite_equal(csup,cif2)) {
1007  list listemp;
1008  if (value_abs (vect_coeff(indice2,pvif2))==1){
1009  listemp=CONS(STATEMENT,
1011  lisi= gen_concatenate(lisi,listemp);
1012  sequence_statements(seqi)=lisi;
1013  }
1014  else{
1015  list lexp;
1016  call ca;
1017  expression exp1,exp2;
1018  Pvecteur pv;
1019  statement s;
1020  pv=vect_dup (pvif2);
1021  vect_erase_var( &pv,indice2);
1022  exp1=Pvecteur_to_expression(pv);
1023  s= copy_statement (last);
1025  (-vect_coeff(indice2,pvif2)), NIL);
1026  lexp = CONS(EXPRESSION, exp1, lexp);
1030  exp2=int_to_expression(0);
1031  exp1=eq_expression(exp1,exp2);
1033  listemp=CONS(STATEMENT,s ,NIL);
1034  lisi= gen_concatenate(lisi,listemp);
1035  sequence_statements(seqi)=lisi;
1036  };
1037  };
1038 
1039 
1040  /* fin cas2 */
1041  /* debut cas3 */
1042 
1043  if ( egalite_equal(cinf,cif2)) {
1044  statement sif1;
1045  sequence seqif1;
1046  instruction insif1;
1047  Pvecteur v;
1048  Value constante;
1049  seqif1=make_sequence(lisjcopy2);
1050  insif1=make_instruction_sequence(seqif1);
1051  sif1=instruction_to_statement(insif1);
1052  if (value_abs (vect_coeff(indice2,pvif2))==1){
1053  lisi=gen_concatenate(lisjcopy2,lisi);
1054  sequence_statements(seqi)=lisi;
1055  }
1056  else{
1057  list lexp;
1058  call ca;
1059  expression exp1,exp2;
1060  Pvecteur pv;
1061  Value val;
1062  statement s/*,s1*/;
1063  pv=vect_dup (pvif2);
1064  val=vect_coeff(indice2,pvif2);
1065  vect_erase_var( &pv,indice2);
1066  exp1=Pvecteur_to_expression(pv);;
1067  s= copy_statement (last);
1068 
1070  (-val), NIL);
1071  lexp = CONS(EXPRESSION, exp1, lexp);
1075  exp2=int_to_expression(0);
1076  exp1=eq_expression(exp1,exp2);
1079  lisi=CONS(STATEMENT,s,lisi);
1080  sequence_statements(seqi)=lisi;
1081  };
1082  v = vect_dup (contrainte_vecteur(cinf));
1083  constante=vect_coeff(TCST,v);
1084  vect_chg_coeff(&v,TCST,value_plus(1,constante));
1085  cinf=contrainte_make(v);
1087  }
1088  /*fin cas3 */
1089  /* debut cas4 */
1090 
1091  if ( egalite_equal(csup,cif1)){
1092  statement sif2;
1093  sequence seqif2;
1094  instruction insif2;
1095  Pvecteur v;
1096  list listemp;
1097  Value constante;
1098  seqif2=make_sequence(lisjcopy);
1099  insif2=make_instruction_sequence(seqif2);
1100  sif2=instruction_to_statement(insif2);
1101  if (value_abs (vect_coeff(indice2,pvif1))==1){
1102  lisi=gen_concatenate(lisi,lisjcopy);
1103  sequence_statements(seqi)=lisi;
1104  }
1105  else{
1106  list lexp;
1107  call ca;
1108  expression exp1,exp2;
1109  Pvecteur pv;
1110  statement s;
1111  pv=vect_dup (pvif1);
1112  vect_erase_var( &pv,indice2);
1113  exp1=Pvecteur_to_expression(pv);
1114  s= copy_statement (first);
1116  (-vect_coeff(indice2,pvif1)), NIL);
1117  lexp = CONS(EXPRESSION, exp1, lexp);
1121  exp2=int_to_expression(0);
1122  exp1=eq_expression(exp1,exp2);
1125  listemp=CONS(STATEMENT,s ,NIL);
1126  lisi= gen_concatenate(lisi,listemp);
1127  sequence_statements(seqi)=lisi;
1128  };
1129  v=vect_dup( contrainte_vecteur(csup));
1130  constante=vect_coeff(TCST,v);
1131  vect_chg_coeff(&v,TCST,value_plus(1,constante));
1132  csup=contrainte_make(v);
1134 
1135  }
1136 
1137  /*fin cas4 */
1138  };
1139  if (i%2==0){
1140  if (condition1||condition2) isoler =i;
1141  }
1142 
1143  };
1144  lis= gen_nreverse(lis);
1145  i=-1;
1146  lisp=lis;
1147  FOREACH(STATEMENT,s,lis)
1148  {
1149  i++;if((i!=isoler)&&(i%2==0)&&(i!=isoler2)) {
1150  if(i==0) {
1151  CHUNK( CAR(lisp))= (gen_chunk *) make_block_statement(NIL);
1152  range_lower(loop_range(tab_loop[i+1]))=
1153  int_to_expression( sommetg[(i+1)/2]);
1154  }
1155  else{
1156  if(i==2*nbr_vertice-2){
1157  CHUNK( CAR(lisp))= (gen_chunk *) make_block_statement(NIL);
1158  range_upper(loop_range(tab_loop[i-1]))=
1159  int_to_expression(sommetg[(i-1)/2+1]);
1160  }
1161  else{
1162  body1=loop_body(tab_loop[i]);
1163  ins =statement_instruction(body1);
1164  seq=instruction_sequence(ins);
1165  lisi =sequence_statements(seq);
1167  loop2 =s1; },lisi) ;
1168  ins =statement_instruction(loop2);
1169  range1=loop_range(instruction_loop(ins));
1170  body1=loop_body(tab_loop[i-1]);
1171  ins =statement_instruction(body1);
1172  seq=instruction_sequence(ins);
1173  lisi =sequence_statements(seq);
1175  loop2 =s1; },lisi) ;
1176  ins =statement_instruction(loop2);
1177  range2=loop_range(instruction_loop(ins));
1178  body1=loop_body(tab_loop[i+1]);
1179  ins =statement_instruction(body1);
1180  seq=instruction_sequence(ins);
1181  lisi =sequence_statements(seq);
1183  loop2 =s1; },lisi) ;
1184  ins =statement_instruction(loop2);
1185  range3=loop_range(instruction_loop(ins));
1186  if (range_equal_p(range1,range2)) {
1187  CHUNK( CAR(lisp))= (gen_chunk *) make_block_statement(NIL);
1188  range_upper(loop_range(tab_loop[i-1]))=
1189  int_to_expression( sommetg[(i-1)/2+1]);
1190  }
1191  else {
1192  CHUNK( CAR(lisp))= (gen_chunk *) make_block_statement(NIL);
1193  if (range_equal_p(range1,range3))
1194  range_lower(loop_range(tab_loop[i+1]))=
1195  int_to_expression( sommetg[(i+1)/2]);
1196  }
1197  };
1198  };
1199 
1200  };
1201  lisp=CDR(lisp);
1202  }
1203  seq=make_sequence (lis);
1204  ins= make_instruction_sequence(seq);
1205  return( instruction_to_statement(ins));
1206 }
instruction make_instruction_loop(loop _field_)
Definition: ri.c:1175
call make_call(entity a1, list a2)
Definition: ri.c:269
loop copy_loop(loop p)
LOOP.
Definition: ri.c:1265
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
statement copy_statement(statement p)
STATEMENT.
Definition: ri.c:2186
instruction make_instruction_sequence(sequence _field_)
Definition: ri.c:1169
syntax make_syntax(enum syntax_utype tag, void *val)
Definition: ri.c:2491
sequence make_sequence(list a)
Definition: ri.c:2125
struct _newgen_struct_expression_ * expression
Definition: alias_private.h:21
#define value_plus(v1, v2)
binary operators on values
#define value_abs(val)
static list lexp
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
#define contrainte_vecteur(c)
passage au champ vecteur d'une contrainte "a la Newgen"
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
bool egalite_equal(Pcontrainte, Pcontrainte)
bool egalite_equal(Pcontrainte eg1, Pcontrainte eg2): teste l'equivalence de deux egalites; leurs coe...
Definition: predicats.c:98
#define CHUNK(x)
Definition: genC.h:90
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
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
list gen_concatenate(const list l1x, const list l2x)
concatenate two lists.
Definition: list.c:436
#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
list gen_last(list l)
Return the last element of a list.
Definition: list.c:578
#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
#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
list gen_full_copy_list(list l)
Copy a list structure with element copy.
Definition: list.c:535
Psysteme sc_newbase
include <sys/ddi.h>
bool if2
Ptsg sg
static Value eval2(Value val0, Value val1, Value val2, Value val)
bool if1
bool vect_equal(Pvecteur v1, Pvecteur v2)
bool vect_equal(Pvecteur v1, Pvecteur v2): test a egalite de deux vecteurs
Definition: reductions.c:278
bool vect_oppos(Pvecteur v1, Pvecteur v2)
bool vect_oppos(Pvecteur v1, Pvecteur v2): test de l'opposition de deux vecteurs
Definition: reductions.c:360
loop loop1
tiling_sequence.c
struct _newgen_struct_range_ * range
Definition: message.h:21
void normalize_all_expressions_of(void *obj)
Definition: normalize.c:668
static void norm(struct rproblem *RR)
cette procedure normalise la fonction cout, calcule les valeurs des seconds membres resultant d'une n...
Definition: r1.c:271
#define eq_expression(e1, e2)
#define MODULO_OPERATOR_NAME
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression Pvecteur_to_expression(Pvecteur vect)
AP, sep 25th 95 : some usefull functions moved from static_controlize/utils.c.
Definition: expression.c:1825
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 make_contrainte_expression(Pcontrainte pc, Variable index)
A wrapper around make_constraint_expression() for compatibility.
Definition: expression.c:1815
bool range_equal_p(range r1, range r2)
Definition: expression.c:1522
#define loop_body(x)
Definition: ri.h:1644
#define normalized_undefined
Definition: ri.h:1745
#define instruction_loop_p(x)
Definition: ri.h:1518
#define range_upper(x)
Definition: ri.h:2290
#define instruction_loop(x)
Definition: ri.h:1520
@ is_syntax_call
Definition: ri.h:2693
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
struct _newgen_struct_call_ * call
Definition: ri.h:63
#define expression_normalized(x)
Definition: ri.h:1249
struct _newgen_struct_syntax_ * syntax
Definition: ri.h:407
#define test_true(x)
Definition: ri.h:2835
#define sequence_statements(x)
Definition: ri.h:2360
#define instruction_sequence(x)
Definition: ri.h:1514
#define syntax_call(x)
Definition: ri.h:2736
#define test_condition(x)
Definition: ri.h:2833
#define range_lower(x)
Definition: ri.h:2288
#define statement_instruction(x)
Definition: ri.h:2458
#define loop_range(x)
Definition: ri.h:1642
#define call_arguments(x)
Definition: ri.h:711
#define instruction_test(x)
Definition: ri.h:1517
#define normalized_linear(x)
Definition: ri.h:1781
#define expression_syntax(x)
Definition: ri.h:1247
#define loop_index(x)
Definition: ri.h:1640
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
int printf()
s1
Definition: set.c:247
#define sg_sommets(sg)
vieilles definitions des fonctions d'impression void sg_fprint(); #define print_sg(sg) sg_fprint(stdo...
Definition: sg-local.h:85
#define sg_nbre_sommets(sg)
nombre de sommets: int sg_nbre_sommets(Ptsg)
Definition: sg-local.h:96
Pvecteur vecteur
struct Scontrainte * succ
Pcontrainte inegalites
Definition: sc-local.h:71
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
structure de donnees Sommet
Definition: sommet-local.h:64
struct typ_som * succ
Definition: sommet-local.h:68
Pvecteur vecteur
Definition: sommet-local.h:66
Value denominateur
Definition: sommet-local.h:67
A gen_chunk is used to store every object.
Definition: genC.h:58
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Definition: alloc.c:51
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2)
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2): allocation d'un vecteur v dont la valeur est la di...
Definition: binaires.c:75
void vect_erase_var(Pvecteur *ppv, Variable v)
void vect_erase_var(Pvecteur * ppv, Variable v): projection du vecteur *ppv selon la direction v (i....
Definition: unaires.c:106
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Definition: unaires.c:72
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val)
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val): mise de la coordonnee var du vecteur *pp...
Definition: unaires.c:143

References call_arguments, CAR, CDR, CHUNK, CONS, contrainte_make(), contrainte_vecteur, copy_loop(), copy_statement(), typ_som::denominateur, egalite_equal(), entity_intrinsic(), eq_expression, eval2(), exp, EXPRESSION, expression_normalized, expression_syntax, FOREACH, gen_concatenate(), gen_full_copy_list(), gen_last(), gen_nreverse(), if1, if2, Ssysteme::inegalites, instruction_loop, instruction_loop_p, instruction_sequence, instruction_test, instruction_to_statement(), int_to_expression(), is_syntax_call, lexp, loop1, loop_body, loop_index, loop_range, make_block_statement(), make_call(), make_contrainte_expression(), make_expression(), make_instruction_loop(), make_instruction_sequence(), make_sequence(), make_syntax(), MAP, MODULO_OPERATOR_NAME, NIL, norm(), normalize_all_expressions_of(), normalized_linear, normalized_undefined, printf(), Pvecteur_to_expression(), range_equal_p(), range_lower, range_upper, s1, sc_newbase, sequence_statements, sg, sg_nbre_sommets, sg_sommets, STATEMENT, statement_instruction, Scontrainte::succ, typ_som::succ, syntax_call, TCST, test_condition, test_true, value_abs, value_direct_multiply, value_div, value_plus, vect_add_elem(), vect_chg_coeff(), vect_coeff(), vect_dup(), vect_equal(), vect_erase_var(), vect_oppos(), vect_substract(), Scontrainte::vecteur, typ_som::vecteur, and VECTEUR_NUL.

Referenced by guard_elimination().

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

◆ guard_elimination()

bool guard_elimination ( string  module)

set_ordering_to_statement(stat);

MAP(STATEMENT,s,{printf("%d \n",statement_ordering(s));},lis)

gen_recurse(stat, statement_domain, gen_true,);

Parameters
moduleodule

Definition at line 1208 of file guard_elimination.c.

1209 {
1210 
1211  statement stat,s1;
1212  string str ;
1213  int ordering ;
1214  instruction ins;
1215  sequence seq;
1216  list lis;
1217  context_t context;
1218  debug_on("GUARD_ELIMINATION_DEBUG_LEVEL");
1219  pips_debug(1, "considering module %s\n", module);
1221  stat = (statement) db_get_memory_resource(DBR_CODE, module, true);
1223  context.statement_stack = stack_make(statement_domain, 0, 0);
1224 
1225  // user_request
1226  // recherche le statement dans stat
1227  // appliquer...
1228 
1229  /* set_ordering_to_statement(stat); */
1230  ins=statement_instruction(stat);
1231  seq=instruction_sequence(ins);
1232  lis =sequence_statements(seq);
1233  /* MAP(STATEMENT,s,{printf("%d \n",statement_ordering(s));},lis) */
1234 
1235  str = user_request("Which nid do you want to treat?\n"
1236  "(give its ordering): ");
1237  ordering=atoi(str);
1238 
1239 
1240  s1=ordering_to_statement(ordering);
1241 
1245  NULL);
1246  str = user_request("for Which nid do you want apply unimodular "
1247  "transformation ?\n" "(give its ordering): ");
1248  ordering=atoi(str);
1249 
1250  s1=ordering_to_statement(ordering);
1251  MAP(STATEMENT,s,{if (statement_ordering(s)==ordering){
1252  s1=unimodular(s1); ; s1= free_guards(s1);
1253  CHUNK(CAR(lis))= (gen_chunk *) s1;}
1254  ;lis=CDR(lis) ;},lis)
1255 
1256 
1257 
1258 
1259  /* gen_recurse(stat, statement_domain, gen_true,); */
1260  module_reorder(stat);
1261 
1262  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module, stat);
1265  debug_off();
1266  return true;
1267 }
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
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
Definition: genClib.c:3373
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
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
static bool stmt_flt(statement s, context_p context)
statement free_guards(statement s)
statement unimodular(s)
static void stmt_rwt(statement s, context_p context)
static bool loop_flt(loop l, context_p context)
#define debug_on(env)
Definition: misc-local.h:157
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define debug_off()
Definition: misc-local.h:160
string user_request(const char *,...)
stack stack_make(int, int, int)
allocation
Definition: stack.c:246
statement ordering_to_statement(int o)
Get the statement associated to a given ordering.
Definition: ordering.c:111
static char * module
Definition: pips.c:74
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
#define loop_domain
newgen_language_domain_defined
Definition: ri.h:218
#define statement_ordering(x)
Definition: ri.h:2454
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
cette structure contient une pile.
Definition: delay.c:253

References CAR, CDR, CHUNK, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, free_guards(), gen_context_multi_recurse(), gen_null(), instruction_sequence, local_name_to_top_level_entity(), loop_domain, loop_flt(), MAP, module, module_reorder(), ordering_to_statement(), pips_debug, reset_current_module_entity(), reset_current_module_statement(), s1, sequence_statements, set_current_module_entity(), set_current_module_statement(), stack_make(), STATEMENT, statement_domain, statement_instruction, statement_ordering, stmt_flt(), stmt_rwt(), unimodular(), and user_request().

+ Here is the call graph for this function:

◆ intersection()

static Value intersection ( Pvecteur  pv1,
Pvecteur  pv2,
Variable  var,
floor   
)
static

Definition at line 100 of file guard_elimination.c.

104 {
105  if (floor==1)
106  return
108  vect_coeff(var,pv1 )- vect_coeff(var,pv2 ) );
109  else
110  return
111  myceil(vect_coeff(TCST,pv2) -vect_coeff(TCST,pv1),
112  vect_coeff(var,pv1 )- vect_coeff(var,pv2 ) );
113 
114 }
static Value myfloor(Value k, Value m)
static Value myceil(Value k, Value m)

References myceil(), myfloor(), TCST, and vect_coeff().

Referenced by loop_flt().

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

◆ loop_flt()

static bool loop_flt ( loop  l,
context_p  context 
)
static

ECLARATION

ND OF DECLARATION

Definition at line 127 of file guard_elimination.c.

128 {
129  /*DECLARATION */
130  statement s1=NULL,s2=NULL,s_in_loop_in_side=NULL,st=NULL;
131  int i=0,cas=0;
132  bool first1=true,first2=true;
133  Value val1=0,val2=0,f1_val1,f1_val2,f2_val1,f2_val2,e=0;
134  loop copyloop,loop_in_side=NULL;
135  Variable var1= (Variable)loop_index(l);
136  instruction ins,ins1,ins2;
137  sequence seq,seq1,seq2;
138  list lis=NIL,lis1=NIL,lis1par=NIL,lis2=NIL,lis2par=NIL;
139  range range;
140  expression lower, upper,index=NULL ;
141  normalized norm1, norm2;
142  Pvecteur pv1 ,pv2;
143  test t1,t2;
144  /*END OF DECLARATION */
145 
146  copyloop =copy_loop(l);
147  range=loop_range(l);
148  lower=range_lower(range);
149  upper=range_upper(range);
152  norm1=expression_normalized(lower);
153  norm2=expression_normalized(upper);
154  pips_assert("normalized are linear", normalized_linear_p(norm1)&&
155  normalized_linear_p(norm2));
156  pv1= normalized_linear(norm1);
157  pv2= normalized_linear(norm2);
158  val1= vect_coeff(TCST,pv1);
159  val2=vect_coeff(TCST,pv2);
161  if (instruction_sequence_p(ins))
162  {
163  seq = instruction_sequence(ins);
164  lis =sequence_statements(seq);
166  i++;
167  if(!(instruction_loop_p(ins1))&&first1 ) {
168  if (instruction_call_p(ins1 )) {
169  call ca= instruction_call(ins1 ) ;
170  if(strcmp(entity_name(call_function(ca)),"TOP-LEVEL:CONTINUE" )!=0){
171  if (i==1) { lis1=CONS(STATEMENT,s,NIL); lis1par=lis1;}
172  else {
173  CDR(lis1par)=CONS(STATEMENT,s,NIL);
174  lis1par=CDR(lis1par);
175  };
176  };
177  }
178  else
179  {
180  if (i==1) {
181  lis1=CONS(STATEMENT,s,NIL);
182  lis1par=lis1;
183  }
184  else {
185  CDR(lis1par)=CONS(STATEMENT,s,NIL);
186  lis1par=CDR(lis1par);
187  };
188  };
189  };
190  if( (instruction_loop_p(ins1))&&first1 ) {
191  loop_in_side=instruction_loop(ins1);
192  index= entity_to_expression(loop_index(loop_in_side));
193  s_in_loop_in_side=loop_body( loop_in_side );
194  range=loop_range(loop_in_side);
195  lower=range_lower(range);
196  upper=range_upper(range);
199  norm1=expression_normalized(lower);
200  norm2=expression_normalized(upper);
201  pips_assert("normalized are linear", normalized_linear_p(norm1) &&
202  normalized_linear_p(norm2));
203  pv1= normalized_linear(norm1);
204  pv2= normalized_linear(norm2);
205  f1_val1= eval(pv1,val1,var1);
206  f1_val2= eval(pv1,val2,var1);
207  f2_val1= eval(pv2,val1,var1);
208  f2_val2= eval(pv2,val2,var1);
209  if ( (f2_val1 >=f1_val1)&&(f2_val2 >=f1_val2)){
210  cas=1;
211  loop_body(l)=s;
212  }
213  else {
214  if ( (f2_val1 >=f1_val1)&&(f2_val2 <f1_val2)){
215  cas=2;
216  loop_body(l)=s;
217  e=intersection(pv1,pv2,var1,1);
218  }
219  else{
220  if ( (f2_val1 < f1_val1)&&(f2_val2 >= f1_val2)){
221  e=intersection(pv1,pv2,var1,2);
222  cas=3;
223  loop_body(l)=s;
224  }
225  else {
226  cas=4;
228  }
229  }
230  }
231  first1 =false;
232  i=0;
233  }
234  if ( (! first1 )&&(i !=0)) {
235  if (instruction_call_p(ins1 )) {
236  call ca= instruction_call(ins1 ) ;
237  if( strcmp( entity_name(call_function(ca)),"TOP-LEVEL:CONTINUE" )!=0){
238  if (i==1) {
239  lis2=CONS(STATEMENT,s,NIL);
240  lis2par=lis2;
241  }
242  else {
243  CDR(lis2par)=CONS(STATEMENT,s,NIL);
244  lis2par=CDR(lis2par);
245  };
246  };
247  }
248  else {
249  if (i==1)
250  {
251  lis2=CONS(STATEMENT,s,NIL);
252  lis2par=lis2;
253  }
254  else{
255  CDR(lis2par)=CONS(STATEMENT,s,NIL);
256  lis2par=CDR(lis2par);
257  };
258  };
259  };
260  lis=CDR(lis);
261  ;},lis);
262  switch (cas) {
263  case 1:{
264  switch (gen_length(lis1)) {
265  case 0 :{ break;}
266  case 1 :{ s1=STATEMENT(CAR(lis1)); break;}
267  default :{ seq1= make_sequence(lis1);
268  ins1= make_instruction_sequence(seq1);
269  s1= instruction_to_statement(ins1); break;
270  }
271  };
272  switch (gen_length(lis2)) {
273  case 0 :{ break;}
274  case 1 :{ s2=STATEMENT(CAR(lis2)); break;}
275  default :{ seq2= make_sequence(lis2);
276  ins2= make_instruction_sequence(seq2);
277  s2= instruction_to_statement(ins2); break;
278  }
279  };
280  if (gen_length(lis1)!=0)
281  { expression copyindex, copylower;
282  copyindex=copy_expression(index);
283  copylower=copy_expression(lower);
284  t1= make_test(eq_expression (copyindex,copylower),s1,
286  s1=test_to_statement(t1);
287  if1=true;
288  };
289  if (gen_length(lis2)!=0)
290  { expression copyindex, copyupper;
291  copyindex=copy_expression(index);
292  copyupper=copy_expression(upper);
293  t2= make_test(eq_expression (copyindex,copyupper) ,s2,
295  s2=test_to_statement(t2);
296  if2=true;
297  };
298  if (gen_length(lis2)!=0)
299  lis=CONS(STATEMENT , s2,NIL);
300  else{
302  lis=CONS(STATEMENT,s2,NIL);
303  };
304  lis=CONS(STATEMENT,s_in_loop_in_side,lis);
305  if (gen_length(lis1)!=0)
306  lis=CONS(STATEMENT,s1,lis);
307  else
309  seq= make_sequence(lis);
310  ins= make_instruction_sequence(seq);
311  s_in_loop_in_side= instruction_to_statement(ins);
312  loop_body(loop_in_side)=s_in_loop_in_side;
313  break ;
314  }
315  case 2:{
316  switch (gen_length(lis1)) {
317  case 0 :{ break;}
318  case 1 :{ s1=STATEMENT(CAR(lis1)); break;}
319  default :{ seq1= make_sequence(lis1);
320  ins1= make_instruction_sequence(seq1);
321  s1= instruction_to_statement(ins1); break;
322  }
323  };
324  switch (gen_length(lis2)) {
325  case 0 :{ break;}
326  case 1 :{ s2=STATEMENT(CAR(lis2)); break;}
327  default :{ seq2= make_sequence(lis2);
328  ins2= make_instruction_sequence(seq2);
329  s2= instruction_to_statement(ins2); break;
330  }
331  };
332  if (gen_length(lis1)!=0)
333  {
334  expression copyindex, copylower;
335  copyindex=copy_expression(index);
336  copylower=copy_expression(lower);
337  t1= make_test(eq_expression (copyindex,copylower),s1,
339  s1=test_to_statement(t1);
340  };
341  if (gen_length(lis2)!=0)
342  {
343  expression copyindex, copyupper;
344  copyindex=copy_expression(index);
345  copyupper=copy_expression(upper);
346  t2= make_test(eq_expression (copyindex,copyupper) ,s2,
348  s2=test_to_statement(t2);
349  };
350  if (gen_length(lis2)!=0)
351  lis=CONS(STATEMENT , s2,NIL);
352  else{
354  lis=CONS(STATEMENT,s2,NIL);
355  };
356  lis=CONS(STATEMENT,s_in_loop_in_side,lis);
357  if (gen_length(lis1)!=0)
358  lis=CONS(STATEMENT,s1,lis);
359  else
361  seq= make_sequence(lis);
362  ins= make_instruction_sequence(seq);
363  s_in_loop_in_side= instruction_to_statement(ins);
364  loop_body(loop_in_side)=s_in_loop_in_side;
366  st=stack_head(context->statement_stack);
367  s1=copy_statement (st);
368  ins1 = statement_instruction(loop_body(copyloop));
369  seq = instruction_sequence(ins1);
370  lis =sequence_statements(seq);
372  if( (instruction_loop_p(ins1))&&first2 ) {
374  first2=false;
375  };
376  lis=CDR(lis);
377  ;},lis);
378  range_lower(loop_range(copyloop))= int_to_expression(e+1);
379  s2=loop_to_statement(copyloop);
380  lis=CONS(STATEMENT,s1,CONS(STATEMENT,s2,NIL));
381  seq=make_sequence(lis);
382  ins=make_instruction_sequence(seq);
383  statement_instruction(st) = ins;
384  break ;
385  }
386 
387  case 3: {
388  switch (gen_length(lis1)) {
389  case 0 :{ break;}
390  case 1 :{ s1=STATEMENT(CAR(lis1)); break;}
391  default :{ seq1= make_sequence(lis1);
392  ins1= make_instruction_sequence(seq1);
393  s1= instruction_to_statement(ins1); break;
394  }
395  };
396  switch (gen_length(lis2)) {
397  case 0 :{ break;}
398  case 1 :{ s2=STATEMENT(CAR(lis2)); break;}
399  default :{ seq2= make_sequence(lis2);
400  ins2= make_instruction_sequence(seq2);
401  s2= instruction_to_statement(ins2); break;
402  }
403  };
404  if (gen_length(lis1)!=0)
405  {
406  expression copyindex, copylower;
407  copyindex=copy_expression(index);
408  copylower=copy_expression(lower);
409  t1= make_test(eq_expression (copyindex,copylower),s1,
411  s1=test_to_statement(t1);
412  if1=true;
413  };
414  if (gen_length(lis2)!=0)
415  {
416  expression copyindex, copyupper;
417  copyindex=copy_expression(index);
418  copyupper=copy_expression(upper);
419  t2= make_test(eq_expression (copyindex,copyupper) ,s2,
421  s2=test_to_statement(t2);
422  if2=true;
423  };
424  if (gen_length(lis2)!=0)
425  lis=CONS(STATEMENT , s2,NIL);
426  else{
428  lis=CONS(STATEMENT,s2,NIL);
429  };
430  lis=CONS(STATEMENT,s_in_loop_in_side,lis);
431  if (gen_length(lis1)!=0)
432  lis=CONS(STATEMENT,s1,lis);
433  else
435  seq= make_sequence(lis);
436  ins= make_instruction_sequence(seq);
437  s_in_loop_in_side= instruction_to_statement(ins);
438  loop_body(loop_in_side)=s_in_loop_in_side;
440  st=stack_head(context->statement_stack);
441  s2=copy_statement (st);
442  ins = statement_instruction(loop_body(copyloop));
443  seq = instruction_sequence(ins);
444  lis =sequence_statements(seq);
446  if( (instruction_loop_p(ins1))&&first2 ) {
448  first2=false;};
449  lis=CDR(lis);
450  ;},lis);
451  range_upper(loop_range(copyloop))= int_to_expression(e-1);
452  s1=loop_to_statement(copyloop);
453  lis=CONS(STATEMENT,s1,CONS(STATEMENT,s2,NIL));
454  seq=make_sequence(lis);
455  ins=make_instruction_sequence(seq);
456  statement_instruction(st) = ins;
457  break;}
458  case 4 :{ break;}
459  default :{break;}
460  };
461  };
462  return false;
463 }
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
test make_test(expression a1, statement a2, statement a3)
Definition: ri.c:2607
size_t gen_length(const list l)
Definition: list.c:150
static Value intersection(Pvecteur pv1, Pvecteur pv2, Variable var, floor)
static Value eval(Pvecteur pv, Value val, Variable var)
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
void * stack_head(const stack)
returns the item on top of stack s
Definition: stack.c:420
#define loop_to_statement(l)
#define test_to_statement(t)
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
#define instruction_sequence_p(x)
Definition: ri.h:1512
#define normalized_linear_p(x)
Definition: ri.h:1779
#define call_function(x)
Definition: ri.h:709
#define entity_name(x)
Definition: ri.h:2790
#define instruction_call_p(x)
Definition: ri.h:1527
#define instruction_call(x)
Definition: ri.h:1529

References call_function, CAR, CDR, CHUNK, CONS, copy_expression(), copy_loop(), copy_statement(), entity_name, entity_to_expression(), eq_expression, eval(), expression_normalized, gen_length(), if1, if2, instruction_call, instruction_call_p, instruction_loop, instruction_loop_p, instruction_sequence, instruction_sequence_p, instruction_to_statement(), int_to_expression(), intersection(), loop_body, loop_index, loop_range, loop_to_statement, make_block_statement(), make_instruction_sequence(), make_sequence(), make_test(), MAP, NIL, normalize_all_expressions_of(), normalized_linear, normalized_linear_p, pips_assert, range_lower, range_upper, s1, sequence_statements, stack_head(), STATEMENT, statement_instruction, TCST, test_to_statement, and vect_coeff().

Referenced by guard_elimination().

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

◆ myceil()

static Value myceil ( Value  k,
Value  m 
)
static

Definition at line 56 of file guard_elimination.c.

58 {
59  Value res;
60  res = value_div(k,m);
61  if(value_mod(k,m)==0) return res;
62  else
63  {
64  if ( value_direct_multiply(k,m)>=0 ) return res+1;
65  else return res;
66  }
67 }
#define value_mod(v1, v2)

References value_direct_multiply, value_div, and value_mod.

Referenced by intersection().

+ Here is the caller graph for this function:

◆ myfloor()

static Value myfloor ( Value  k,
Value  m 
)
static

Definition at line 69 of file guard_elimination.c.

71 {
72  Value res;
73  res = value_div(k,m);
74  if(value_mod(k,m)==0) return res;
75  else
76  {
77  if ( value_direct_multiply(k,m)>=0 ) return res;
78  else return res-1;
79  }
80 }

References value_direct_multiply, value_div, and value_mod.

Referenced by intersection().

+ Here is the caller graph for this function:

◆ stmt_flt()

static bool stmt_flt ( statement  s,
context_p  context 
)
static

Definition at line 116 of file guard_elimination.c.

117 {
118  stack_push(s, context->statement_stack);
119  return true;
120 }
void stack_push(void *, stack)
stack use
Definition: stack.c:373

References stack_push().

Referenced by guard_elimination().

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

◆ stmt_rwt()

static void stmt_rwt ( statement  s,
context_p  context 
)
static

Definition at line 121 of file guard_elimination.c.

122 {
123  pips_assert("true", s==s && context==context);
124  stack_pop(context->statement_stack);
125 }
void * stack_pop(stack)
POPs one item from stack s.
Definition: stack.c:399

References pips_assert, and stack_pop().

Referenced by guard_elimination().

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

◆ unimodular()

statement unimodular ( )

sc initial

sc nouveau

number of index

number of constraints

create the new system of constraintes (Psysteme scn) with
AG and sci

computation of the new iteration space in the new basis G

change of basis for index

generation of hyperplane code

generation of bounds

loop body generation

FI: I do not know if the last parameter should be true or false

Definition at line 465 of file guard_elimination.c.

467 {
468  FILE *infp;
469  char *name_file;
470  cons *lls=NULL;
471  Psysteme sci; /* sc initial */
472  Psysteme scn; /* sc nouveau */
473  Psysteme sc_row_echelon;
474  Pbase base_oldindex = NULL;
475  Pbase base_newindex = NULL;
476  matrice A;
477  matrice G;
478  matrice AG;
479  matrice G_inv;
480  int n; /* number of index */
481  int m ; /* number of constraints */
482  statement s_lhyp;
483  Pvecteur *pvg;
484  Pbase pb;
485  expression lower, upper;
486  Pvecteur pv1 ;
487  loop l;
489  lls = CONS(STATEMENT,s,lls);
491  }
492  sci = loop_iteration_domaine_to_sc(lls, &base_oldindex);
493  sc_dump(sci);
494  n = base_dimension(base_oldindex);
495  m = sci->nb_ineq;
496  A = matrice_new(m,n);
497  sys_matrice_index(sci, base_oldindex, A, n, m);
498  name_file = user_request("nom du fichier pour la matrice T");
499  infp = safe_fopen(name_file,"r");
500  matrice_fscan(infp,&G,&n,&n);
501  safe_fclose(infp, name_file);
502  free(name_file);
503  G_inv = matrice_new(n,n);
504  matrice_general_inversion(G,G_inv,n);
505  AG = matrice_new(m,n);
506  matrice_multiply(A, G_inv, AG, m, n, n);
507  printf( " tototototo \n");
508  /* create the new system of constraintes (Psysteme scn) with
509  AG and sci */
510  scn = sc_dup(sci);
511  matrice_index_sys(scn, base_oldindex, AG, n,m );
512 
513  /* computation of the new iteration space in the new basis G */
514  sc_row_echelon = new_loop_bound(scn,base_oldindex);
515 
516 
517  /* change of basis for index */
518  change_of_base_index(base_oldindex, &base_newindex);
519 
520  sc_newbase = sc_change_baseindex(sc_dup(sc_row_echelon), base_oldindex, base_newindex);
521 
522 
526  /* generation of hyperplane code */
527  /* generation of bounds */
528  for (pb=base_newindex; pb!=NULL; pb=pb->succ) {
529  make_bound_expression(pb->var, base_newindex, sc_newbase, &lower, &upper);
530  }
531  /* loop body generation */
532  pvg = (Pvecteur *)malloc((unsigned)n*sizeof(Svecteur));
533  scanning_base_to_vect(G_inv,n,base_newindex,pvg);
534  pv1 = sc_row_echelon->inegalites->succ->vecteur;
535  (void)vect_change_base(pv1,base_oldindex,pvg);
537  lower = range_upper(loop_range(l));
538  upper= expression_to_expression_newbase(lower, pvg, base_oldindex);
539  /* FI: I do not know if the last parameter should be true or false */
540  s_lhyp = code_generation(lls, pvg, base_oldindex, base_newindex, sc_newbase, true);
541  printf(" finn \n");
542  return(s_lhyp);
543 }
void change_of_base_index(Pbase base_oldindex, Pbase *base_newindex)
void change_of_base_index(Pbase base_oldindex, Pbase *base_newindex) change of variable index from ba...
Psysteme sc_change_baseindex(Psysteme sc, Pbase base_old, Pbase base_new)
Psysteme sc_change_baseindex(Psysteme sc, Pbase base_old, Pbase base_new) le changement de base d'ind...
Ptsg sc_to_sg_chernikova(Psysteme sc)
chernikova_mulprec.c
Definition: chernikova.c:42
expression expression_to_expression_newbase(expression e_old, pvg, Pbase base_oldindex)
expression expression_to_expression_newbase(expression e_old,Pvecteur pvg[], Pbase base_oldindex) com...
Pvecteur vect_change_base(Pvecteur pv_old, Pbase base_oldindex, pvg)
Pvecteur vect_change_base(Pvecteur pv_old, Pvecteur pvg[], Pbase base_oldindex, Pbase base_newindex) ...
void scanning_base_to_vect(matrice G, int n, Pbase base, pvg)
void scanning_base_to_vect(matrice G,int n,Pbase base,Pvecteur pvg[n]) compute G*base and put the res...
statement code_generation(list lls, Pvecteur pvg[], Pbase base_oldindex, Pbase base_newindex, Psysteme sc_newbase, bool preserve_entry_label_p)
package hyperplane
#define A(i, j)
comp_matrice.c
Definition: comp_matrice.c:63
void sc_syst_debug(Psysteme s)
constraint_to_text.c
Psysteme loop_iteration_domaine_to_sc(list, Pbase *)
loop_iteration_domaine_to_sc.c
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
void * malloc(YYSIZE_T)
void free(void *)
#define matrice_new(n, m)
Allocation et desallocation d'une matrice.
Definition: matrice-local.h:77
Value * matrice
package matrice
Definition: matrice-local.h:71
void matrice_general_inversion(matrice a, matrice inv_a, int n)
void matrice_general_inversion(matrice a; matrice inv_a; int n) calcul de l'inversion du matrice gene...
Definition: inversion.c:222
void matrice_multiply(matrice a, matrice b, matrice c, int p, int q, int r)
void matrice_multiply(matrice a, matrice b, matrice c, int p, int q, int r): multiply rational matrix...
Definition: matrice.c:82
void matrice_fscan(FILE *, matrice *, int *, int *)
void matrice_fscan(FILE * f, matrice * a, int * n, int * m): read an (nxm) rational matrix in an ASCI...
Definition: matrice_io.c:115
void make_bound_expression(Variable index, Pbase base, Psysteme sc, expression *lower, expression *upper)
void make_bound_expression(variable index, Pbase base, Psysteme sc, expression *lower,...
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
void sc_dump(Psysteme sc)
void sc_dump(Psysteme sc): dump to stderr
Definition: sc_io.c:142
Psysteme new_loop_bound(Psysteme scn, Pbase base_index)
Psysteme new_loop_bound(Psysteme scn, Pbase base_index) computation of the new iteration space (given...
#define G(j, a, b)
maybe most of them should be functions?
void sys_matrice_index(Psysteme, Pbase, matrice, int, int)
Warning! Do not modify this file that is automatically generated!
void matrice_index_sys(Psysteme, Pbase, matrice, int, int)
void matrice_index_sys(Psysteme sc, Pbase base_index, matrice AG, int n, int m) replace the coefficie...
Definition: pip__tab.h:25
int nb_ineq
Definition: sc-local.h:73
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92
#define base_dimension(b)
struct Svecteur Svecteur
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique

References A, base_dimension, CAR, change_of_base_index(), code_generation(), CONS, expression_to_expression_newbase(), free(), G, Ssysteme::inegalites, instruction_loop, instruction_loop_p, loop_body, loop_iteration_domaine_to_sc(), loop_range, make_bound_expression(), malloc(), matrice_fscan(), matrice_general_inversion(), matrice_index_sys(), matrice_multiply(), matrice_new, Ssysteme::nb_ineq, new_loop_bound(), printf(), range_upper, safe_fclose(), safe_fopen(), sc_change_baseindex(), sc_dump(), sc_dup(), sc_newbase, sc_syst_debug(), sc_to_sg_chernikova(), scanning_base_to_vect(), sg, STATEMENT, statement_instruction, Scontrainte::succ, Svecteur::succ, sys_matrice_index(), user_request(), Svecteur::var, vect_change_base(), and Scontrainte::vecteur.

Referenced by guard_elimination().

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

Variable Documentation

◆ if1

bool if1 =false

Definition at line 49 of file guard_elimination.c.

Referenced by free_guards(), and loop_flt().

◆ if2

bool if2 =false

Definition at line 49 of file guard_elimination.c.

Referenced by free_guards(), and loop_flt().

◆ sc_newbase

Psysteme sc_newbase

include <sys/ddi.h>

guard_elimination.c

Definition at line 47 of file guard_elimination.c.

Referenced by code_generation(), free_guards(), hyperplane(), and unimodular().

◆ sg