https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122108
Bug ID: 122108
Summary: [M68K][Fixed-Point] Wrong stack pointer update after
function call
Product: gcc
Version: 14.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: djipi.mari at gmail dot com
Target Milestone: ---
I have adapted the gcc 14.3.0 config file, and compiled with the
--enable-fixed-point so gcc can compile with the fixed-point types.
About the configure options:
--prefix="/c/Projects/GNU/build" \
--target=m68k-elf \
--with-cpu=m68000 \
--with-newlib --with-gnu-as --with-gnu-ld \
--without-headers \
--enable-fixed-point \
--enable-languages=c,c++ \
--enable-lto \
--enable-silent-rules \
--enable-static \
--disable-bootstrap \
--disable-checking \
--disable-docs \
--disable-hosted-libstdcxx \
--disable-libgomp \
--disable-libssp \
--disable-libstdcxx-pch \
--disable-libstdcxx-verbose \
--disable-libquadmath \
--disable-multilib \
--disable-nls \
--disable-plugins \
--disable-shared \
--disable-threads \
--disable-tls
And I have added these lines in the gcc configure with the mips, arm &
loongarch parts:
m68k*)
enable_fixed_point=yes
;;
The gcc compiler is generated without problems.
I have tried with a short source code using short _Fract & _Fract
(signed/unsigned) and found an issue in the m68k (at least in 68000) generated
code. The code compiles without error:
int main(int argc, char** argv)
{
unsigned _Fract i_ur = 0.85ur;
i_ur += 0.017ur;
}
.file "test.c"
.text
.align 2
.globl main
.type main, @function
main:
| BLOCK 2 seq:0
| PRED: ENTRY (FALLTHRU)
link.w %fp,#-4 | 24 [c=0] *link
move.w #-9831,-2(%fp) | 5 [c=2] *m68k.md:1084
move.w #1114,-(%sp) | 6 [c=2] *m68k.md:1084
move.w -2(%fp),-(%sp) | 7 [c=8] *m68k.md:1084
jsr __adduhq3 | 8 [c=11] *symbolic_call_value_jsr/1
addq.l #8,%sp | 9 [c=4] *addsi3_internal/1
move.w %d0,%d0 | 10 [c=4] *m68k.md:1084
move.w %d0,-2(%fp) | 11 [c=4] *m68k.md:1084
moveq #0,%d0 | 12 [c=4] *movsi_const0_68000_10/0
unlk %fp | 29 [c=0] *unlink
| SUCC: EXIT [always]
rts | 30 [c=0] *return
.size main, .-main
.globl __adduhq3
.ident "GCC: (GNU) 14.3.0"
The addq.l #8,%sp should be addq.l #4,%sp