Menu

#3634 Problems with shifting wide (> 32 bit) variables)

closed-fixed
None
MCS51
5
2023-11-02
2023-08-17
No

In [r14305] I added more regression tests for shifts of wide variables. Some of them fail; apparently only ports that use support functions for shifts of such variables are affected.

Related

Bugs: #3619
Commit: [r14305]
Discussion: [SDCC 4.3.0][MCS51] bug adding int64_t constants using liblonglong
Discussion: [SDCC 4.3.0][MCS51] bug adding int64_t constants using liblonglong
Wiki: SDCC 4.4.0 Release

Discussion

  • Philipp Klaus Krause

    As of now ([r14308]), I only see a few remaining failures. All for mcs51 and the small memory model (the failures are the same both with and without --stack-auto):

    Summary for 'mcs51-small-stack-auto': 36 failures, 23023 tests, 4357 test cases, 9675166 bytes, 909219996 ticks
       Failure: bitintshift_width_33_count_1_varstorage_auto_countstorage_auto_direction_1
       Failure: bitintshift_width_33_count_1_varstorage_auto_countstorage_static_direction_1
       Failure: bitintshift_width_33_count_20_varstorage_auto_countstorage_auto_direction_1
       Failure: bitintshift_width_33_count_20_varstorage_auto_countstorage_static_direction_1
       Failure: bitintshift_width_40_count_1_varstorage_auto_countstorage_auto_direction_0
       Failure: bitintshift_width_40_count_1_varstorage_auto_countstorage_auto_direction_1
       Failure: bitintshift_width_40_count_1_varstorage_auto_countstorage_static_direction_0
       Failure: bitintshift_width_40_count_1_varstorage_auto_countstorage_static_direction_1
       Failure: bitintshift_width_40_count_20_varstorage_auto_countstorage_auto_direction_1
       Failure: bitintshift_width_40_count_20_varstorage_auto_countstorage_static_direction_1
       Failure: bitintshift_width_48_count_1_varstorage_auto_countstorage_auto_direction_0
       Failure: bitintshift_width_48_count_1_varstorage_auto_countstorage_auto_direction_1
       Failure: bitintshift_width_48_count_1_varstorage_auto_countstorage_static_direction_0
       Failure: bitintshift_width_48_count_1_varstorage_auto_countstorage_static_direction_1
       Failure: bitintshift_width_48_count_20_varstorage_auto_countstorage_auto_direction_1
       Failure: bitintshift_width_48_count_20_varstorage_auto_countstorage_static_direction_1
       Failure: bitintshift_width_48_count_40_varstorage_auto_countstorage_auto_direction_1
       Failure: bitintshift_width_48_count_40_varstorage_auto_countstorage_static_direction_1
    

    P.S.: The test currently does not use as many values for the shift count as I will want to use later, due to an issue in the regtest infrastructure. I think I would otherwise see a higher number of failures (at different shift counts, but the same widths and storage classes).

     

    Related

    Commit: [r14308]


    Last edit: Philipp Klaus Krause 2023-08-17
  • Philipp Klaus Krause

    Actually, this is not about the support functions. For the failing shift tests, code is generated directly by the mcs51 backend. After all, mcs51 never uses support routines for shifts.

     
  • Philipp Klaus Krause

    • Category: other --> MCS51
     
  • Philipp Klaus Krause

    An example from gen/mcs51-small/bitintshift/bitintshift_width_33_count_1_varstorage_auto_countstorage_auto_direction_1.lst (code generated for the shift itself is correct, but the return value of a call is messed up):

                                        215 ;   cases/bitintshift/bitintshift_width_33_count_1_varstorage_auto_countstorage_auto_direction_1.c:88: operand = setoperand0();
                                        216 ;   genCall
          000047 C0 07            [24]  217     push    ar7
          000049 12r00r00         [24]  218     lcall   _setoperand0
          00004C AA 82            [24]  219     mov r2,dpl
          00004E AB 83            [24]  220     mov r3,dph
          000050 AC F0            [24]  221     mov r4,b
          000052 FD               [12]  222     mov r5,a
          000053 8C 06            [24]  223     mov ar6,r4
          000055 D0 07            [24]  224     pop ar7
    

    The value in r4 is overwritten before it is used. While in this test, the error is seen for an unsigned _BitInt, I think the same problem can affect an unsigned long long.

    P.S.: The wrong code is generated in assignResultValue in gen.c.

     

    Last edit: Philipp Klaus Krause 2023-09-01
    • Philipp Klaus Krause

      IMO, the best way forward for fixing this and related issues is to implement the wholegenMove_o and genCopy machinery we have in some other ports, such as stm8: Helper functions that will try to move data from (part of) one asmop to another as efficiently as possible, and being able to deal with virtually any complications, such as overlapping source/destination.

      As of [r14339], the failing parts of the test is disabled for mcs51-small.

       

      Related

      Commit: [r14339]

  • Philipp Klaus Krause

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

    Fixed in [r14398].

     

    Related

    Commit: [r14398]


Log in to post a comment.