Fixed problem with repl_mul(); it was called far too often
authorceriel <none@none>
Fri, 24 Apr 1992 12:39:58 +0000 (12:39 +0000)
committerceriel <none@none>
Fri, 24 Apr 1992 12:39:58 +0000 (12:39 +0000)
util/opt/patterns
util/opt/peephole.c

index 46bd1f4..4955fed 100644 (file)
@@ -32,6 +32,7 @@ adp sti $1!=0 && $2==w: stf $1
 adp sti $1!=0 && $2==2*w:       sdf $1
 asp $1==0:
 asp asp :       asp $1+$2
+dup asp $1<=$2:        asp $2-$1
 blm $1==0 : asp 2*p
 cmi zeq $1==w:  beq $2
 cmi zge $1==w:  bge $2
index 4c07bd2..d7513de 100644 (file)
@@ -655,9 +655,17 @@ basicblock(alpp) line_p *alpp; {
                lpp = next;
        }
        lpp = alpp;
-       if (repl_muls) while ((*lpp) != (line_p) 0) {
+       if (repl_muls) {
+           while ((lp = *lpp) != (line_p) 0 && (lp->l_instr&BMASK) != op_lab) {
                line_p b_repl, e_repl;
-               int cnt = repl_mul(*lpp, &b_repl, &e_repl);
+               int cnt;
+               
+               if ((cnt = (lp->l_instr & BMASK)) != op_loc && cnt != op_ldc) {
+                       lpp = &lp->l_next;
+                       continue;
+               }
+
+               cnt = repl_mul(lp, &b_repl, &e_repl);
 
                lp = *lpp;
                if (cnt > 0 && cnt <= repl_muls) {
@@ -677,6 +685,7 @@ basicblock(alpp) line_p *alpp; {
                        }
                        lpp = &lp->l_next;
                }
+           }
        }
        return madeopt;
 }
@@ -698,9 +707,6 @@ repl_mul(lp, b, e)
        if ((ins = (next->l_instr & BMASK)) != op_mli && ins != op_mlu) {
                return 0;
        }
-       if ((ins = (lp->l_instr & BMASK)) != op_loc && ins != op_ldc) {
-               return 0;
-       }
        switch(next->l_optyp) {
        case OPNO:
                return 0;