Added SLI reduce
authorceriel <none@none>
Tue, 19 Feb 1991 16:45:57 +0000 (16:45 +0000)
committerceriel <none@none>
Tue, 19 Feb 1991 16:45:57 +0000 (16:45 +0000)
15 files changed:
util/ego/descr/Makefile
util/ego/descr/em22.descr
util/ego/descr/em24.descr
util/ego/descr/em44.descr
util/ego/descr/i86.descr
util/ego/descr/m68020.descr
util/ego/descr/m68k2.descr
util/ego/descr/m68k4.descr
util/ego/descr/pdp.descr
util/ego/descr/sparc.descr
util/ego/descr/vax4.descr
util/ego/sr/Makefile
util/ego/sr/sr.c
util/ego/sr/sr.h
util/ego/sr/sr_reduce.c

index 05a0364..3b73049 100644 (file)
@@ -4,7 +4,7 @@ EMLIB=$(EMHOME)/lib
 SHARE=../share
 CPP=$(EMLIB)/cpp
 
-LDFLAGS=-i
+LDFLAGS=
 CPPFLAGS=-DVERBOSE -DNOTCOMPACT
 CFLAGS=$(CPPFLAGS) -O
 LINTFLAGS=-hbu
index ca542cc..393420d 100644 (file)
@@ -68,6 +68,7 @@ access costs of local variables:
 %%SR
 overflow harmful?:  yes
 array bound harmful?:  yes
+reduce sli if shift count larger than:  0
 %%CS
 #include "../../../h/em_mnem.h"
 first time then space:
index dceee18..c218483 100644 (file)
@@ -68,6 +68,7 @@ access costs of local variables:
 %%SR
 overflow harmful?:  yes
 array bound harmful?:  yes
+reduce sli if shift count larger than:  0
 %%CS
 #include "../../../h/em_mnem.h"
 first time then space:
index 5989b70..e217416 100644 (file)
@@ -68,6 +68,7 @@ access costs of local variables:
 %%SR
 overflow harmful?:  yes
 array bound harmful?:  yes
+reduce sli if shift count larger than:  0
 %%CS
 #include "../../../h/em_mnem.h"
 first time then space:
index 1d2217e..2b09ef6 100644 (file)
@@ -83,6 +83,7 @@ access costs of local variables:
 %%SR
 overflow harmful?:  no
 array bound harmful?:  no
+reduce sli if shift count larger than:  0
 %%CS
 #include "../../../h/em_mnem.h"
 first time then space:
index 8b90a2e..cabf2f5 100644 (file)
@@ -92,6 +92,7 @@ access costs of local variables:
 %%SR
 overflow harmful?:  no
 array bound harmful?:  no
+reduce sli if shift count larger than:  3
 %%CS
 #include "../../../h/em_mnem.h"
 first time then space:
index 9f525d4..8a60deb 100644 (file)
@@ -90,6 +90,7 @@ access costs of local variables:
 %%SR
 overflow harmful?:  no
 array bound harmful?:  no
+reduce sli if shift count larger than:  0
 %%CS
 #include "../../../h/em_mnem.h"
 first time then space:
index dedf1d2..8a0b4b4 100644 (file)
@@ -92,6 +92,7 @@ access costs of local variables:
 %%SR
 overflow harmful?:  no
 array bound harmful?:  no
+reduce sli if shift count larger than:  0
 %%CS
 #include "../../../h/em_mnem.h"
 first time then space:
index dbdbb02..c2a5f8e 100644 (file)
@@ -82,6 +82,7 @@ access costs of local variables:
 %%SR
 overflow harmful?:  no
 array bound harmful?:  no
+reduce sli if shift count larger than:  0
 %%CS
 #include "../../../h/em_mnem.h"
 first time then space:
index 476ab3b..9385324 100644 (file)
@@ -87,6 +87,7 @@ access costs of local variables:
 %%SR
 overflow harmful?:  no
 array bound harmful?:  yes
+reduce sli if shift count larger than:  0
 %%CS
 #include "../../../h/em_mnem.h"
 first time then space:
index 389d94e..8a5f948 100644 (file)
@@ -101,7 +101,7 @@ access costs of local variables:
 %%SR
 overflow harmful?:  no
 array bound harmful?:  no
-
+reduce sli if shift count larger than:  3
 %%CS
 #include "../../../h/em_mnem.h"
 first time then space:
index 857de69..65a5b65 100644 (file)
@@ -4,7 +4,7 @@ EMH=$(EMHOME)/h
 EMLIB=$(EMHOME)/lib
 SHR=../share
 
-LDFLAGS=-i
+LDFLAGS=
 CPPFLAGS=-DVERBOSE -DNOTCOMPACT
 CFLAGS=$(CPPFLAGS) -O
 LINTFLAGS=-hbu
index 6bf880c..5db01e3 100644 (file)
@@ -24,7 +24,7 @@
 
 /* Strength reduction tries to change expensive operators occurring
  * in a loop into cheaper operators. The expensive operators considered
- * are multiplication and array referencing.
+ * are multiplication, left-shift and array referencing.
  * The transformations can be expressed in C as:
  *
  * [1]:                for (i = e1; i <= e2; i++)
@@ -46,6 +46,7 @@
 
 int ovfl_harmful;
 int arrbound_harmful;
+int sli_threshold;
 
 int Ssr;  /* #optimizations found */
 
@@ -63,6 +64,7 @@ sr_machinit(f)
        }
        fscanf(f,"%d",&ovfl_harmful);
        fscanf(f,"%d",&arrbound_harmful);
+       fscanf(f,"%d",&sli_threshold);
 }
 
 STATIC del_ivs(ivs)
index 623ad6e..466b710 100644 (file)
@@ -9,11 +9,6 @@
  *
  */
 
-/*#define SLI_REDUCE           /* if defined, shift-lefts are also reduced */
-                               /* not defined for the moment; should use
-                                * machine specific information (as should
-                                * reduction of array instructions      */
-
 typedef struct iv      *iv_p;
 typedef struct code_info *code_p;
 
@@ -70,6 +65,9 @@ extern int ovfl_harmful;  /* Does overflow during multiplication
 extern int arrbound_harmful;  /* Is it harmful to take the address of
                                * a non-existing array element ?
                                */
+extern int sli_threshold; /* Try to optimize SLI if shift-count larger than
+                           * this
+                           */
 extern int Ssr;  /* #optimizations found */
 
 /* core allocation macros */
index eb401e0..1b69d12 100644 (file)
@@ -45,10 +45,8 @@ STATIC int regtyp(code)
        switch(code->co_instr) {
                case op_mli:
                case op_mlu:
-#ifdef SLI_REDUCE
                case op_sli:
                case op_slu:
-#endif
                        return reg_any;
                default:
                        return reg_pointer;
@@ -92,10 +90,8 @@ STATIC line_p newcode(code,tmp)
        switch(code->co_instr) {
                case op_mli:
                case op_mlu:
-#ifdef SLI_REDUCE
                case op_sli:
                case op_slu:
-#endif
                        /* new code is just a LOL tmp */
                        l = int_line(tmp);
                        l->l_instr = op_lol;
@@ -201,7 +197,6 @@ STATIC init_code(code,tmp)
                        l->l_next = int_line(tmp);
                        l->l_next->l_instr = op_stl;
                        break;
-#ifdef SLI_REDUCE
                case op_sli:
                case op_slu:
                        /* reduced code is: iv_expr << lc
@@ -211,7 +206,6 @@ STATIC init_code(code,tmp)
                        l->l_next = int_line(tmp);
                        l->l_next->l_instr = op_stl;
                        break;
-#endif
                case op_lar:
                case op_sar:
                        /* reduced code is: ...= A[iv_expr] resp.
@@ -283,7 +277,6 @@ STATIC incr_code(code,tmp)
                        store_tmp = int_line(tmp);
                        store_tmp->l_instr = op_stl;
                        break;
-#ifdef SLI_REDUCE
                case op_sli:
                case op_slu:
                        loc = int_line(
@@ -297,7 +290,6 @@ STATIC incr_code(code,tmp)
                        store_tmp = int_line(tmp);
                        store_tmp->l_instr = op_stl;
                        break;
-#endif
                case op_lar:
                case op_sar:
                case op_aar:
@@ -416,10 +408,8 @@ STATIC bool same_code(c1,c2,vars)
        switch(c1->co_instr) {
                case op_mli:
                case op_mlu:
-#ifdef SLI_REDUCE
                case op_sli:
                case op_slu:
-#endif
                        return c1->co_instr == c2->co_instr &&
                        off_set(c1->c_o.co_loadlc) ==
                        off_set(c2->c_o.co_loadlc) &&
@@ -616,7 +606,6 @@ STATIC try_multiply(lp,ivs,vars,b,mul)
 
 
 
-#ifdef SLI_REDUCE
 STATIC try_leftshift(lp,ivs,vars,b,shft)
        loop_p   lp;
        lset     ivs,vars;
@@ -642,7 +631,7 @@ STATIC try_leftshift(lp,ivs,vars,b,shft)
         */
 
        l2 = PREV(shft); /* Instruction before the shift */
-       if (is_const(l2) &&
+       if (is_const(l2) && off_set(l2) > sli_threshold &&
                (is_ivexpr(PREV(l2),ivs,vars,&lbegin,&iv,&sign))) {
                        /* recognized "iv << const " */
                        c = newcinfo();
@@ -668,7 +657,6 @@ STATIC try_leftshift(lp,ivs,vars,b,shft)
 }
 
 
-#endif
 STATIC try_array(lp,ivs,vars,b,arr)
        loop_p   lp;
        lset     ivs,vars;
@@ -760,12 +748,10 @@ strength_reduction(lp,ivs,vars)
                        next = l->l_next;
                        if (TYPE(l) == OPSHORT && SHORT(l) == ws) {
                                switch(INSTR(l)) {
-#ifdef SLI_REDUCE
                                        case op_sli:
                                        case op_slu:
                                                try_leftshift(lp,ivs,vars,b,l);
                                                break;
-#endif
                                        case op_mlu:
                                        case op_mli:
                                                try_multiply(lp,ivs,vars,b,l);