]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/5g, cmd/6g, cmd/8g: simplify for loop in bitmap generation
authorRuss Cox <rsc@golang.org>
Fri, 6 Sep 2013 20:49:11 +0000 (16:49 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 6 Sep 2013 20:49:11 +0000 (16:49 -0400)
Lucio De Re reports that the more complex
loop miscompiles on Plan 9.

R=ken2
CC=golang-dev
https://golang.org/cl/13602043

src/cmd/5g/ggen.c
src/cmd/6g/ggen.c
src/cmd/8g/ggen.c

index f018c88aa87b4b3dfc9b38dcc8ebe5a88a851222..9065a8dd37a1acb2fcf7bb8e5ad9519bf93d96d8 100644 (file)
@@ -49,7 +49,8 @@ defframe(Prog *ptxt, Bvec *bv)
                patch(p, p1);
        } else {
                first = 1;
-               for(i=0, j=(stkptrsize-stkzerosize)/widthptr*2; i<stkzerosize; i+=widthptr, j+=2) {
+               j = (stkptrsize - stkzerosize)/widthptr * 2;
+               for(i=0; i<stkzerosize; i+=widthptr) {
                        if(bvget(bv, j) || bvget(bv, j+1)) {
                                if(first) {
                                        p = appendp(p, AMOVW, D_CONST, NREG, 0, D_REG, 0, 0);
@@ -57,6 +58,7 @@ defframe(Prog *ptxt, Bvec *bv)
                                }
                                p = appendp(p, AMOVW, D_REG, 0, 0, D_OREG, REGSP, 4+frame-stkzerosize+i);
                        }
+                       j += 2;
                }
        }
 }
index 6e2f0fd69ebab05e50c4be96e7667798d4966ac2..1e1790e1221eff65142e12840ccdae47377f0152 100644 (file)
@@ -37,9 +37,12 @@ defframe(Prog *ptxt, Bvec *bv)
                p = appendp(p, AREP, D_NONE, 0, D_NONE, 0);
                appendp(p, ASTOSQ, D_NONE, 0, D_NONE, 0);
        } else {
-               for(i=0, j=(stkptrsize-stkzerosize)/widthptr*2; i<stkzerosize; i+=widthptr, j+=2)
+               j = (stkptrsize - stkzerosize)/widthptr * 2;
+               for(i=0; i<stkzerosize; i+=widthptr) {
                        if(bvget(bv, j) || bvget(bv, j+1))
                                p = appendp(p, AMOVQ, D_CONST, 0, D_SP+D_INDIR, frame-stkzerosize+i);
+                       j += 2;
+               }
        }
 }
 
index 1f9e6e0593e435f2fd7ded79250822778ec454d0..9f2758c91ee1fce201bc47819e83743dd0df6d2c 100644 (file)
@@ -39,9 +39,12 @@ defframe(Prog *ptxt, Bvec *bv)
                p = appendp(p, AREP, D_NONE, 0, D_NONE, 0);
                appendp(p, ASTOSL, D_NONE, 0, D_NONE, 0);
        } else {
-               for(i=0, j=(stkptrsize-stkzerosize)/widthptr*2; i<stkzerosize; i+=widthptr, j+=2)
+               j = (stkptrsize - stkzerosize)/widthptr * 2;
+               for(i=0; i<stkzerosize; i+=widthptr) {
                        if(bvget(bv, j) || bvget(bv, j+1))
                                p = appendp(p, AMOVL, D_CONST, 0, D_SP+D_INDIR, frame-stkzerosize+i);
+                       j += 2;
+               }
        }
 }