|
From: Thorsten O. <ad...@th...> - 2019-11-06 00:20:33
|
On Mittwoch, 6. November 2019 00:03:47 CET Vincent Rivière wrote:
> m68k-linux-gnu-gcc -mshort -S -O2 -fomit-frame-pointer a.c -o -
Uh oh. That looks really strange. Interestingly, i get also strange results
with the cross-compiler from opensuse:
$ m68k-suse-linux-gcc -S -O2 -fomit-frame-pointer -mshort a.c -o -
f:
move.l 4(%sp),%d1
move.l 8(%sp),%a0
clr.b (%a0)
move.l %a0,%d0
add.l #65535,%d0
subq.l #1,%a0
cmp.l %d1,%a0
jls .L1
.L5:
move.l %d0,%a0
clr.b (%a0)
move.l %a0,%d0
add.l #65535,%d0
subq.l #1,%a0
cmp.l %d1,%a0
jhi .L5
.L1:
rts
.size f, .-f
.ident "GCC: (GNU) 4.8.1"
.section .note.GNU-stack,"",@progbits
The same strange add.l #65535, but note that the comparison is done to a0
instead of d0, so that is even worse, because that will be translated to cmpa,
which does not set the flags.
Our compiler does not do that:
m68k-atari-mint-gcc-7 -O2 -fomit-frame-pointer -mshort -S -o - x.c
#NO_APP
.text
.even
.globl _f
_f:
move.l 4(%sp),%d0
move.l 8(%sp),%a0
.L2:
clr.b (%a0)
subq.l #1,%a0
cmp.l %d0,%a0
jhi .L2
rts
(this is gcc 7.4; our current gcc 9.1 produces the same code)
The plain m68k-elf-gcc also does not have that problem. Must be must something
that they had patched, or wrongly configured. And if you try it you will see:
$ echo "" | m68k-atari-linux-gcc -mshort -dM -E - | grep SIZE_T
#define __SIZEOF_SIZE_T__ 2
#define __SIZE_TYPE__ unsigned int
Thats the reason for the madness.
|