Fix: illegal optimizations of muls
This commit is contained in:
parent
114048df57
commit
5929f3dd0e
1 changed files with 36 additions and 0 deletions
|
@ -145,6 +145,9 @@ move.l A, B : bra LAB : labdef L1 : move.l A, B : labdef LAB
|
||||||
labdef LAB ;
|
labdef LAB ;
|
||||||
/* some strength reduction */
|
/* some strength reduction */
|
||||||
mulu.l #NUM,DREG -> muls.l #NUM,DREG ;
|
mulu.l #NUM,DREG -> muls.l #NUM,DREG ;
|
||||||
|
muls.l #NUM,DREG
|
||||||
|
{isshift_once(NUM,X,Y)} -> asl.l #X,DREG :
|
||||||
|
asl.l #Y,DREG ;
|
||||||
muls.l #NUM,DREG
|
muls.l #NUM,DREG
|
||||||
{is_shift_twice(NUM,X,Y)} -> asl.l #X,DREG :
|
{is_shift_twice(NUM,X,Y)} -> asl.l #X,DREG :
|
||||||
move.l DREG,-(sp) :
|
move.l DREG,-(sp) :
|
||||||
|
@ -179,6 +182,38 @@ int no_side_effects(s)
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int isshift_once(s, c1, c2)
|
||||||
|
char *s, *c1, *c2;
|
||||||
|
{
|
||||||
|
long atol();
|
||||||
|
register int i = 0;
|
||||||
|
long val = atol(s), pow = 1;
|
||||||
|
|
||||||
|
while (i <= 8) {
|
||||||
|
if (pow & val) {
|
||||||
|
val -= pow;
|
||||||
|
sprintf(c1, "%d", i);
|
||||||
|
strcpy(c2, "0");
|
||||||
|
if (val == 0) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
pow <<= 1;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
i = 0;
|
||||||
|
strcpy(c1, "8");
|
||||||
|
while (i <= 8) {
|
||||||
|
if (pow & val) {
|
||||||
|
val -= pow;
|
||||||
|
sprintf(c2, "%d", i);
|
||||||
|
if (val == 0) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
pow <<= 1;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int is_shift_twice(s, c1, c2)
|
int is_shift_twice(s, c1, c2)
|
||||||
char *s, *c1, *c2;
|
char *s, *c1, *c2;
|
||||||
|
@ -196,6 +231,7 @@ int is_shift_twice(s, c1, c2)
|
||||||
pow <<= 1;
|
pow <<= 1;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
if (i > 8) return 0;
|
||||||
if (pow > 0 && val) {
|
if (pow > 0 && val) {
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i <= 8) {
|
while (i <= 8) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue