Menu

#936 STM8S103F3 - Strange optimization

None
closed-fixed
None
5
2024-07-15
2024-01-28
Andreas7
No

Hello,
I think I found an error in the optimization.
In the example code, the first 5 statements are optimized correctly (bset, bres), but the 6th statement is not (lines 120 - 131).
Why isn't the last statement optimized?

                                112 ;   -----------------------------------------
                                113 ;    function i2c_init
                                114 ;   -----------------------------------------
  00000A                        115 _i2c_init:
                                116 ;   tbasic.c: 51: *(uint8_t *)(SCL_BASE + P_DDR) |= SCL_MASK;           // Set DDR to output
  00000A 72 16 50 11      [ 1]  117     bset    0x5011, #3
                                118 ;   tbasic.c: 52: *(uint8_t *)(SCL_BASE + P_CR1) &= ~SCL_MASK;      // Set CR1 to open-drain
  00000E 72 17 50 12      [ 1]  119     bres    0x5012, #3
                                120 ;   tbasic.c: 53: *(uint8_t *)(SCL_BASE + P_CR2) &= ~SCL_MASK;      // Set CR2 to 2MHz
  000012 72 17 50 13      [ 1]  121     bres    0x5013, #3
                                122 ;   tbasic.c: 54: i2c_set_scl();
  000016 CDr00r00         [ 4]  123     call    _i2c_set_scl
                                124 ;   tbasic.c: 56: *(uint8_t *)(SDA_BASE + P_DDR) |= SDA_MASK;           // Set DDR to output
  000019 72 18 50 11      [ 1]  125     bset    0x5011, #4
                                126 ;   tbasic.c: 57: *(uint8_t *)(SDA_BASE + P_CR1) &= ~SDA_MASK;      // Set CR1 to open-drain
  00001D 72 19 50 12      [ 1]  127     bres    0x5012, #4
                                128 ;   tbasic.c: 58: *(uint8_t *)(SDA_BASE + P_CR2) &= ~SDA_MASK;      // Set CR2 to 2MHz
  000021 C6 50 13         [ 1]  129     ld  a, 0x5013
  000024 A4 EF            [ 1]  130     and a, #0xef
  000026 C7 50 13         [ 1]  131     ld  0x5013, a
                                132 ;   tbasic.c: 59: i2c_set_sda();
                                133 ;   tbasic.c: 60: }
  000029 CCr00r05         [ 2]  134     jp  _i2c_set_sda

SDCC 4.3.0
STM8S103F3
Please see atached files.

3 Attachments

Discussion

  • Andreas7

    Andreas7 - 2024-01-28

    Sorry, I gave the wrong line numbers.
    The lines 129-130 are not optimized.

     
  • Maarten Brock

    Maarten Brock - 2024-01-29

    This happens because ~ upcasts the value to an int.

     
  • Andreas7

    Andreas7 - 2024-01-29

    The same happens if i cast the value to uint8_t:

                                    112 ;   -----------------------------------------
                                    113 ;    function i2c_init
                                    114 ;   -----------------------------------------
      00000A                        115 _i2c_init:
                                    116 ;   tbasic.c: 51: *(uint8_t *)(SCL_BASE + P_DDR) |= SCL_MASK;           // Set DDR to output
      00000A 72 16 50 11      [ 1]  117     bset    0x5011, #3
                                    118 ;   tbasic.c: 52: *(uint8_t *)(SCL_BASE + P_CR1) &= ~SCL_MASK;      // Set CR1 to open-drain
      00000E 72 17 50 12      [ 1]  119     bres    0x5012, #3
                                    120 ;   tbasic.c: 53: *(uint8_t *)(SCL_BASE + P_CR2) &= ~SCL_MASK;      // Set CR2 to 2MHz
      000012 72 17 50 13      [ 1]  121     bres    0x5013, #3
                                    122 ;   tbasic.c: 54: i2c_set_scl();
      000016 CDr00r00         [ 4]  123     call    _i2c_set_scl
                                    124 ;   tbasic.c: 56: *(uint8_t *)(SDA_BASE + P_DDR) |= SDA_MASK;           // Set DDR to output
      000019 72 18 50 11      [ 1]  125     bset    0x5011, #4
                                    126 ;   tbasic.c: 57: *(uint8_t *)(SDA_BASE + P_CR1) &= ~SDA_MASK;      // Set CR1 to open-drain
      00001D 72 19 50 12      [ 1]  127     bres    0x5012, #4
                                    128 ;   tbasic.c: 58: *(uint8_t *)(SDA_BASE + P_CR2) &= ~(uint8_t)SDA_MASK;     // Set CR2 to 2MHz
      000021 C6 50 13         [ 1]  129     ld  a, 0x5013
      000024 A4 EF            [ 1]  130     and a, #0xef
      000026 C7 50 13         [ 1]  131     ld  0x5013, a
                                    132 ;   tbasic.c: 59: i2c_set_sda();
                                    133 ;   tbasic.c: 60: }
      000029 CCr00r05         [ 2]  134     jp  _i2c_set_sda
    
     
  • Maarten Brock

    Maarten Brock - 2024-01-29

    That does not help because your uint_8 casted value gets upcasted to an int for the ~ operator. You need to cast the inverted value down for this to work.

     
  • Andreas7

    Andreas7 - 2024-01-29

    Even this does not work, see the code.
    The lines above are the same, and its optimized.
    What is different with this one line?

                                    112 ;   -----------------------------------------
                                    113 ;    function i2c_init
                                    114 ;   -----------------------------------------
      00000A                        115 _i2c_init:
                                    116 ;   tbasic.c: 51: *(uint8_t *)(SCL_BASE + P_DDR) |= SCL_MASK;           // Set DDR to output
      00000A 72 16 50 11      [ 1]  117     bset    0x5011, #3
                                    118 ;   tbasic.c: 52: *(uint8_t *)(SCL_BASE + P_CR1) &= ~SCL_MASK;      // Set CR1 to open-drain
      00000E 72 17 50 12      [ 1]  119     bres    0x5012, #3
                                    120 ;   tbasic.c: 53: *(uint8_t *)(SCL_BASE + P_CR2) &= ~SCL_MASK;      // Set CR2 to 2MHz
      000012 72 17 50 13      [ 1]  121     bres    0x5013, #3
                                    122 ;   tbasic.c: 54: i2c_set_scl();
      000016 CDr00r00         [ 4]  123     call    _i2c_set_scl
                                    124 ;   tbasic.c: 56: *(uint8_t *)(SDA_BASE + P_DDR) |= SDA_MASK;           // Set DDR to output
      000019 72 18 50 11      [ 1]  125     bset    0x5011, #4
                                    126 ;   tbasic.c: 57: *(uint8_t *)(SDA_BASE + P_CR1) &= ~SDA_MASK;      // Set CR1 to open-drain
      00001D 72 19 50 12      [ 1]  127     bres    0x5012, #4
                                    128 ;   tbasic.c: 58: *(uint8_t *)(SDA_BASE + P_CR2) &= (uint8_t)~SDA_MASK;     // Set CR2 to 2MHz
      000021 C6 50 13         [ 1]  129     ld  a, 0x5013
      000024 A4 EF            [ 1]  130     and a, #0xef
      000026 C7 50 13         [ 1]  131     ld  0x5013, a
                                    132 ;   tbasic.c: 59: i2c_set_sda();
                                    133 ;   tbasic.c: 60: }
      000029 CCr00r05         [ 2]  134     jp  _i2c_set_sda
    
     

    Last edit: Andreas7 2024-01-29
  • Andreas7

    Andreas7 - 2024-01-30

    Hello,
    the optimization is done as soon the call to _i2c_set_sda is removed.
    But i can't see any reason for this behaviour.

                                        112 ;   -----------------------------------------
                                        113 ;    function i2c_init
                                        114 ;   -----------------------------------------
          00000A                        115 _i2c_init:
                                        116 ;   tbasic.c: 51: *(uint8_t *)(SCL_BASE + P_DDR) |= SCL_MASK;           // Set DDR to output
          00000A 72 16 50 11      [ 1]  117     bset    0x5011, #3
                                        118 ;   tbasic.c: 52: *(uint8_t *)(SCL_BASE + P_CR1) &= ~SCL_MASK;      // Set CR1 to open-drain
          00000E 72 17 50 12      [ 1]  119     bres    0x5012, #3
                                        120 ;   tbasic.c: 53: *(uint8_t *)(SCL_BASE + P_CR2) &= ~SCL_MASK;      // Set CR2 to 2MHz
          000012 72 17 50 13      [ 1]  121     bres    0x5013, #3
                                        122 ;   tbasic.c: 56: *(uint8_t *)(SDA_BASE + P_DDR) |= SDA_MASK;           // Set DDR to output
          000016 72 18 50 11      [ 1]  123     bset    0x5011, #4
                                        124 ;   tbasic.c: 57: *(uint8_t *)(SDA_BASE + P_CR1) &= ~SDA_MASK;      // Set CR1 to open-drain
          00001A 72 19 50 12      [ 1]  125     bres    0x5012, #4
                                        126 ;   tbasic.c: 58: *(uint8_t *)(SDA_BASE + P_CR2) &= ~SDA_MASK;      // Set CR2 to 2MHz
          00001E 72 19 50 13      [ 1]  127     bres    0x5013, #4
                                        128 ;   tbasic.c: 60: }
          000022 81               [ 4]  129     ret
    
     
  • Andreas7

    Andreas7 - 2024-01-31

    Hello,
    i investigated this further.
    The same behaviour happens on other places too.
    Please see the two indentical "t >>= 16" instructions in the following code.

        int32_t t;
        t = raw_temp;
        t *= 100;
        t *= 165;
    //  t /= 65535;
        t >>= 16;
        t -= 40 * 100;
        thd->temperature = t;
    
        // Calculate temperature value
        uint16_t raw_hum = data[3];
        raw_hum <<= 8;
        raw_hum |= data[4];
    
        crc = htu31d_crc(raw_hum);
        // Serial.print("CRC: 0x"); Serial.println(crc, HEX);
        if (crc != data[5])
        {
            sprintf(buffer, "H crc 0x%02X 0x%02X\r\n", crc, data[5]);
            uart_putstring(buffer);
            return 0;
        }
    
        t = raw_hum;
        t *= 100;
        t *= 100;
    //  t /= 65535;
        t >>= 16;
        thd->humidity = t;
        return 1;
    

    The first instruction produces this code:

                                       1386 ;   tbasic.c: 734: t >>= 16;
          000635 17 0B            [ 2] 1387     ldw (0x0b, sp), y
          000637 17 01            [ 2] 1388     ldw (0x01, sp), y
          000639 1E 0D            [ 2] 1389     ldw x, (0x0d, sp)
          00063B 07 01            [ 1] 1390     sra (0x01, sp)
          00063D 06 02            [ 1] 1391     rrc (0x02, sp)
          00063F 56               [ 2] 1392     rrcw    x
          000640 07 01            [ 1] 1393     sra (0x01, sp)
          000642 06 02            [ 1] 1394     rrc (0x02, sp)
          000644 56               [ 2] 1395     rrcw    x
          000645 07 01            [ 1] 1396     sra (0x01, sp)
          000647 06 02            [ 1] 1397     rrc (0x02, sp)
          000649 56               [ 2] 1398     rrcw    x
          00064A 07 01            [ 1] 1399     sra (0x01, sp)
          00064C 06 02            [ 1] 1400     rrc (0x02, sp)
          00064E 56               [ 2] 1401     rrcw    x
          00064F 07 01            [ 1] 1402     sra (0x01, sp)
          000651 06 02            [ 1] 1403     rrc (0x02, sp)
          000653 56               [ 2] 1404     rrcw    x
          000654 07 01            [ 1] 1405     sra (0x01, sp)
          000656 06 02            [ 1] 1406     rrc (0x02, sp)
          000658 56               [ 2] 1407     rrcw    x
          000659 07 01            [ 1] 1408     sra (0x01, sp)
          00065B 06 02            [ 1] 1409     rrc (0x02, sp)
          00065D 56               [ 2] 1410     rrcw    x
          00065E 07 01            [ 1] 1411     sra (0x01, sp)
          000660 06 02            [ 1] 1412     rrc (0x02, sp)
          000662 56               [ 2] 1413     rrcw    x
          000663 07 01            [ 1] 1414     sra (0x01, sp)
          000665 06 02            [ 1] 1415     rrc (0x02, sp)
          000667 56               [ 2] 1416     rrcw    x
          000668 07 01            [ 1] 1417     sra (0x01, sp)
          00066A 06 02            [ 1] 1418     rrc (0x02, sp)
          00066C 56               [ 2] 1419     rrcw    x
          00066D 07 01            [ 1] 1420     sra (0x01, sp)
          00066F 06 02            [ 1] 1421     rrc (0x02, sp)
          000671 56               [ 2] 1422     rrcw    x
          000672 07 01            [ 1] 1423     sra (0x01, sp)
          000674 06 02            [ 1] 1424     rrc (0x02, sp)
          000676 56               [ 2] 1425     rrcw    x
          000677 07 01            [ 1] 1426     sra (0x01, sp)
          000679 06 02            [ 1] 1427     rrc (0x02, sp)
          00067B 56               [ 2] 1428     rrcw    x
          00067C 07 01            [ 1] 1429     sra (0x01, sp)
          00067E 06 02            [ 1] 1430     rrc (0x02, sp)
          000680 56               [ 2] 1431     rrcw    x
          000681 07 01            [ 1] 1432     sra (0x01, sp)
          000683 06 02            [ 1] 1433     rrc (0x02, sp)
          000685 56               [ 2] 1434     rrcw    x
          000686 07 01            [ 1] 1435     sra (0x01, sp)
          000688 06 02            [ 1] 1436     rrc (0x02, sp)
          00068A 56               [ 2] 1437     rrcw    x
    

    The second instruction produces this code:

                                       1523 ;   tbasic.c: 758: t >>= 16;
          000711 4F               [ 1] 1524     clr a
          000712 5D               [ 2] 1525     tnzw    x
          000713 2A 01            [ 1] 1526     jrpl    00143$
          000715 4A               [ 1] 1527     dec a
          000716                       1528 00143$:
          000716 88               [ 1] 1529     push    a
          000717 01               [ 1] 1530     rrwa    x
          000718 90 01            [ 1] 1531     rrwa    y
          00071A 7B 01            [ 1] 1532     ld  a, (1, sp)
          00071C 01               [ 1] 1533     rrwa    x
          00071D 90 01            [ 1] 1534     rrwa    y
          00071F 84               [ 1] 1535     pop a
          000720 1F 0B            [ 2] 1536     ldw (0x0b, sp), x
    
     
  • Philipp Klaus Krause

    Not having looked into this in detail: I suspect that codegen always generates the longer code, then the peephole optimizer replaces it by bset/bres. Then an inaccurate notUsed peephole optimizer helper function would result in the last one not being replaced, as SDCC couldn't prove there that the value in a is no longer needed.

    I'd like to see .asm or .lst output from a current SDCC version when using --fverbose-asm.

     

    Last edit: Philipp Klaus Krause 2024-01-31
  • Andreas7

    Andreas7 - 2024-01-31

    Hello,
    this is the "bset bres" issue compiled by SDCC 4.4.0 with --fverbose-asm:

                                        133 ;   -----------------------------------------
                                        134 ;    function i2c_init
                                        135 ;   -----------------------------------------
                                        136 ;   Register assignment is optimal.
                                        137 ;   Stack space usage: 0 bytes.
          00000A                        138 _i2c_init:
                                        139 ;   tbasic.c: 51: *(uint8_t *)(SCL_BASE + P_DDR) |= SCL_MASK;           // Set DDR to output
                                        140 ; genPointerGet
                                        141 ; genOr
                                        142 ; genPointerSet
          00000A 72 16 50 11      [ 1]  143     bset    0x5011, #3
                                        144 ; peephole 202x replaced 'or' by 'bset' ('0x5011').
                                        145 ;   tbasic.c: 52: *(uint8_t *)(SCL_BASE + P_CR1) &= ~SCL_MASK;      // Set CR1 to open-drain
                                        146 ; genPointerGet
                                        147 ; genAnd
                                        148 ; genPointerSet
          00000E 72 17 50 12      [ 1]  149     bres    0x5012, #3
                                        150 ; peephole 204x replaced 'and' by 'bres' ('0x5012').
                                        151 ;   tbasic.c: 53: *(uint8_t *)(SCL_BASE + P_CR2) &= ~SCL_MASK;      // Set CR2 to 2MHz
                                        152 ; genPointerGet
                                        153 ; genAnd
                                        154 ; genPointerSet
          000012 72 17 50 13      [ 1]  155     bres    0x5013, #3
                                        156 ; peephole 204x replaced 'and' by 'bres' ('0x5013').
                                        157 ;   tbasic.c: 54: i2c_set_scl();
                                        158 ; genCall
          000016 CDr00r00         [ 4]  159     call    _i2c_set_scl
                                        160 ;   tbasic.c: 56: *(uint8_t *)(SDA_BASE + P_DDR) |= SDA_MASK;           // Set DDR to output
                                        161 ; genPointerGet
                                        162 ; genOr
                                        163 ; genPointerSet
          000019 72 18 50 11      [ 1]  164     bset    0x5011, #4
                                        165 ; peephole 202x replaced 'or' by 'bset' ('0x5011').
                                        166 ;   tbasic.c: 57: *(uint8_t *)(SDA_BASE + P_CR1) &= ~SDA_MASK;      // Set CR1 to open-drain
                                        167 ; genPointerGet
                                        168 ; genAnd
                                        169 ; genPointerSet
          00001D 72 19 50 12      [ 1]  170     bres    0x5012, #4
                                        171 ; peephole 204x replaced 'and' by 'bres' ('0x5012').
                                        172 ;   tbasic.c: 58: *(uint8_t *)(SDA_BASE + P_CR2) &= ~SDA_MASK;      // Set CR2 to 2MHz
                                        173 ; genPointerGet
          000021 C6 50 13         [ 1]  174     ld  a, 0x5013
                                        175 ; genAnd
          000024 A4 EF            [ 1]  176     and a, #0xef
                                        177 ; genPointerSet
          000026 C7 50 13         [ 1]  178     ld  0x5013, a
                                        179 ;   tbasic.c: 59: i2c_set_sda();
                                        180 ; genCall
                                        181 ; genLabel
                                        182 ; peephole j30 removed unused label 00101$.
                                        183 ;   tbasic.c: 60: }
                                        184 ; genEndFunction
          000029 CCr00r05         [ 2]  185     jp  _i2c_set_sda
                                        186 ; peephole 52 removed unreachable ret.
    

    This is the "shift by 16" issue compiled by SDCC 4.4.0 with --fverbose-asm:

                                       2293 ;   tbasic.c: 734: t >>= 16;
                                       2294 ; genCall
          0005FF CDr00r00         [ 4] 2295     call    __mullong
          000602 5B 08            [ 2] 2296     addw    sp, #8
          000604 1F 0D            [ 2] 2297     ldw (0x0d, sp), x
                                       2298 ; genRightShiftLiteral
          000606 17 0B            [ 2] 2299     ldw (0x0b, sp), y
                                       2300 ; peephole 4w removed redundant load from (0x0b, sp) into y.
          000608 17 01            [ 2] 2301     ldw (0x01, sp), y
          00060A 1E 0D            [ 2] 2302     ldw x, (0x0d, sp)
          00060C 07 01            [ 1] 2303     sra (0x01, sp)
          00060E 06 02            [ 1] 2304     rrc (0x02, sp)
          000610 56               [ 2] 2305     rrcw    x
          000611 07 01            [ 1] 2306     sra (0x01, sp)
          000613 06 02            [ 1] 2307     rrc (0x02, sp)
          000615 56               [ 2] 2308     rrcw    x
          000616 07 01            [ 1] 2309     sra (0x01, sp)
          000618 06 02            [ 1] 2310     rrc (0x02, sp)
          00061A 56               [ 2] 2311     rrcw    x
          00061B 07 01            [ 1] 2312     sra (0x01, sp)
          00061D 06 02            [ 1] 2313     rrc (0x02, sp)
          00061F 56               [ 2] 2314     rrcw    x
          000620 07 01            [ 1] 2315     sra (0x01, sp)
          000622 06 02            [ 1] 2316     rrc (0x02, sp)
          000624 56               [ 2] 2317     rrcw    x
          000625 07 01            [ 1] 2318     sra (0x01, sp)
          000627 06 02            [ 1] 2319     rrc (0x02, sp)
          000629 56               [ 2] 2320     rrcw    x
          00062A 07 01            [ 1] 2321     sra (0x01, sp)
          00062C 06 02            [ 1] 2322     rrc (0x02, sp)
          00062E 56               [ 2] 2323     rrcw    x
          00062F 07 01            [ 1] 2324     sra (0x01, sp)
          000631 06 02            [ 1] 2325     rrc (0x02, sp)
          000633 56               [ 2] 2326     rrcw    x
          000634 07 01            [ 1] 2327     sra (0x01, sp)
          000636 06 02            [ 1] 2328     rrc (0x02, sp)
          000638 56               [ 2] 2329     rrcw    x
          000639 07 01            [ 1] 2330     sra (0x01, sp)
          00063B 06 02            [ 1] 2331     rrc (0x02, sp)
          00063D 56               [ 2] 2332     rrcw    x
          00063E 07 01            [ 1] 2333     sra (0x01, sp)
          000640 06 02            [ 1] 2334     rrc (0x02, sp)
          000642 56               [ 2] 2335     rrcw    x
          000643 07 01            [ 1] 2336     sra (0x01, sp)
          000645 06 02            [ 1] 2337     rrc (0x02, sp)
          000647 56               [ 2] 2338     rrcw    x
          000648 07 01            [ 1] 2339     sra (0x01, sp)
          00064A 06 02            [ 1] 2340     rrc (0x02, sp)
          00064C 56               [ 2] 2341     rrcw    x
          00064D 07 01            [ 1] 2342     sra (0x01, sp)
          00064F 06 02            [ 1] 2343     rrc (0x02, sp)
          000651 56               [ 2] 2344     rrcw    x
          000652 07 01            [ 1] 2345     sra (0x01, sp)
          000654 06 02            [ 1] 2346     rrc (0x02, sp)
          000656 56               [ 2] 2347     rrcw    x
          000657 07 01            [ 1] 2348     sra (0x01, sp)
          000659 06 02            [ 1] 2349     rrc (0x02, sp)
          00065B 56               [ 2] 2350     rrcw    x
                                       2351 ;   tbasic.c: 735: t -= 40 * 100;
                                       2352 ; genMinus
          00065C 1F 03            [ 2] 2353     ldw (0x03, sp), x
                                       2354 ; peephole 4w removed redundant load from (0x03, sp) into x.
          00065E 1D 0F A0         [ 2] 2355     subw    x, #0x0fa0
          000661 1F 0D            [ 2] 2356     ldw (0x0d, sp), x
          000663 1E 01            [ 2] 2357     ldw x, (0x01, sp)
          000665 24 01            [ 1] 2358     jrnc    00147$
          000667 5A               [ 2] 2359     decw    x
          000668                       2360 00147$:
          000668 1F 0B            [ 2] 2361     ldw (0x0b, sp), x
                                       2362 ;   tbasic.c: 736: thd->temperature = t;
                                       2363 ; genCast
                                       2364 ; genAssign
                                       2365 ; genPointerSet
    
     
  • Philipp Klaus Krause

    The .asm indicates this is indeed the peephole optimizer that makes the difference here.

    Can you provide a self-contained, compileable C code sample to reproduce the issue?

     
    • Philipp Klaus Krause

      The peephole optimizer couldn't handle the tail call well, triggering a fail-safe fallback.

      In [r14920], this was improved, and we not get the bres.

       

      Related

      Commit: [r14920]

  • Andreas7

    Andreas7 - 2024-05-24

    Hello,
    here is the self contained code file, the list file and the make script.
    The not optimized lines are:

    000021 C6 50 13 [ 1] 128 ld a, 0x5013
    000024 A4 EF [ 1] 129 and a, #0xef
    000026 C7 50 13 [ 1] 130 ld 0x5013, a

     
    • Philipp Klaus Krause

      Thanks. I can reproduce the issue in SDCC built from current trunk on my Debian GNU/Linux testing system.

       
  • Andreas7

    Andreas7 - 2024-05-25

    Hello,
    here is a small selfcontaining example to reproduce the "right shift by 16" no optimization problem.

    The not optimized lines:
    198 ; tbasic.c: 53: t >>= 16;
    00006C CDr00r00 [ 4] 199 call __mullong
    00006F 5B 08 [ 2] 200 addw sp, #8
    000071 1F 0D [ 2] 201 ldw (0x0d, sp), x
    000073 17 0B [ 2] 202 ldw (0x0b, sp), y
    000075 17 01 [ 2] 203 ldw (0x01, sp), y
    000077 1E 0D [ 2] 204 ldw x, (0x0d, sp)
    000079 07 01 [ 1] 205 sra (0x01, sp)
    00007B 06 02 [ 1] 206 rrc (0x02, sp)
    00007D 56 [ 2] 207 rrcw x
    00007E 07 01 [ 1] 208 sra (0x01, sp)
    000080 06 02 [ 1] 209 rrc (0x02, sp)
    000082 56 [ 2] 210 rrcw x
    000083 07 01 [ 1] 211 sra (0x01, sp)
    000085 06 02 [ 1] 212 rrc (0x02, sp)
    000087 56 [ 2] 213 rrcw x
    000088 07 01 [ 1] 214 sra (0x01, sp)
    00008A 06 02 [ 1] 215 rrc (0x02, sp)
    00008C 56 [ 2] 216 rrcw x
    00008D 07 01 [ 1] 217 sra (0x01, sp)
    00008F 06 02 [ 1] 218 rrc (0x02, sp)
    000091 56 [ 2] 219 rrcw x
    000092 07 01 [ 1] 220 sra (0x01, sp)
    000094 06 02 [ 1] 221 rrc (0x02, sp)
    000096 56 [ 2] 222 rrcw x
    000097 07 01 [ 1] 223 sra (0x01, sp)
    000099 06 02 [ 1] 224 rrc (0x02, sp)
    00009B 56 [ 2] 225 rrcw x
    00009C 07 01 [ 1] 226 sra (0x01, sp)
    00009E 06 02 [ 1] 227 rrc (0x02, sp)
    0000A0 56 [ 2] 228 rrcw x
    0000A1 07 01 [ 1] 229 sra (0x01, sp)
    0000A3 06 02 [ 1] 230 rrc (0x02, sp)
    0000A5 56 [ 2] 231 rrcw x
    0000A6 07 01 [ 1] 232 sra (0x01, sp)
    0000A8 06 02 [ 1] 233 rrc (0x02, sp)
    0000AA 56 [ 2] 234 rrcw x
    0000AB 07 01 [ 1] 235 sra (0x01, sp)
    0000AD 06 02 [ 1] 236 rrc (0x02, sp)
    0000AF 56 [ 2] 237 rrcw x
    0000B0 07 01 [ 1] 238 sra (0x01, sp)
    0000B2 06 02 [ 1] 239 rrc (0x02, sp)
    0000B4 56 [ 2] 240 rrcw x
    0000B5 07 01 [ 1] 241 sra (0x01, sp)
    0000B7 06 02 [ 1] 242 rrc (0x02, sp)
    0000B9 56 [ 2] 243 rrcw x
    0000BA 07 01 [ 1] 244 sra (0x01, sp)
    0000BC 06 02 [ 1] 245 rrc (0x02, sp)
    0000BE 56 [ 2] 246 rrcw x
    0000BF 07 01 [ 1] 247 sra (0x01, sp)
    0000C1 06 02 [ 1] 248 rrc (0x02, sp)
    0000C3 56 [ 2] 249 rrcw x
    0000C4 07 01 [ 1] 250 sra (0x01, sp)
    0000C6 06 02 [ 1] 251 rrc (0x02, sp)
    0000C8 56 [ 2] 252 rrcw x

     
    • Philipp Klaus Krause

      Thanks. I can reproduce the shift issue.

       
      • Philipp Klaus Krause

        in [r14921], better code is generated for the shift.

         

        Related

        Commit: [r14921]

  • Philipp Klaus Krause

    Ticket moved from /p/sdcc/bugs/3705/

    Can't be converted:

    • _category: STM8
     
  • Philipp Klaus Krause

    Moved to feature request tracker, since the generated code is correct, just not as efficient as we would want it to be.

     
  • Philipp Klaus Krause

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

Log in to post a comment.