Added SLI reduce
This commit is contained in:
parent
e0be1dfe3a
commit
79cb35ec4f
|
@ -4,7 +4,7 @@ EMLIB=$(EMHOME)/lib
|
||||||
SHARE=../share
|
SHARE=../share
|
||||||
CPP=$(EMLIB)/cpp
|
CPP=$(EMLIB)/cpp
|
||||||
|
|
||||||
LDFLAGS=-i
|
LDFLAGS=
|
||||||
CPPFLAGS=-DVERBOSE -DNOTCOMPACT
|
CPPFLAGS=-DVERBOSE -DNOTCOMPACT
|
||||||
CFLAGS=$(CPPFLAGS) -O
|
CFLAGS=$(CPPFLAGS) -O
|
||||||
LINTFLAGS=-hbu
|
LINTFLAGS=-hbu
|
||||||
|
|
|
@ -68,6 +68,7 @@ access costs of local variables:
|
||||||
%%SR
|
%%SR
|
||||||
overflow harmful?: yes
|
overflow harmful?: yes
|
||||||
array bound harmful?: yes
|
array bound harmful?: yes
|
||||||
|
reduce sli if shift count larger than: 0
|
||||||
%%CS
|
%%CS
|
||||||
#include "../../../h/em_mnem.h"
|
#include "../../../h/em_mnem.h"
|
||||||
first time then space:
|
first time then space:
|
||||||
|
|
|
@ -68,6 +68,7 @@ access costs of local variables:
|
||||||
%%SR
|
%%SR
|
||||||
overflow harmful?: yes
|
overflow harmful?: yes
|
||||||
array bound harmful?: yes
|
array bound harmful?: yes
|
||||||
|
reduce sli if shift count larger than: 0
|
||||||
%%CS
|
%%CS
|
||||||
#include "../../../h/em_mnem.h"
|
#include "../../../h/em_mnem.h"
|
||||||
first time then space:
|
first time then space:
|
||||||
|
|
|
@ -68,6 +68,7 @@ access costs of local variables:
|
||||||
%%SR
|
%%SR
|
||||||
overflow harmful?: yes
|
overflow harmful?: yes
|
||||||
array bound harmful?: yes
|
array bound harmful?: yes
|
||||||
|
reduce sli if shift count larger than: 0
|
||||||
%%CS
|
%%CS
|
||||||
#include "../../../h/em_mnem.h"
|
#include "../../../h/em_mnem.h"
|
||||||
first time then space:
|
first time then space:
|
||||||
|
|
|
@ -83,6 +83,7 @@ access costs of local variables:
|
||||||
%%SR
|
%%SR
|
||||||
overflow harmful?: no
|
overflow harmful?: no
|
||||||
array bound harmful?: no
|
array bound harmful?: no
|
||||||
|
reduce sli if shift count larger than: 0
|
||||||
%%CS
|
%%CS
|
||||||
#include "../../../h/em_mnem.h"
|
#include "../../../h/em_mnem.h"
|
||||||
first time then space:
|
first time then space:
|
||||||
|
|
|
@ -92,6 +92,7 @@ access costs of local variables:
|
||||||
%%SR
|
%%SR
|
||||||
overflow harmful?: no
|
overflow harmful?: no
|
||||||
array bound harmful?: no
|
array bound harmful?: no
|
||||||
|
reduce sli if shift count larger than: 3
|
||||||
%%CS
|
%%CS
|
||||||
#include "../../../h/em_mnem.h"
|
#include "../../../h/em_mnem.h"
|
||||||
first time then space:
|
first time then space:
|
||||||
|
|
|
@ -90,6 +90,7 @@ access costs of local variables:
|
||||||
%%SR
|
%%SR
|
||||||
overflow harmful?: no
|
overflow harmful?: no
|
||||||
array bound harmful?: no
|
array bound harmful?: no
|
||||||
|
reduce sli if shift count larger than: 0
|
||||||
%%CS
|
%%CS
|
||||||
#include "../../../h/em_mnem.h"
|
#include "../../../h/em_mnem.h"
|
||||||
first time then space:
|
first time then space:
|
||||||
|
|
|
@ -92,6 +92,7 @@ access costs of local variables:
|
||||||
%%SR
|
%%SR
|
||||||
overflow harmful?: no
|
overflow harmful?: no
|
||||||
array bound harmful?: no
|
array bound harmful?: no
|
||||||
|
reduce sli if shift count larger than: 0
|
||||||
%%CS
|
%%CS
|
||||||
#include "../../../h/em_mnem.h"
|
#include "../../../h/em_mnem.h"
|
||||||
first time then space:
|
first time then space:
|
||||||
|
|
|
@ -82,6 +82,7 @@ access costs of local variables:
|
||||||
%%SR
|
%%SR
|
||||||
overflow harmful?: no
|
overflow harmful?: no
|
||||||
array bound harmful?: no
|
array bound harmful?: no
|
||||||
|
reduce sli if shift count larger than: 0
|
||||||
%%CS
|
%%CS
|
||||||
#include "../../../h/em_mnem.h"
|
#include "../../../h/em_mnem.h"
|
||||||
first time then space:
|
first time then space:
|
||||||
|
|
|
@ -87,6 +87,7 @@ access costs of local variables:
|
||||||
%%SR
|
%%SR
|
||||||
overflow harmful?: no
|
overflow harmful?: no
|
||||||
array bound harmful?: yes
|
array bound harmful?: yes
|
||||||
|
reduce sli if shift count larger than: 0
|
||||||
%%CS
|
%%CS
|
||||||
#include "../../../h/em_mnem.h"
|
#include "../../../h/em_mnem.h"
|
||||||
first time then space:
|
first time then space:
|
||||||
|
|
|
@ -101,7 +101,7 @@ access costs of local variables:
|
||||||
%%SR
|
%%SR
|
||||||
overflow harmful?: no
|
overflow harmful?: no
|
||||||
array bound harmful?: no
|
array bound harmful?: no
|
||||||
|
reduce sli if shift count larger than: 3
|
||||||
%%CS
|
%%CS
|
||||||
#include "../../../h/em_mnem.h"
|
#include "../../../h/em_mnem.h"
|
||||||
first time then space:
|
first time then space:
|
||||||
|
|
|
@ -4,7 +4,7 @@ EMH=$(EMHOME)/h
|
||||||
EMLIB=$(EMHOME)/lib
|
EMLIB=$(EMHOME)/lib
|
||||||
SHR=../share
|
SHR=../share
|
||||||
|
|
||||||
LDFLAGS=-i
|
LDFLAGS=
|
||||||
CPPFLAGS=-DVERBOSE -DNOTCOMPACT
|
CPPFLAGS=-DVERBOSE -DNOTCOMPACT
|
||||||
CFLAGS=$(CPPFLAGS) -O
|
CFLAGS=$(CPPFLAGS) -O
|
||||||
LINTFLAGS=-hbu
|
LINTFLAGS=-hbu
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
/* Strength reduction tries to change expensive operators occurring
|
/* Strength reduction tries to change expensive operators occurring
|
||||||
* in a loop into cheaper operators. The expensive operators considered
|
* 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:
|
* The transformations can be expressed in C as:
|
||||||
*
|
*
|
||||||
* [1]: for (i = e1; i <= e2; i++)
|
* [1]: for (i = e1; i <= e2; i++)
|
||||||
|
@ -46,6 +46,7 @@
|
||||||
|
|
||||||
int ovfl_harmful;
|
int ovfl_harmful;
|
||||||
int arrbound_harmful;
|
int arrbound_harmful;
|
||||||
|
int sli_threshold;
|
||||||
|
|
||||||
int Ssr; /* #optimizations found */
|
int Ssr; /* #optimizations found */
|
||||||
|
|
||||||
|
@ -63,6 +64,7 @@ sr_machinit(f)
|
||||||
}
|
}
|
||||||
fscanf(f,"%d",&ovfl_harmful);
|
fscanf(f,"%d",&ovfl_harmful);
|
||||||
fscanf(f,"%d",&arrbound_harmful);
|
fscanf(f,"%d",&arrbound_harmful);
|
||||||
|
fscanf(f,"%d",&sli_threshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC del_ivs(ivs)
|
STATIC del_ivs(ivs)
|
||||||
|
|
|
@ -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 iv *iv_p;
|
||||||
typedef struct code_info *code_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
|
extern int arrbound_harmful; /* Is it harmful to take the address of
|
||||||
* a non-existing array element ?
|
* a non-existing array element ?
|
||||||
*/
|
*/
|
||||||
|
extern int sli_threshold; /* Try to optimize SLI if shift-count larger than
|
||||||
|
* this
|
||||||
|
*/
|
||||||
extern int Ssr; /* #optimizations found */
|
extern int Ssr; /* #optimizations found */
|
||||||
|
|
||||||
/* core allocation macros */
|
/* core allocation macros */
|
||||||
|
|
|
@ -45,10 +45,8 @@ STATIC int regtyp(code)
|
||||||
switch(code->co_instr) {
|
switch(code->co_instr) {
|
||||||
case op_mli:
|
case op_mli:
|
||||||
case op_mlu:
|
case op_mlu:
|
||||||
#ifdef SLI_REDUCE
|
|
||||||
case op_sli:
|
case op_sli:
|
||||||
case op_slu:
|
case op_slu:
|
||||||
#endif
|
|
||||||
return reg_any;
|
return reg_any;
|
||||||
default:
|
default:
|
||||||
return reg_pointer;
|
return reg_pointer;
|
||||||
|
@ -92,10 +90,8 @@ STATIC line_p newcode(code,tmp)
|
||||||
switch(code->co_instr) {
|
switch(code->co_instr) {
|
||||||
case op_mli:
|
case op_mli:
|
||||||
case op_mlu:
|
case op_mlu:
|
||||||
#ifdef SLI_REDUCE
|
|
||||||
case op_sli:
|
case op_sli:
|
||||||
case op_slu:
|
case op_slu:
|
||||||
#endif
|
|
||||||
/* new code is just a LOL tmp */
|
/* new code is just a LOL tmp */
|
||||||
l = int_line(tmp);
|
l = int_line(tmp);
|
||||||
l->l_instr = op_lol;
|
l->l_instr = op_lol;
|
||||||
|
@ -201,7 +197,6 @@ STATIC init_code(code,tmp)
|
||||||
l->l_next = int_line(tmp);
|
l->l_next = int_line(tmp);
|
||||||
l->l_next->l_instr = op_stl;
|
l->l_next->l_instr = op_stl;
|
||||||
break;
|
break;
|
||||||
#ifdef SLI_REDUCE
|
|
||||||
case op_sli:
|
case op_sli:
|
||||||
case op_slu:
|
case op_slu:
|
||||||
/* reduced code is: iv_expr << lc
|
/* reduced code is: iv_expr << lc
|
||||||
|
@ -211,7 +206,6 @@ STATIC init_code(code,tmp)
|
||||||
l->l_next = int_line(tmp);
|
l->l_next = int_line(tmp);
|
||||||
l->l_next->l_instr = op_stl;
|
l->l_next->l_instr = op_stl;
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
case op_lar:
|
case op_lar:
|
||||||
case op_sar:
|
case op_sar:
|
||||||
/* reduced code is: ...= A[iv_expr] resp.
|
/* reduced code is: ...= A[iv_expr] resp.
|
||||||
|
@ -283,7 +277,6 @@ STATIC incr_code(code,tmp)
|
||||||
store_tmp = int_line(tmp);
|
store_tmp = int_line(tmp);
|
||||||
store_tmp->l_instr = op_stl;
|
store_tmp->l_instr = op_stl;
|
||||||
break;
|
break;
|
||||||
#ifdef SLI_REDUCE
|
|
||||||
case op_sli:
|
case op_sli:
|
||||||
case op_slu:
|
case op_slu:
|
||||||
loc = int_line(
|
loc = int_line(
|
||||||
|
@ -297,7 +290,6 @@ STATIC incr_code(code,tmp)
|
||||||
store_tmp = int_line(tmp);
|
store_tmp = int_line(tmp);
|
||||||
store_tmp->l_instr = op_stl;
|
store_tmp->l_instr = op_stl;
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
case op_lar:
|
case op_lar:
|
||||||
case op_sar:
|
case op_sar:
|
||||||
case op_aar:
|
case op_aar:
|
||||||
|
@ -416,10 +408,8 @@ STATIC bool same_code(c1,c2,vars)
|
||||||
switch(c1->co_instr) {
|
switch(c1->co_instr) {
|
||||||
case op_mli:
|
case op_mli:
|
||||||
case op_mlu:
|
case op_mlu:
|
||||||
#ifdef SLI_REDUCE
|
|
||||||
case op_sli:
|
case op_sli:
|
||||||
case op_slu:
|
case op_slu:
|
||||||
#endif
|
|
||||||
return c1->co_instr == c2->co_instr &&
|
return c1->co_instr == c2->co_instr &&
|
||||||
off_set(c1->c_o.co_loadlc) ==
|
off_set(c1->c_o.co_loadlc) ==
|
||||||
off_set(c2->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)
|
STATIC try_leftshift(lp,ivs,vars,b,shft)
|
||||||
loop_p lp;
|
loop_p lp;
|
||||||
lset ivs,vars;
|
lset ivs,vars;
|
||||||
|
@ -642,7 +631,7 @@ STATIC try_leftshift(lp,ivs,vars,b,shft)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
l2 = PREV(shft); /* Instruction before the shift */
|
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))) {
|
(is_ivexpr(PREV(l2),ivs,vars,&lbegin,&iv,&sign))) {
|
||||||
/* recognized "iv << const " */
|
/* recognized "iv << const " */
|
||||||
c = newcinfo();
|
c = newcinfo();
|
||||||
|
@ -668,7 +657,6 @@ STATIC try_leftshift(lp,ivs,vars,b,shft)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
STATIC try_array(lp,ivs,vars,b,arr)
|
STATIC try_array(lp,ivs,vars,b,arr)
|
||||||
loop_p lp;
|
loop_p lp;
|
||||||
lset ivs,vars;
|
lset ivs,vars;
|
||||||
|
@ -760,12 +748,10 @@ strength_reduction(lp,ivs,vars)
|
||||||
next = l->l_next;
|
next = l->l_next;
|
||||||
if (TYPE(l) == OPSHORT && SHORT(l) == ws) {
|
if (TYPE(l) == OPSHORT && SHORT(l) == ws) {
|
||||||
switch(INSTR(l)) {
|
switch(INSTR(l)) {
|
||||||
#ifdef SLI_REDUCE
|
|
||||||
case op_sli:
|
case op_sli:
|
||||||
case op_slu:
|
case op_slu:
|
||||||
try_leftshift(lp,ivs,vars,b,l);
|
try_leftshift(lp,ivs,vars,b,l);
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
case op_mlu:
|
case op_mlu:
|
||||||
case op_mli:
|
case op_mli:
|
||||||
try_multiply(lp,ivs,vars,b,l);
|
try_multiply(lp,ivs,vars,b,l);
|
||||||
|
|
Loading…
Reference in a new issue