[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] Optimisation bug in gcc 4 ?
Hello Patrice,
While I am no expert, I believe this problem still exists in GCC 4.5.0.
Attached are the .s files from -O0 and -O1 (and -O2, -O3 is identical
to -O2) from:
falcon:tmp# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/d/usr/bin/../libexec/gcc/m68k-atari-mint/4.5.0/lto-wrapper
Target: m68k-atari-mint
Configured with: ../configure --enable-languages=c,c++ --prefix=/usr
--disable-nls --disable-libstdcxx-pch --target=m68k-atari-mint
--host=m68k-atari-mint
Thread model: single
gcc version 4.5.0 (MiNT 20100511) (GCC)
Keith
On Wed, 9 Jun 2010, Patrice Mandin wrote:
Hello,
I just encountered a strange optimisation bug with gcc 4 (4.4.2 more
precisely), I hope it's fixed with 4.5.
Source is attached, this is a small test case.
I have a variable 'vidix_capability_t vidx_cap'.
The purpose of the function vdxGetCapability() (which is xbios #404) is
to fill this structure.
Then I test the field vidx_cap.flags for a given combination of bits in
this field.
Depending on this test, I either exit the program, or call myvidix_func().
The bug:
with gcc 4.4.2 (starting at -O1 level), it assumes the field has a
constant value, optimizes the test by removing it, and the code that
follows, thus also wiping out entirely the function myvidix_func from
the generated assembly code (use -save-temps to prevent deletion of it).
It does not happen with -O0, or with gcc 3.
I don't know if it's a problem in gcc, or in the definition of the
function (that uses mintlib defined trap_14_wl macro).
Note: both 4.4.2 and 3.x are cross-compilers.
--
Patrice Mandin
WWW: http://pmandin.atari.org/
Programmeur Linux, Atari
Spécialité: Développement, jeux
"who writes the code, decides"
#NO_APP
.text
.LC0:
.ascii "vidix: Get capability failed\15\12\0"
.LC1:
.ascii "vidix: Need upscaler and downscaler\12\0"
.even
.globl _main
_main:
link.w %fp,#-204
move.l %a2,-(%sp)
move.l %d2,-(%sp)
jsr ___main
lea (-204,%fp),%a0
move.l %a0,-4(%fp)
move.l -4(%fp),%d0
#APP
| 45 "patrice.c" 1
movl %d0,sp@-
movw #404,sp@-
trap #14
addql #6,sp
| 0 "" 2
#NO_APP
tst.l %d0
jeq .L2
move.l #.LC0,-8(%fp)
move.l -8(%fp),%d0
#APP
| 46 "patrice.c" 1
movl %d0,sp@-
movw #9,sp@-
trap #1
addql #6,sp
| 0 "" 2
#NO_APP
jra .L1
.L2:
move.l #.LC1,-12(%fp)
move.l -12(%fp),%d0
#APP
| 52 "patrice.c" 1
movl %d0,sp@-
movw #9,sp@-
trap #1
addql #6,sp
| 0 "" 2
#NO_APP
nop
.L1:
move.l -212(%fp),%d2
move.l -208(%fp),%a2
unlk %fp
rts
.LC2:
.ascii "Hello vidix\15\12\0"
.even
_myvidix_func:
link.w %fp,#-4
move.l %a2,-(%sp)
move.l %d2,-(%sp)
move.l #.LC2,-4(%fp)
move.l -4(%fp),%d0
#APP
| 61 "patrice.c" 1
movl %d0,sp@-
movw #9,sp@-
trap #1
addql #6,sp
| 0 "" 2
#NO_APP
move.l (%sp)+,%d2
move.l (%sp)+,%a2
unlk %fp
rts
#NO_APP
.text
.LC0:
.ascii "vidix: Get capability failed\15\12\0"
.LC1:
.ascii "vidix: Need upscaler and downscaler\12\0"
.even
.globl _main
_main:
link.w %fp,#-192
move.l %a2,-(%sp)
move.l %d2,-(%sp)
jsr ___main
move.l %fp,%d0
add.l #-192,%d0
#APP
| 45 "patrice.c" 1
movl %d0,sp@-
movw #404,sp@-
trap #14
addql #6,sp
| 0 "" 2
#NO_APP
tst.l %d0
jeq .L2
move.l #.LC0,%d0
#APP
| 46 "patrice.c" 1
movl %d0,sp@-
movw #9,sp@-
trap #1
addql #6,sp
| 0 "" 2
#NO_APP
jra .L1
.L2:
move.l #.LC1,%d0
#APP
| 52 "patrice.c" 1
movl %d0,sp@-
movw #9,sp@-
trap #1
addql #6,sp
| 0 "" 2
#NO_APP
.L1:
move.l -200(%fp),%d2
move.l -196(%fp),%a2
unlk %fp
rts
#NO_APP
.text
.LC0:
.ascii "vidix: Get capability failed\15\12\0"
.LC1:
.ascii "vidix: Need upscaler and downscaler\12\0"
.even
.globl _main
_main:
link.w %fp,#-192
move.l %a2,-(%sp)
move.l %d2,-(%sp)
jsr ___main
move.l %fp,%d0
add.l #-192,%d0
#APP
| 45 "patrice.c" 1
movl %d0,sp@-
movw #404,sp@-
trap #14
addql #6,sp
| 0 "" 2
#NO_APP
tst.l %d0
jne .L5
move.l #.LC1,%d0
#APP
| 52 "patrice.c" 1
movl %d0,sp@-
movw #9,sp@-
trap #1
addql #6,sp
| 0 "" 2
#NO_APP
move.l -200(%fp),%d2
move.l -196(%fp),%a2
unlk %fp
rts
.L5:
move.l #.LC0,%d0
#APP
| 46 "patrice.c" 1
movl %d0,sp@-
movw #9,sp@-
trap #1
addql #6,sp
| 0 "" 2
#NO_APP
move.l -200(%fp),%d2
move.l -196(%fp),%a2
unlk %fp
rts