mburkley / tms9900-gcc

gcc cross-compiler for TMS9900
GNU General Public License v3.0
13 stars 1 forks source link

[1.32 branch][bug][OK in latest changes of branch 1.32] Mostly good news except for "internal compiler error: in subreg_highpart_offset" when dividing a constant by an unsigned char #64

Closed Fabrizio-Caruso closed 1 week ago

Fabrizio-Caruso commented 3 weeks ago

1.32 seems to fix all new major problems (some old issues persist). Maybe there are a couple of very minor issues but all games except one can be built and are playable. So it is OK for 8 out of 9 games.

I am compiling with -O2 -fno-peephole2 -fno-function-cse. I have the same probem if I substitue -O2 with -Os or -O1.

If I try to compile my game Verbix in my Cross-Lib project I get: internal compiler error: in subreg_highpart_offset

A more complete message is

games/verbix/main.c: In function ‘drop_letter’:
games/verbix/main.c:422: internal compiler error: in subreg_highpart_offset, at emit-rtl.c:1316
Please submit a full bug report,
with preprocessed source if appropriate.
See <[http://gcc.gnu.org/bugs.html](http://gcc.gnu.org/bugs.html?fbclid=IwZXh0bgNhZW0CMTAAAR1lN5Unoi3YXbMH3H6BpGceVSuJyYNFtRnQ2J0kaPGBPw-kS5w1_61PBTg_aem_da3daBQmDaX9y9yef7nZHw)> for instructions.
make: * [makefiles.common/targets/gcc4ti/Makefile_ti99:113: games/verbix/main.o] Error 1

If seems to fail in line 422 of main.c: https://github.com/Fabrizio-Caruso/CROSS-LIB/blob/master/src/games/verbix/main.c#L422

which is the last line of the drop_letter function:

void drop_letter(void)
{
    uint8_t height;
    uint8_t new_letter;
    _XL_PING_SOUND();
    max_level_counter = ((INITIAL_MAX_LEVEL_COUNT)/level+(remaining_words>>3));
    height = matrix_height[slot_index];
    if(next_letter_index<NO_OF_PRECOMPUTED_LETTERS)
    {
        new_letter = precomputed_letter[next_letter_index];
        ++next_letter_index;
    }
    else
    {
        new_letter = (uint8_t) _XL_RAND()%ALPHABET_SIZE;
    }
    matrix[slot_index][height]= new_letter;
    draw_letter(slot_index,height);
    if(height==MAX_HEIGHT-1)
    {
        alive = 0;
    }
    ++matrix_height[slot_index];    
    slot_index = (slot_index + 1U) % WORD_SIZE;
}
mburkley commented 3 weeks ago

If you could create a standalone buildable snippet of code that would be very helpful. The above references several externals and I don't know what type they are. tks.

Fabrizio-Caruso commented 3 weeks ago

I will do my best.

Fabrizio-Caruso commented 3 weeks ago

A minimal test that shows the error:

#define uint8_t unsigned char
uint8_t level;
uint8_t max_level_counter;
#define INITIAL_MAX_LEVEL_COUNT 72U
int main(void)
{
    max_level_counter = INITIAL_MAX_LEVEL_COUNT/level;
    return 0;
}
mburkley commented 1 week ago

Initialisation of longs from constants was not working correctly - fixed in 1.32