SDCC 2.7.4 generating redundant code?

wasiliy
2007-11-23
2013-03-12
  • wasiliy

    wasiliy - 2007-11-23

    Following output in the asm File:

    ;     ledtest.c:85: RFPWR &= ~RREG_RADIO_PD;
         mov     dptr,#_RFPWR
         movx     a,@dptr
         mov     r2,a
         anl     a,#0xF7
         movx     @dptr,a
    ;     ledtest.c:86: while((RFPWR & ADI_RADIO_PD) == 1);
    00101$:
         mov     dptr,#_RFPWR
         movx     a,@dptr
         mov     r2,a
         anl     ar2,#0x16
         cjne     r2,#0x01,00124$
         sjmp     00101$

    Where RFPWR is:
    xdata at 0xDF17 uint8_t RFPWR;
    and
    #define RREG_RADIO_PD 0x08
    #define ADI_RADIO_PD 0x16

    So my question is why the "mov r2,a" is generated in the first section, although r2 isn't used there at all and doesn't have to do with the use of r2 in the next section?

     
    • Maarten Brock

      Maarten Brock - 2007-11-24

      If you recompile the source with --fverbose-asm you can see the peephole rules that were applied to get to this asm. If you then recompile also with --no-peep you can see the original asm. You'll find out that writing to r2 is a left-over after the peephole optimization but it is difficult to determine for sure that it can be left out.

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks