From 79cb35ec4faa489a10fcae6cad8a4aaa85752ffb Mon Sep 17 00:00:00 2001 From: ceriel Date: Tue, 19 Feb 1991 16:45:57 +0000 Subject: [PATCH] Added SLI reduce --- util/ego/descr/Makefile | 2 +- util/ego/descr/em22.descr | 1 + util/ego/descr/em24.descr | 1 + util/ego/descr/em44.descr | 1 + util/ego/descr/i86.descr | 1 + util/ego/descr/m68020.descr | 1 + util/ego/descr/m68k2.descr | 1 + util/ego/descr/m68k4.descr | 1 + util/ego/descr/pdp.descr | 1 + util/ego/descr/sparc.descr | 1 + util/ego/descr/vax4.descr | 2 +- util/ego/sr/Makefile | 2 +- util/ego/sr/sr.c | 4 +++- util/ego/sr/sr.h | 8 +++----- util/ego/sr/sr_reduce.c | 16 +--------------- 15 files changed, 19 insertions(+), 24 deletions(-) diff --git a/util/ego/descr/Makefile b/util/ego/descr/Makefile index 05a03647b..3b7304989 100644 --- a/util/ego/descr/Makefile +++ b/util/ego/descr/Makefile @@ -4,7 +4,7 @@ EMLIB=$(EMHOME)/lib SHARE=../share CPP=$(EMLIB)/cpp -LDFLAGS=-i +LDFLAGS= CPPFLAGS=-DVERBOSE -DNOTCOMPACT CFLAGS=$(CPPFLAGS) -O LINTFLAGS=-hbu diff --git a/util/ego/descr/em22.descr b/util/ego/descr/em22.descr index ca542cc92..393420d42 100644 --- a/util/ego/descr/em22.descr +++ b/util/ego/descr/em22.descr @@ -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: diff --git a/util/ego/descr/em24.descr b/util/ego/descr/em24.descr index dceee1824..c218483b0 100644 --- a/util/ego/descr/em24.descr +++ b/util/ego/descr/em24.descr @@ -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: diff --git a/util/ego/descr/em44.descr b/util/ego/descr/em44.descr index 5989b70e4..e2174169b 100644 --- a/util/ego/descr/em44.descr +++ b/util/ego/descr/em44.descr @@ -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: diff --git a/util/ego/descr/i86.descr b/util/ego/descr/i86.descr index 1d2217e72..2b09ef64d 100644 --- a/util/ego/descr/i86.descr +++ b/util/ego/descr/i86.descr @@ -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: diff --git a/util/ego/descr/m68020.descr b/util/ego/descr/m68020.descr index 8b90a2e0b..cabf2f578 100644 --- a/util/ego/descr/m68020.descr +++ b/util/ego/descr/m68020.descr @@ -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: diff --git a/util/ego/descr/m68k2.descr b/util/ego/descr/m68k2.descr index 9f525d46a..8a60debd7 100644 --- a/util/ego/descr/m68k2.descr +++ b/util/ego/descr/m68k2.descr @@ -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: diff --git a/util/ego/descr/m68k4.descr b/util/ego/descr/m68k4.descr index dedf1d24d..8a0b4b4cd 100644 --- a/util/ego/descr/m68k4.descr +++ b/util/ego/descr/m68k4.descr @@ -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: diff --git a/util/ego/descr/pdp.descr b/util/ego/descr/pdp.descr index dbdbb0281..c2a5f8e84 100644 --- a/util/ego/descr/pdp.descr +++ b/util/ego/descr/pdp.descr @@ -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: diff --git a/util/ego/descr/sparc.descr b/util/ego/descr/sparc.descr index 476ab3b1e..938532463 100644 --- a/util/ego/descr/sparc.descr +++ b/util/ego/descr/sparc.descr @@ -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: diff --git a/util/ego/descr/vax4.descr b/util/ego/descr/vax4.descr index 389d94e15..8a5f948e1 100644 --- a/util/ego/descr/vax4.descr +++ b/util/ego/descr/vax4.descr @@ -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: diff --git a/util/ego/sr/Makefile b/util/ego/sr/Makefile index 857de6927..65a5b6563 100644 --- a/util/ego/sr/Makefile +++ b/util/ego/sr/Makefile @@ -4,7 +4,7 @@ EMH=$(EMHOME)/h EMLIB=$(EMHOME)/lib SHR=../share -LDFLAGS=-i +LDFLAGS= CPPFLAGS=-DVERBOSE -DNOTCOMPACT CFLAGS=$(CPPFLAGS) -O LINTFLAGS=-hbu diff --git a/util/ego/sr/sr.c b/util/ego/sr/sr.c index 6bf880cec..5db01e3b0 100644 --- a/util/ego/sr/sr.c +++ b/util/ego/sr/sr.c @@ -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) diff --git a/util/ego/sr/sr.h b/util/ego/sr/sr.h index 623ad6e03..466b71042 100644 --- a/util/ego/sr/sr.h +++ b/util/ego/sr/sr.h @@ -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 */ diff --git a/util/ego/sr/sr_reduce.c b/util/ego/sr/sr_reduce.c index eb401e024..1b69d1219 100644 --- a/util/ego/sr/sr_reduce.c +++ b/util/ego/sr/sr_reduce.c @@ -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); -- 2.34.1