diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-04-28 22:53:50 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-04-28 22:53:50 +0200 |
commit | 391198888a71649067d10862db1f1afed2b69c90 (patch) | |
tree | 15e2ce3daf5061d819feae8d2d2c78f6fe4181b0 /sys/src/cmd/6c | |
parent | 7b8f4b25be690482793b8bc1be84e8fad4b5492e (diff) |
8c, 6c: fix peephole bug for eleminating CMPL $0,R after shift
the shift instructions does not change the zero flag
when the shift count is 0, so we cannot remove the
compare instruction in this case.
this fixes oggdec under 386.
Diffstat (limited to 'sys/src/cmd/6c')
-rw-r--r-- | sys/src/cmd/6c/peep.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/sys/src/cmd/6c/peep.c b/sys/src/cmd/6c/peep.c index b04b85a25..351dc887d 100644 --- a/sys/src/cmd/6c/peep.c +++ b/sys/src/cmd/6c/peep.c @@ -210,6 +210,13 @@ loop1: break; p1 = r1->prog; switch(p1->as){ + case ASHLQ: + case ASHRQ: + case ASALQ: + case ASARQ: + /* shift doesnt affect ZF when shift count is zero */ + if(p1->from.type != D_CONST || p1->from.offset == 0) + break; case AANDQ: case AORQ: case AXORQ: @@ -218,10 +225,6 @@ loop1: case AADCQ: case ASUBQ: case ASBBQ: - case ASHLQ: - case ASHRQ: - case ASALQ: - case ASARQ: case AINCQ: case ADECQ: if(p->as != ACMPQ) @@ -234,12 +237,17 @@ loop1: case AADCL: case ASUBL: case ASBBL: + case AINCL: + case ADECL: + excise(r); + break; case ASHLL: case ASHRL: case ASALL: case ASARL: - case AINCL: - case ADECL: + /* shift doesnt affect ZF when shift count is zero */ + if(p1->from.type != D_CONST || p1->from.offset == 0) + break; excise(r); } break; |