This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/32406] New: [4.3 Regression] MIPS: FAIL in nestfunc-6.c at -O3


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]