public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/32406]  New: [4.3 Regression] MIPS: FAIL in nestfunc-6.c at -O3
@ 2007-06-19 17:53 daney at gcc dot gnu dot org
  2007-06-20  2:53 ` [Bug target/32406] " hp at gcc dot gnu dot org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: daney at gcc dot gnu dot org @ 2007-06-19 17:53 UTC (permalink / raw)
  To: gcc-bugs

Build from svn r125825 with:
http://gcc.gnu.org/viewcvs?view=rev&revision=125852
applied.

Configured: ../trunk/configure --target=mipsel-linux
--with-sysroot=/usr/local/mipsel-linux-test
--prefix=/usr/local/mipsel-linux-test --with-arch=mips32 --with-float=soft
--disable-java-awt --without-x --disable-tls --enable-__cxa_atexit
--disable-jvmpi --disable-libmudflap --enable-languages=c,c++

gcc.c-torture/execute/nestfunc-6.c is FAILing at -O2, -O3, and -Os.  This is a
regression from:

http://gcc.gnu.org/ml/gcc-testresults/2007-06/msg00546.html

This is the test case:
-----------------------
typedef __SIZE_TYPE__ size_t;
extern void abort (void);
extern void exit (int);
extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));

int main ()
{
  __label__ nonlocal;
  int compare (const void *a, const void *b)
  {
    goto nonlocal;
  }

  char array[3];
  qsort (array, 3, 1, compare);
  abort ();

 nonlocal:
  exit (0);
}
------------------------------------------------

Here is the generated assembly:
 /home/daney/gccsvn/mipsel-trunk/gcc/xgcc
-B/home/daney/gccsvn/mipsel-trunk/gcc/ -O3 -S nestfunc-6.c
-------------------------------
        .file   1 "nestfunc-6.c"
        .section .mdebug.abi32
        .previous
        .abicalls
        .rdata
        .align  2
$LTRAMP0:
        .word   0x03e00821              # move   $1,$31
        .word   0x04110001              # bgezal $0,.+8
        .word   0x00000000              # nop
        .word   0x8fe30014              # lw     $3,20($31)
        .word   0x8fe20018              # lw     $2,24($31)
        .word   0x0060c821              # move   $25,$3
        .word   0x00600008              # jr     $3
        .word   0x0020f821              # move   $31,$1
        .word   0x00000000              # <function address>
        .word   0x00000000              # <static chain value>
        .globl  _flush_cache
        .text
        .align  2
        .globl  main
        .ent    main
        .type   main, @function
main:
        .frame  $sp,96,$31              # vars= 64, regs= 2/0, args= 16, gp= 8
        .mask   0xc0000000,-4
        .fmask  0x00000000,0
        .set    noreorder
        .set    nomacro

        lui     $28,%hi(__gnu_local_gp)
        addiu   $sp,$sp,-96
        addiu   $28,$28,%lo(__gnu_local_gp)
        sw      $31,92($sp)
        sw      $fp,88($sp)
        .cprestore      16
        lui     $2,%hi($LTRAMP0)
        addiu   $6,$2,%lo($LTRAMP0)
        addiu   $3,$sp,40
        addiu   $2,$sp,24
        sw      $2,84($sp)
        sw      $3,80($sp)
        sw      $2,28($sp)
        sw      $sp,32($sp)
        move    $7,$3
        addiu   $8,$6,32
$L2:
        lw      $2,0($6)
        lw      $3,4($6)
        lw      $4,8($6)
        lw      $5,12($6)
        addiu   $6,$6,16
        sw      $2,0($7)
        sw      $3,4($7)
        sw      $4,8($7)
        sw      $5,12($7)
        bne     $6,$8,$L2
        addiu   $7,$7,16

        lw      $2,4($6)
        lw      $4,0($6)
        sw      $2,4($7)
        sw      $4,0($7)
        lw      $2,80($sp)
        lui     $3,%hi(compare.1584)
        addiu   $3,$3,%lo(compare.1584)
        sw      $3,32($2)
        lw      $3,80($sp)
        addiu   $2,$sp,28
        sw      $2,36($3)
        lw      $25,%call16(_flush_cache)($28)
        lw      $4,80($sp)
        li      $5,40                   # 0x28
        jalr    $25
        li      $6,3                    # 0x3

        lw      $28,16($sp)
        lw      $4,84($sp)
        lw      $25,%call16(qsort)($28)
        lw      $7,80($sp)
        li      $5,3                    # 0x3
        jalr    $25
        li      $6,1                    # 0x1

        lw      $28,16($sp)
        lw      $25,%call16(abort)($28)
        jalr    $25
        nop

$L3:
$L4:
        lw      $25,%call16(exit)($28)
        jalr    $25
        move    $4,$0

        .set    macro
        .set    reorder
        .end    main
        .align  2
        .ent    compare.1584
        .type   compare.1584, @function
compare.1584:
        .frame  $fp,8,$31               # vars= 0, regs= 1/0, args= 0, gp= 0
        .mask   0x40000000,-8
        .fmask  0x00000000,0
        .set    noreorder
        .set    nomacro

        addiu   $sp,$sp,-8
        sw      $fp,0($sp)
        lw      $fp,0($2)
        lw      $sp,4($2)
        lui     $2,%hi($L3)
        addiu   $2,$2,%lo($L3)
        j       $2
        nop

        .set    macro
        .set    reorder
        .end    compare.1584
        .ident  "GCC: (GNU) 4.3.0 20070618 (experimental)"
------------------------------------------------

Note that $gp ($28) is not restored at $L3 where it is used.  The compare
function does 'goto nonlocal;' which is a jump to $L3, but $gp will have the
wrong value and must be restored.

This worked before the dataflow merge because the compare function would load
$gp (unnecessarily).

I think the fix is to load $gp at $L3.


-- 
           Summary: [4.3 Regression] MIPS: FAIL in nestfunc-6.c at -O3
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: daney at gcc dot gnu dot org
 GCC build triplet: mipsel-linux-gnu
  GCC host triplet: mipsel-linux-gnu
GCC target triplet: mipsel-linux-gnu


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


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

end of thread, other threads:[~2007-11-28 19:49 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-19 17:53 [Bug target/32406] New: [4.3 Regression] MIPS: FAIL in nestfunc-6.c at -O3 daney at gcc dot gnu dot org
2007-06-20  2:53 ` [Bug target/32406] " hp at gcc dot gnu dot org
2007-06-20  7:12 ` daney at gcc dot gnu dot org
2007-06-20 12:56 ` richard at codesourcery dot com
2007-06-22  4:55 ` daney at gcc dot gnu dot org
2007-09-29 22:44 ` daney at gcc dot gnu dot org
2007-11-11  6:29 ` daney at gcc dot gnu dot org
2007-11-11  6:33 ` daney at gcc dot gnu dot org
2007-11-11  6:34 ` daney at gcc dot gnu dot org
2007-11-11  7:05 ` daney at gcc dot gnu dot org
2007-11-11 10:07 ` rsandifo at gcc dot gnu dot org
2007-11-11 10:16 ` rsandifo at nildram dot co dot uk
2007-11-27  5:48 ` mmitchel at gcc dot gnu dot org
2007-11-28 19:46 ` rsandifo at gcc dot gnu dot org
2007-11-28 19:49 ` rsandifo at gcc dot gnu dot org

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).