ref: 2d071d5dee7846207cc3b25d6eb007db00831e7f
parent: e12df5a36fa72ec9f3ecb217aae95d978e9a9ce5
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Apr 28 18:53:50 EDT 2014
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.
--- a/sys/src/cmd/6c/peep.c
+++ b/sys/src/cmd/6c/peep.c
@@ -210,6 +210,13 @@
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 @@
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 @@
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;
--- a/sys/src/cmd/8c/peep.c
+++ b/sys/src/cmd/8c/peep.c
@@ -150,6 +150,13 @@
break;
p1 = r1->prog;
switch(p1->as){+ case ASALL:
+ case ASARL:
+ case ASHLL:
+ case ASHRL:
+ /* shift doesnt affect ZF when shift count is zero */
+ if(p1->from.type != D_CONST || p1->from.offset == 0)
+ break;
case AANDL:
case AORL:
case AXORL:
@@ -158,10 +165,6 @@
case AADCL:
case ASUBL:
case ASBBL:
- case ASHLL:
- case ASHRL:
- case ASALL:
- case ASARL:
case AINCL:
case ADECL:
excise(r);
--
⑨