Fix: illegal optimizations of muls
This commit is contained in:
parent
3ad14daa2e
commit
ca659ea85a
@ -145,6 +145,9 @@ move.l A, B : bra LAB : labdef L1 : move.l A, B : labdef LAB
|
||||
labdef LAB ;
|
||||
/* some strength reduction */
|
||||
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
|
||||
{is_shift_twice(NUM,X,Y)} -> asl.l #X,DREG :
|
||||
move.l DREG,-(sp) :
|
||||
@ -179,6 +182,38 @@ int no_side_effects(s)
|
||||
/* 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)
|
||||
char *s, *c1, *c2;
|
||||
@ -196,6 +231,7 @@ int is_shift_twice(s, c1, c2)
|
||||
pow <<= 1;
|
||||
i++;
|
||||
}
|
||||
if (i > 8) return 0;
|
||||
if (pow > 0 && val) {
|
||||
i = 0;
|
||||
while (i <= 8) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user