Fix: illegal optimizations of muls
authorceriel <none@none>
Tue, 30 Jan 1990 13:41:36 +0000 (13:41 +0000)
committerceriel <none@none>
Tue, 30 Jan 1990 13:41:36 +0000 (13:41 +0000)
mach/m68020/top/table

index 3b3b9d2..d806885 100644 (file)
@@ -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) {