Menu

#2415 Invalid peephole optimization in pic14

closed-fixed
None
PIC14
5
2015-09-03
2015-09-02
No

In sdcc/src/pic14/peeph.def:

replace restart {
        comf    %1,w
        movwf   %1
} by {
        ;     peep 12 - Removed redundant move
        comf    %1,f
}

Original code also sets W to the result of comf. Replacement doesn't.

Code to reproduce:

#include <pic16f887.h>
#include <stdint.h>

void main(void)
{
  uint8_t j = 0;
  while (1)
  {
    j = ~j;
    RD6 = j & 1;
  }
}

For buggy result:

sdcc -mpic14 -p16f887 --use-non-free test.c

For bug-free result:

sdcc -mpic14 -p16f887 --no-peep --use-non-free test.c

Also changing j to volatile works around the issue.

sdcc -v:

SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.5.4 #9304 (MINGW32)

Discussion

  • Ben Shi

    Ben Shi - 2015-09-02
    • Category: other --> PIC14
     
  • Philipp Klaus Krause

    Fixed in revision #9307.

    Philipp

     
  • Philipp Klaus Krause

    • status: open --> closed-fixed
    • assigned_to: Philipp Klaus Krause
     

Log in to post a comment.

MongoDB Logo MongoDB