Commit af2a3193 authored by Russ Cox's avatar Russ Cox

cmd/5g, cmd/6g, cmd/8g: simplify for loop in bitmap generation

Lucio De Re reports that the more complex
loop miscompiles on Plan 9.

R=ken2
CC=golang-dev
https://golang.org/cl/13602043
parent 08925ce6
...@@ -49,7 +49,8 @@ defframe(Prog *ptxt, Bvec *bv) ...@@ -49,7 +49,8 @@ defframe(Prog *ptxt, Bvec *bv)
patch(p, p1); patch(p, p1);
} else { } else {
first = 1; 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(bvget(bv, j) || bvget(bv, j+1)) {
if(first) { if(first) {
p = appendp(p, AMOVW, D_CONST, NREG, 0, D_REG, 0, 0); p = appendp(p, AMOVW, D_CONST, NREG, 0, D_REG, 0, 0);
...@@ -57,6 +58,7 @@ defframe(Prog *ptxt, Bvec *bv) ...@@ -57,6 +58,7 @@ defframe(Prog *ptxt, Bvec *bv)
} }
p = appendp(p, AMOVW, D_REG, 0, 0, D_OREG, REGSP, 4+frame-stkzerosize+i); p = appendp(p, AMOVW, D_REG, 0, 0, D_OREG, REGSP, 4+frame-stkzerosize+i);
} }
j += 2;
} }
} }
} }
......
...@@ -37,9 +37,12 @@ defframe(Prog *ptxt, Bvec *bv) ...@@ -37,9 +37,12 @@ defframe(Prog *ptxt, Bvec *bv)
p = appendp(p, AREP, D_NONE, 0, D_NONE, 0); p = appendp(p, AREP, D_NONE, 0, D_NONE, 0);
appendp(p, ASTOSQ, D_NONE, 0, D_NONE, 0); appendp(p, ASTOSQ, D_NONE, 0, D_NONE, 0);
} else { } 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)) if(bvget(bv, j) || bvget(bv, j+1))
p = appendp(p, AMOVQ, D_CONST, 0, D_SP+D_INDIR, frame-stkzerosize+i); p = appendp(p, AMOVQ, D_CONST, 0, D_SP+D_INDIR, frame-stkzerosize+i);
j += 2;
}
} }
} }
......
...@@ -39,9 +39,12 @@ defframe(Prog *ptxt, Bvec *bv) ...@@ -39,9 +39,12 @@ defframe(Prog *ptxt, Bvec *bv)
p = appendp(p, AREP, D_NONE, 0, D_NONE, 0); p = appendp(p, AREP, D_NONE, 0, D_NONE, 0);
appendp(p, ASTOSL, D_NONE, 0, D_NONE, 0); appendp(p, ASTOSL, D_NONE, 0, D_NONE, 0);
} else { } 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)) if(bvget(bv, j) || bvget(bv, j+1))
p = appendp(p, AMOVL, D_CONST, 0, D_SP+D_INDIR, frame-stkzerosize+i); p = appendp(p, AMOVL, D_CONST, 0, D_SP+D_INDIR, frame-stkzerosize+i);
j += 2;
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment