1
0
mirror of https://github.com/golang/go synced 2024-11-17 06:04:47 -07:00

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
This commit is contained in:
Russ Cox 2013-09-06 16:49:11 -04:00
parent 08925ce6ee
commit af2a3193af
3 changed files with 11 additions and 3 deletions

View 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;
}
}
}

View 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;
}
}
}

View 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;
}
}
}