public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/42522]  New: [m68k] Wrong code generated with -O2/-O3
@ 2009-12-28 20:15 ami_stuff at o2 dot pl
  2009-12-28 20:18 ` [Bug c/42522] " ami_stuff at o2 dot pl
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: ami_stuff at o2 dot pl @ 2009-12-28 20:15 UTC (permalink / raw)
  To: gcc-bugs

Hi,

This is a code from "libavformat/flvdec.c":

static int flv_probe(AVProbeData *p)
{
    const uint8_t *d;

    d = p->buf;
    if (d[0] == 'F' && d[1] == 'L' && d[2] == 'V' && d[3] < 5 && d[5]==0 &&
AV_RB32(d+5)>8) {
        return AVPROBE_SCORE_MAX;
    }
    return 0;
}

When I compile FFmpeg with -O2/-O3 options, FFmpeg doesn't recognize FLV files
("Unknown format"), but when I use -O1 everything works correctly.

Here is asm output when I compile flvdec.c file with -O2:

_flv_probe:
        clr.l d0
        rts
        .even

and here when I use -O1:

_flv_probe:
        move.l 4(sp),a0
        move.l 4(a0),a0
        cmp.b #70,(a0)
        jne L3
        cmp.b #76,1(a0)
        jne L4
        cmp.b #86,2(a0)
        jne L5
        cmp.b #4,3(a0)
        jhi L6
        tst.b 5(a0)
        jne L7
        move.l 5(a0),d0
        moveq #8,d1
        cmp.l d0,d1
        jcs L8
        clr.l d0
        rts
L3:
        clr.l d0
        rts
L4:
        clr.l d0
        rts
L5:
        clr.l d0
        rts
L6:
        clr.l d0
        rts
L7:
        clr.l d0
        rts
L8:
        moveq #100,d0
        rts
        .even


I attache proprocessed files + asm output in the archive.


-- 
           Summary: [m68k] Wrong code generated with -O2/-O3
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ami_stuff at o2 dot pl
  GCC host triplet: i686-cygwin
GCC target triplet: m68k-amigaos


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42522


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug c/42522] [m68k] Wrong code generated with -O2/-O3
  2009-12-28 20:15 [Bug c/42522] New: [m68k] Wrong code generated with -O2/-O3 ami_stuff at o2 dot pl
@ 2009-12-28 20:18 ` ami_stuff at o2 dot pl
  2009-12-28 20:23 ` [Bug target/42522] " pinskia at gcc dot gnu dot org
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: ami_stuff at o2 dot pl @ 2009-12-28 20:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from ami_stuff at o2 dot pl  2009-12-28 20:17 -------
Created an attachment (id=19401)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19401&action=view)
preprocessed files + asm output


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42522


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/42522] [m68k] Wrong code generated with -O2/-O3
  2009-12-28 20:15 [Bug c/42522] New: [m68k] Wrong code generated with -O2/-O3 ami_stuff at o2 dot pl
  2009-12-28 20:18 ` [Bug c/42522] " ami_stuff at o2 dot pl
@ 2009-12-28 20:23 ` pinskia at gcc dot gnu dot org
  2009-12-28 20:39 ` [Bug c/42522] " ami_stuff at o2 dot pl
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-12-28 20:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2009-12-28 20:23 -------
Does -O2 -fno-strict-aliasing work?


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |normal
          Component|c                           |target


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42522


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug c/42522] [m68k] Wrong code generated with -O2/-O3
  2009-12-28 20:15 [Bug c/42522] New: [m68k] Wrong code generated with -O2/-O3 ami_stuff at o2 dot pl
  2009-12-28 20:18 ` [Bug c/42522] " ami_stuff at o2 dot pl
  2009-12-28 20:23 ` [Bug target/42522] " pinskia at gcc dot gnu dot org
@ 2009-12-28 20:39 ` ami_stuff at o2 dot pl
  2009-12-28 23:31 ` schwab at linux-m68k dot org
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: ami_stuff at o2 dot pl @ 2009-12-28 20:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from ami_stuff at o2 dot pl  2009-12-28 20:38 -------
No, asm code looks the same like with -O2 option:

_flv_probe:
        clr.l d0
        rts
        .even


Here are GCC's options which I used (should be included in the first post):

$ make_68k_v45
/bin/ffmpeg13_play/version.sh "/bin/ffmpeg13_play" version.h
/usr/local/amiga/bin/m68k-amigaos-gcc-4.5.0.exe -V 4.5.0 -DHAVE_AV_CONFIG_H -I.
-I"/bin/ffmpeg13_play" --save-temps -S -D_ISOC99_SOURCE
-D_POSIX_C_SOURCE=200112
 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DHAVE_BIGENDIAN=1 -m68060 -std=c99
-fno-common -fomit-frame-pointer -Wdeclaration-after-statement -Wall
-Wno-switch
 -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wcast-qual
-Wwrite-s
trings -Wundef -O2 -S -fno-math-errno       -MMD -MF libavformat/flvdec.d -MT
li
bavformat/flvdec.o -c -o libavformat/flvdec.o libavformat/flvdec.c


$ m68k-amigaos-gcc -V 4.5.0 -v
Using built-in specs.
COLLECT_GCC=m68k-amigaos-gcc-4.5.0
COLLECT_LTO_WRAPPER=/usr/local/amiga/libexec/gcc/m68k-amigaos/4.5.0/lto-wrapper.
exe
Target: m68k-amigaos
Configured with: /bernd/gcc4/configure --target=m68k-amigaos --with-cpu=m68040
-
-prefix=/usr/local/amiga
Thread model: single
gcc version 4.5.0 20091224 (experimental) (GCC)


-- 

ami_stuff at o2 dot pl changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |major
          Component|target                      |c


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42522


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug c/42522] [m68k] Wrong code generated with -O2/-O3
  2009-12-28 20:15 [Bug c/42522] New: [m68k] Wrong code generated with -O2/-O3 ami_stuff at o2 dot pl
                   ` (2 preceding siblings ...)
  2009-12-28 20:39 ` [Bug c/42522] " ami_stuff at o2 dot pl
@ 2009-12-28 23:31 ` schwab at linux-m68k dot org
  2009-12-28 23:38 ` ami_stuff at o2 dot pl
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: schwab at linux-m68k dot org @ 2009-12-28 23:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from schwab at linux-m68k dot org  2009-12-28 23:30 -------
Works for me with 4.5.0 20091228.


-- 

schwab at linux-m68k dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |normal
             Status|UNCONFIRMED                 |RESOLVED
   GCC host triplet|i686-cygwin                 |
 GCC target triplet|m68k-amigaos                |m68k-*-*
         Resolution|                            |WORKSFORME


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42522


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug c/42522] [m68k] Wrong code generated with -O2/-O3
  2009-12-28 20:15 [Bug c/42522] New: [m68k] Wrong code generated with -O2/-O3 ami_stuff at o2 dot pl
                   ` (3 preceding siblings ...)
  2009-12-28 23:31 ` schwab at linux-m68k dot org
@ 2009-12-28 23:38 ` ami_stuff at o2 dot pl
  2009-12-29  1:20 ` ami_stuff at o2 dot pl
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: ami_stuff at o2 dot pl @ 2009-12-28 23:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from ami_stuff at o2 dot pl  2009-12-28 23:38 -------
I found which optimization doesn't work correctly on my config:

-O2 ("Unknown format"):

_flv_probe:
        clr.l d0
        rts
        .even

-O2 -fno-cse-follow-jumps (works OK):

_flv_probe:
        move.l 4(sp),a0
        move.l 4(a0),a0
        cmp.b #70,(a0)
        jeq L10
L7:
        clr.l d0
        rts
L10:
        cmp.b #76,1(a0)
        jne L7
        cmp.b #86,2(a0)
        jne L7
        cmp.b #4,3(a0)
        jhi L7
        tst.b 5(a0)
        jne L7
        move.l 5(a0),d0
        moveq #8,d1
        cmp.l d0,d1
        jcc L7
        moveq #100,d0
        rts
        .even


-- 

ami_stuff at o2 dot pl changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |major


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42522


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug c/42522] [m68k] Wrong code generated with -O2/-O3
  2009-12-28 20:15 [Bug c/42522] New: [m68k] Wrong code generated with -O2/-O3 ami_stuff at o2 dot pl
                   ` (4 preceding siblings ...)
  2009-12-28 23:38 ` ami_stuff at o2 dot pl
@ 2009-12-29  1:20 ` ami_stuff at o2 dot pl
  2009-12-29 11:58 ` schwab at linux-m68k dot org
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: ami_stuff at o2 dot pl @ 2009-12-29  1:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from ami_stuff at o2 dot pl  2009-12-29 01:20 -------
> Works for me with 4.5.0 20091228.

How's that possible? What about GCC 4.4 branch? I just checked with ATARI GCC
4.4.2 m68k compiler and got the same result:

/usr/local/cross-mint/bin/m68k-atari-mint-gcc -c -S flvdec_O2.i -m68060 -O2:

_flv_probe:
        link.w %fp,#0
        clr.l %d0
        unlk %fp
        rts
        .even

/usr/local/cross-mint/bin/m68k-atari-mint-gcc -c -S flvdec_O2.i -m68060 -O2
-fno-cse-follow-jumps

_flv_probe:
        link.w %fp,#0
        move.l 8(%fp),%a0
        move.l 4(%a0),%a0
        cmp.b #70,(%a0)
        jeq .L6
.L2:
        clr.l %d0
        unlk %fp
        rts
.L6:
        cmp.b #76,1(%a0)
        jne .L2
        cmp.b #86,2(%a0)
        jne .L2
        cmp.b #4,3(%a0)
        jhi .L2
        tst.b 5(%a0)
        jne .L2
        move.l 5(%a0),%d0
        moveq #8,%d1
        cmp.l %d0,%d1
        jcc .L2
        moveq #100,%d0
        unlk %fp
        rts
        .even

$ /usr/local/cross-mint/bin/m68k-atari-mint-gcc -v
Using built-in specs.
Target: m68k-atari-mint
Configured with: ../gcc-4.4.2-mint-20091017/configure --target=m68k-atari-mint
-
-prefix=/usr/local/cross-mint --enable-languages=c,c++ --disable-nls
--disable-l
ibstdcxx-pch --mandir='/man' --infodir='/info'
Thread model: single
gcc version 4.4.2 (MiNT 20091017) (GCC)

http://vincent.riviere.free.fr/soft/m68k-atari-mint/


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42522


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug c/42522] [m68k] Wrong code generated with -O2/-O3
  2009-12-28 20:15 [Bug c/42522] New: [m68k] Wrong code generated with -O2/-O3 ami_stuff at o2 dot pl
                   ` (5 preceding siblings ...)
  2009-12-29  1:20 ` ami_stuff at o2 dot pl
@ 2009-12-29 11:58 ` schwab at linux-m68k dot org
  2009-12-29 18:52 ` nospamname at web dot de
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: schwab at linux-m68k dot org @ 2009-12-29 11:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from schwab at linux-m68k dot org  2009-12-29 11:58 -------
Please report that to the provider of your inofficial builds.  Neither
m68k-amigaos nor m68k-atari-mint are supported by the official sources.


-- 

schwab at linux-m68k dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |normal


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42522


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug c/42522] [m68k] Wrong code generated with -O2/-O3
  2009-12-28 20:15 [Bug c/42522] New: [m68k] Wrong code generated with -O2/-O3 ami_stuff at o2 dot pl
                   ` (6 preceding siblings ...)
  2009-12-29 11:58 ` schwab at linux-m68k dot org
@ 2009-12-29 18:52 ` nospamname at web dot de
  2009-12-31 13:35 ` nospamname at web dot de
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: nospamname at web dot de @ 2009-12-29 18:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from nospamname at web dot de  2009-12-29 18:52 -------
I have now find out with cflag -m68000 work with -O3.
But it work not with -m68020 or -m68040 or -m68060 

Here is a standalone testcode and output with -S

-----

struct test{
long dummy;
unsigned long buf;
};

struct unaligned_32 { unsigned long l; } __attribute__((packed));


static int flv_probe(struct test *p)
{
    const unsigned char *d;

    d = p->buf;
    if (d[0] == 'F' && d[1] == 'L' && d[2] == 'V' && d[3] < 5 && d[5]==0 &&
(((const struct unaligned_32 *) (d+5))->l)>8) {

        return 100;
    }
    return 0;
}

int main(int argc, char **argv)
{
printf("%ld\n",flv_probe(argc));
}

----------------------

Mit dem 4.5.0 vom 24.12 bekomme ich mit -O3 den Outpout .Code geht nicht.

(CFLAGS -m68060 -S -O3)

#NO_APP
    .text
LC0:
    .ascii "%ld\12\0"
    .even
    .globl  _main
_main:
    link.w a5,#0
    jsr ___main
    clr.l 12(a5)
    move.l #LC0,8(a5)
    unlk a5
    jra _printf 

----------------------------------------------

(CFLAGS -m68060 -S -O1)


#NO_APP
    .text
LC0:
    .ascii "%ld\12\0"
    .even
    .globl  _main
_main:
    link.w a5,#0
    jsr ___main
    move.l 8(a5),a0
    move.l 4(a0),a0
    cmp.b #70,(a0)
    jne L3
    cmp.b #76,1(a0)
    jne L4
    cmp.b #86,2(a0)
    jne L5
    cmp.b #4,3(a0)
    jhi L6
    tst.b 5(a0)
    jne L7
    move.l 5(a0),d0
    moveq #8,d1
    cmp.l d0,d1
    jcs L8
    clr.l d0
    jra L2
L3:
    clr.l d0
    jra L2
L4:
    clr.l d0
    jra L2
L5:
    clr.l d0
    jra L2
L6:
    clr.l d0
    jra L2
L7:
    clr.l d0
    jra L2
L8:
    moveq #100,d0
L2:
    move.l d0,-(sp)
    pea LC0
    jsr _printf
    addq.l #8,sp
    unlk a5
    rts 

#NO_APP
    .text
LC0:
    .ascii "%ld\12\0"
    .even
    .globl  _main
_main:
    link.w a5,#0
    move.l a2,-(sp)
    move.l 8(a5),a2
    jsr ___main
    move.l 4(a2),a0
    cmp.b #70,(a0)
    jeq L10
L7:
    moveq #0,d0
    move.l d0,12(a5)
    move.l #LC0,8(a5)
    move.l -4(a5),a2
    unlk a5
    jra _printf
L10:
    cmp.b #76,1(a0)
    jne L7
    cmp.b #86,2(a0)
    jne L7
    cmp.b #4,3(a0)
    jhi L7
    tst.b 5(a0)
    jne L7
    moveq #0,d1
    move.b 6(a0),d1
    swap d1
    clr.w d1
    moveq #0,d0
    move.b 7(a0),d0
    lsl.l #8,d0
    or.l d1,d0
    or.b 8(a0),d0
    moveq #8,d1
    cmp.l d0,d1
    jcc L7
    moveq #100,d0
    move.l d0,12(a5)
    move.l #LC0,8(a5)
    move.l -4(a5),a2
    unlk a5
    jra _printf 

------------------------------------------------
(CFLAGS -m68000 -S -O3)

#NO_APP
    .text
LC0:
    .ascii "%ld\12\0"
    .even
    .globl  _main
_main:
    link.w a5,#0
    move.l a2,-(sp)
    move.l 8(a5),a2
    jsr ___main
    move.l 4(a2),a0
    cmp.b #70,(a0)
    jeq L10
L7:
    moveq #0,d0
    move.l d0,12(a5)
    move.l #LC0,8(a5)
    move.l -4(a5),a2
    unlk a5
    jra _printf
L10:
    cmp.b #76,1(a0)
    jne L7
    cmp.b #86,2(a0)
    jne L7
    cmp.b #4,3(a0)
    jhi L7
    tst.b 5(a0)
    jne L7
    moveq #0,d1
    move.b 6(a0),d1
    swap d1
    clr.w d1
    moveq #0,d0
    move.b 7(a0),d0
    lsl.l #8,d0
    or.l d1,d0
    or.b 8(a0),d0
    moveq #8,d1
    cmp.l d0,d1
    jcc L7
    moveq #100,d0
    move.l d0,12(a5)
    move.l #LC0,8(a5)
    move.l -4(a5),a2
    unlk a5
    jra _printf 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42522


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug c/42522] [m68k] Wrong code generated with -O2/-O3
  2009-12-28 20:15 [Bug c/42522] New: [m68k] Wrong code generated with -O2/-O3 ami_stuff at o2 dot pl
                   ` (7 preceding siblings ...)
  2009-12-29 18:52 ` nospamname at web dot de
@ 2009-12-31 13:35 ` nospamname at web dot de
  2009-12-31 17:01 ` mikpe at it dot uu dot se
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: nospamname at web dot de @ 2009-12-31 13:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from nospamname at web dot de  2009-12-31 13:35 -------
I compile now with a m68k-elf Compiler and do the small testcode i post
above.The Problem is same on m68k-elf Compiler too.

other CPU as -m68000 fail with -O3 or -O2

So can this Report Reopen and maybe another can check please ?
Andreas have not write with what CPU Setting he get the WORKSFORME Result.

Here is the Output 

m68k-elf-gcc.exe -c wb2.c -o "Default Profile/wb2.o"
-I"E:/amiga/AmiDevCpp/bernd/clib2/"  -m68020-60 -v -S     -O3

Using built-in specs.
COLLECT_GCC=/usr/local/amiga/bin/m68k-elf-gcc
COLLECT_LTO_WRAPPER=/usr/local/amiga/bin/../libexec/gcc/m68k-elf/4.5.0/lto-wrapper.exe
Target: m68k-elf
Configured with: /bernd/gcc4/configure --target=m68k-elf
Thread model: single
gcc version 4.5.0 20091224 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-c' '-o' 'Default Profile/wb2.o'
'-IE:/amiga/AmiDevCpp/bernd/clib2/' '-m68020-60' '-v' '-S' '-O3'

...

GNU C (GCC) version 4.5.0 20091224 (experimental) (m68k-elf)
        compiled by GNU C version 4.3.4 20090804 (release) 1, GMP version
4.2.3, MPFR 

and teh Result of -S is this 

#NO_APP
        .file   "wb2.c"
        .section        .rodata
.LC0:
        .string "%ld\n"
        .text
        .align  2
        .globl  main
        .type   main, @function
main:
        move.l %fp,-(%sp)
        move.l %sp,%fp
        clr.l 12(%fp)
        move.l #.LC0,8(%fp)
        unlk %fp
        jra printf
        .size   main, .-main
        .ident  "GCC: (GNU) 4.5.0 20091224 (experimental)" 

---------------------------

COLLECT_GCC_OPTIONS='-c' '-o' 'Default Profile/wb2.o'
'-IE:/amiga/AmiDevCpp/bernd/clib2/' '-m68000' '-v' '-S' '-O3'

with CPU m68000 or -O1 or -O0 this work ok.

#NO_APP
        .file   "wb2.c"
        .section        .rodata
.LC0:
        .string "%ld\n"
        .text
        .align  2
        .globl  main
        .type   main, @function
main:
        link.w %fp,#0
        move.l 8(%fp),%a0
        move.l 4(%a0),%a0
        cmp.b #70,(%a0)
        jeq .L10
.L7:
        moveq #0,%d0
        move.l %d0,12(%fp)
        move.l #.LC0,8(%fp)
        unlk %fp
        jra printf
.L10:
        cmp.b #76,1(%a0)
        jne .L7
        cmp.b #86,2(%a0)
        jne .L7
        cmp.b #4,3(%a0)
        jhi .L7
        tst.b 5(%a0)
        jne .L7
        moveq #0,%d1
        move.b 6(%a0),%d1
        swap %d1
        clr.w %d1
        moveq #0,%d0
        move.b 7(%a0),%d0
        lsl.l #8,%d0
        or.l %d1,%d0
        or.b 8(%a0),%d0
        moveq #8,%d1
        cmp.l %d0,%d1
        jcc .L7
        moveq #100,%d0
        move.l %d0,12(%fp)
        move.l #.LC0,8(%fp)
        unlk %fp
        jra printf
        .size   main, .-main
        .ident  "GCC: (GNU) 4.5.0 20091224 (experimental)" 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42522


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug c/42522] [m68k] Wrong code generated with -O2/-O3
  2009-12-28 20:15 [Bug c/42522] New: [m68k] Wrong code generated with -O2/-O3 ami_stuff at o2 dot pl
                   ` (8 preceding siblings ...)
  2009-12-31 13:35 ` nospamname at web dot de
@ 2009-12-31 17:01 ` mikpe at it dot uu dot se
  2009-12-31 17:06 ` [Bug target/42522] " jsm28 at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: mikpe at it dot uu dot se @ 2009-12-31 17:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from mikpe at it dot uu dot se  2009-12-31 17:01 -------
Created an attachment (id=19431)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19431&action=view)
simpler test case

I'm attaching a reduced test case that triggers wrong-code for m68k-elf with
gcc-4.5-20091224, every 4.x release, and 3.4.6 (didn't check older releases).

To trigger, compile with -O2 (or higher) and -m68020 (or higher), and observe
how bar() skips all tests and just returns zero.

Any of the following actions mask the bug:
1. reduce optimization level to -O1
2. reduce target cpu type to -m68010 or -m68000
3. remove the "__attribute__((packed))" from "union foo"
4. in bar(), replace "p->d[0]" with "p->d[1]" so that the first and second
memory accesses don't have the same base address

-fno-strict-aliasing makes no difference


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42522


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/42522] [m68k] Wrong code generated with -O2/-O3
  2009-12-28 20:15 [Bug c/42522] New: [m68k] Wrong code generated with -O2/-O3 ami_stuff at o2 dot pl
                   ` (9 preceding siblings ...)
  2009-12-31 17:01 ` mikpe at it dot uu dot se
@ 2009-12-31 17:06 ` jsm28 at gcc dot gnu dot org
  2009-12-31 18:04 ` nospamname at web dot de
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-12-31 17:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from jsm28 at gcc dot gnu dot org  2009-12-31 17:06 -------
Reopening for now.  Please leave the Component as "target"; that is
a much more likely place for the bug than the C front end.


-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
          Component|c                           |target
         Resolution|WORKSFORME                  |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42522


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/42522] [m68k] Wrong code generated with -O2/-O3
  2009-12-28 20:15 [Bug c/42522] New: [m68k] Wrong code generated with -O2/-O3 ami_stuff at o2 dot pl
                   ` (10 preceding siblings ...)
  2009-12-31 17:06 ` [Bug target/42522] " jsm28 at gcc dot gnu dot org
@ 2009-12-31 18:04 ` nospamname at web dot de
  2010-01-17 22:27 ` [Bug rtl-optimization/42522] (zero_extract:SI (mem:QI) ...) misoptimized schwab at linux-m68k dot org
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: nospamname at web dot de @ 2009-12-31 18:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from nospamname at web dot de  2009-12-31 18:04 -------
>3.4.6 (didn't check older releases).

I test now 3.4.0 for m68k-amigaos.The Problem is here too.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42522


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug rtl-optimization/42522] (zero_extract:SI (mem:QI) ...) misoptimized
  2009-12-28 20:15 [Bug c/42522] New: [m68k] Wrong code generated with -O2/-O3 ami_stuff at o2 dot pl
                   ` (11 preceding siblings ...)
  2009-12-31 18:04 ` nospamname at web dot de
@ 2010-01-17 22:27 ` schwab at linux-m68k dot org
  2010-01-17 22:35 ` schwab at linux-m68k dot org
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: schwab at linux-m68k dot org @ 2010-01-17 22:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from schwab at linux-m68k dot org  2010-01-17 22:27 -------
The bug exists since the dawn of time.  The problem is that cse thinks that
(zero_extract:SI (mem:QI ...) ...) is zero if (mem:QI ...) is known to be zero,
but the first argument of zero_extract is only a base address if it is a memory
address.  On m68k this is only generated when STRICT_ALIGNMENT, and the bug was
hidden until e2496245b8453f49bb4428f281af7686be09ddf8:

2000-07-17  Zack Weinberg  <zack@wolery.cumb.org>
        (simplify_ternary_operation):  Do not examine MODE_BITSIZE of
           a CONST_INT, it will always be zero.


-- 

schwab at linux-m68k dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|target                      |rtl-optimization
     Ever Confirmed|0                           |1
 GCC target triplet|m68k-*-*                    |m68k-*-elf
   Last reconfirmed|0000-00-00 00:00:00         |2010-01-17 22:27:47
               date|                            |
            Summary|[m68k] Wrong code generated |(zero_extract:SI (mem:QI)
                   |with -O2/-O3                |...) misoptimized


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42522


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug rtl-optimization/42522] (zero_extract:SI (mem:QI) ...) misoptimized
  2009-12-28 20:15 [Bug c/42522] New: [m68k] Wrong code generated with -O2/-O3 ami_stuff at o2 dot pl
                   ` (12 preceding siblings ...)
  2010-01-17 22:27 ` [Bug rtl-optimization/42522] (zero_extract:SI (mem:QI) ...) misoptimized schwab at linux-m68k dot org
@ 2010-01-17 22:35 ` schwab at linux-m68k dot org
  2010-01-18 10:26 ` rguenth at gcc dot gnu dot org
  2010-05-09 13:54 ` ami_stuff at o2 dot pl
  15 siblings, 0 replies; 17+ messages in thread
From: schwab at linux-m68k dot org @ 2010-01-17 22:35 UTC (permalink / raw)
  To: gcc-bugs



-- 

schwab at linux-m68k dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.3.4 4.4.3
   Target Milestone|---                         |4.4.4


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42522


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug rtl-optimization/42522] (zero_extract:SI (mem:QI) ...) misoptimized
  2009-12-28 20:15 [Bug c/42522] New: [m68k] Wrong code generated with -O2/-O3 ami_stuff at o2 dot pl
                   ` (13 preceding siblings ...)
  2010-01-17 22:35 ` schwab at linux-m68k dot org
@ 2010-01-18 10:26 ` rguenth at gcc dot gnu dot org
  2010-05-09 13:54 ` ami_stuff at o2 dot pl
  15 siblings, 0 replies; 17+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-01-18 10:26 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
      Known to fail|4.3.4 4.4.3                 |4.3.4 4.4.3 4.5.0
   Target Milestone|4.4.4                       |---


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42522


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug rtl-optimization/42522] (zero_extract:SI (mem:QI) ...) misoptimized
  2009-12-28 20:15 [Bug c/42522] New: [m68k] Wrong code generated with -O2/-O3 ami_stuff at o2 dot pl
                   ` (14 preceding siblings ...)
  2010-01-18 10:26 ` rguenth at gcc dot gnu dot org
@ 2010-05-09 13:54 ` ami_stuff at o2 dot pl
  15 siblings, 0 replies; 17+ messages in thread
From: ami_stuff at o2 dot pl @ 2010-05-09 13:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from ami_stuff at o2 dot pl  2010-05-09 13:54 -------
Any chance to see this bug fixed in the near future?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42522


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2010-05-09 13:54 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-28 20:15 [Bug c/42522] New: [m68k] Wrong code generated with -O2/-O3 ami_stuff at o2 dot pl
2009-12-28 20:18 ` [Bug c/42522] " ami_stuff at o2 dot pl
2009-12-28 20:23 ` [Bug target/42522] " pinskia at gcc dot gnu dot org
2009-12-28 20:39 ` [Bug c/42522] " ami_stuff at o2 dot pl
2009-12-28 23:31 ` schwab at linux-m68k dot org
2009-12-28 23:38 ` ami_stuff at o2 dot pl
2009-12-29  1:20 ` ami_stuff at o2 dot pl
2009-12-29 11:58 ` schwab at linux-m68k dot org
2009-12-29 18:52 ` nospamname at web dot de
2009-12-31 13:35 ` nospamname at web dot de
2009-12-31 17:01 ` mikpe at it dot uu dot se
2009-12-31 17:06 ` [Bug target/42522] " jsm28 at gcc dot gnu dot org
2009-12-31 18:04 ` nospamname at web dot de
2010-01-17 22:27 ` [Bug rtl-optimization/42522] (zero_extract:SI (mem:QI) ...) misoptimized schwab at linux-m68k dot org
2010-01-17 22:35 ` schwab at linux-m68k dot org
2010-01-18 10:26 ` rguenth at gcc dot gnu dot org
2010-05-09 13:54 ` ami_stuff at o2 dot pl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).