bebbo / amiga-gcc

The GNU C-Compiler with Binutils and other useful tools for cross development for Amiga
GNU General Public License v2.0
312 stars 66 forks source link

__divdi3 crashes on 68060 #391

Closed BSzili closed 4 months ago

BSzili commented 5 months ago

I have a standard 16.16 fixed point division function, and it seem like the 060 version of __divdi3 has some issues. I created a small test case to reproduce it. This is my fixeddiv.c:

int FixedDiv(int a, int b)
{
    return (int)(((long long)a << 16) / b);
}

int main(void)
{
    int j = FixedDiv(0, 4194304);
    return 0;
}

Then I build two executables: m68k-amigaos-gcc -save-temps -noixemul -m68060 -o fixeddiv.060 fixeddiv.c m68k-amigaos-gcc -save-temps -noixemul -m68020 -o fixeddiv.020 fixeddiv.c The 020 one works, but the 060 exe crashes with a 80000005 program failure. The generated asm output is the same, so I guess the difference is in libgcc.a? For reference I uploaded the two executables I built, in case my setup is borked: https://bszili.morphos.me/stuff/fixeddiv.020 https://bszili.morphos.me/stuff/fixeddiv.060 Thank you for the help in advance!

bebbo commented 5 months ago

I can't reproduce this issue.

BSzili commented 4 months ago

It must be config dependent. I made a self-contained test case with WinUAE that reproduces the crash: https://bszili.morphos.me/stuff/divtest.zip I included setpatch, but it happens without it as well.

bebbo commented 4 months ago

your executable crashes, but I cannot build such a crashing executable.

bebbo commented 4 months ago

agc391.zip these are the results building with a clean and fresh prefix

BSzili commented 4 months ago

I see, thanks for the clarification! I'll do a drop-prefix + clean and report back.

BSzili commented 4 months ago

Re-doing my setup fixed it. Sorry for the false alarm, closing this.