Closed th-otto closed 6 years ago
What is "current version"? We have several branches.
The gcc-7-mint branch, which was used by Miro to build the native compilers. 4.6.4 is not affected by this.
I'm not sure what is better on 020: writing a word to an odd address, or writing 2 bytes instead?
Surely one word on an odd address. Unfortunately http://brownbot.mooo.com seems to be broken right now (@ggnkua do you know about it?) so I can't test other compilers how they handle 68000 vs. 68020.
Test with: ...gcc -m68000 -O2 -fomit-frame-pointer -S a.c -o -
m68k-atari-mint-gcc 4.6.4 produces the right thing: exactly "The generated code would then look like" above, without move.w.
Standard m68k-elf-gcc 7.1.0 also produces the exact same code.
And in any case, if I replace -m68000 by any other CPU options, the result stays the same: always good.
I'm not sure what is better on 020: writing a word to an odd address, or writing 2 bytes instead?
Surely one word on an odd address. Unfortunately http://brownbot.mooo.com seems to be broken right now (@ggnkua do you know about it?) so I can't test other compilers how they handle 68000 vs. 68020.
Cannot reproduce here either. I get code snippet 2. If anyone wants to play around, http://brownbot.mooo.com/z/T6z_ao
@ggnkua sorry, I should have been more specific - I meant that I got only a blank screen (no output) for the compiled code. seems to be working now and yes, your ELF build seems to be all right as well.
I confirm @vinriviere findings - it seems that the right thing to do is to ignore this optimisation, i.e. always produce the 68000 version. Does disabling STRICT_ALIGNMENT
have some other side effects?
Fixed by https://github.com/freemint/m68k-atari-mint-gcc/commit/4b7a290df1a088933a94510aa50a6e0edea90469, will prepare a new release.
The current version sometimes produces accesses to odd address, that would cause an address-error on plain 68000. The culprit seems to be https://github.com/freemint/m68k-atari-mint-gcc/blob/45f50048599322ca2c4bd34420b992c113195e72/gcc/config/m68k/mint.h#L23-L26
Simple test case:
produces
Similar code can also been found in EmuTOS https://github.com/emutos/emutos/blob/ec5bc814419255a1b1ac6e43543ef30589639144/aes/gemshlib.c#L98
Removing those lines would fix that, but also turn off that optimization for 020+
The generated code would then look like
I'm not sure what is better on 020: writing a word to an odd address, or writing 2 bytes instead?
I also could not convince gcc to use (a0)+ instead.