summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2014-04-28 22:53:50 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2014-04-28 22:53:50 +0200
commit391198888a71649067d10862db1f1afed2b69c90 (patch)
tree15e2ce3daf5061d819feae8d2d2c78f6fe4181b0 /sys
parent7b8f4b25be690482793b8bc1be84e8fad4b5492e (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')
-rw-r--r--sys/src/cmd/6c/peep.c20
-rw-r--r--sys/src/cmd/8c/peep.c11
2 files changed, 21 insertions, 10 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;
diff --git a/sys/src/cmd/8c/peep.c b/sys/src/cmd/8c/peep.c
index b0f639dd7..06f668c56 100644
--- a/sys/src/cmd/8c/peep.c
+++ b/sys/src/cmd/8c/peep.c
@@ -150,6 +150,13 @@ loop1:
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 @@ loop1:
case AADCL:
case ASUBL:
case ASBBL:
- case ASHLL:
- case ASHRL:
- case ASALL:
- case ASARL:
case AINCL:
case ADECL:
excise(r);