I had trouble with the 30 Jan 2010 and earlier versions of the PIC sdcc 
compiler on the following code for the PIC4620:

oid RateRPG() {
  char W_temp;
       W_temp = PORTD;                 // Copy PORTD into W_temp
        TEMP = W_temp;                  // and TEMP
        W_temp = W_temp ^ OLDPORTD;     // Any change?
        W_temp = W_temp & 0b00000011;   // If not, W_temp = 0
        if (W_temp != 0){                // If the two bits have changed 
then...
         W_temp = OLDPORTD>>1;         // Form what a CCW change would 
produce
    ...
       }
}

The compiler issued a:
    BANKSEL    (null)
which of course failed to compile. It also did not allocate W_temp, or 
issue the code for:

        W_temp = W_temp ^ OLDPORTD;     // Any change?
        W_temp = W_temp & 0b00000011;   // If not, W_temp = 0

Interestingly, the code compiles correctly if W_temp is a global variable.
Some investigation revealed in ralloc.c at line 4148:

    /* if the condition of an if instruction
       is defined in the previous instruction then
       mark the itemp as a conditional */
    if ((IS_CONDITIONAL (ic) ||
         ((ic->op == BITWISEAND ||
           ic->op == '|' ||
           ic->op == '^') &&
          isBitwiseOptimizable (ic))) &&
        ic->next && ic->next->op == IFX &&
        isOperandEqual (IC_RESULT (ic), IC_COND (ic->next)) &&
        OP_SYMBOL (IC_RESULT (ic))->liveTo <= ic->next->seq)
      {

        debugLog ("  %d\n", __LINE__);
        OP_SYMBOL (IC_RESULT (ic))->regType = REG_CND;
        continue;
      }

Clearly the code is not expecting a tree at this point, only a variable.
Commenting this optimization out fixed the problem at the cost of 
slightly less efficient conditional code as in:
    ANDWF    r0x00, F    ;key=00b, flow seq=060
    .line    480; p3.c    if (W_temp != 0){                // If the two 
bits have changed then...
    MOVF    r0x00, W    ;key=00c, flow seq=060
    BZ    _00189_DS_    ;key=00d, flow seq=060

How do I get this patch into the sourceforge version of sdcc?

Thank you,

Paul Neelands



------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to