public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/39194]  New: options -O3 and -msse does not cooperate ?
@ 2009-02-14 18:49 oystein at gnubg dot org
  2009-02-14 19:24 ` [Bug target/39194] " rguenth at gcc dot gnu dot org
  2009-02-16  7:41 ` ubizjak at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: oystein at gnubg dot org @ 2009-02-14 18:49 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3233 bytes --]

Hi,

I try the following code:

#define MAX_N 40
#define MAX_R 25

#ifndef FALSE
#define FALSE 0
#define TRUE 1
#endif

static unsigned int bin_coeff_tab[ MAX_N ][ MAX_R ];
static int is_calculated = FALSE;

static void
bin_coeff_init( void ) 
{

    int i, j;

    for( i = 0; i < MAX_N; i++ )
        bin_coeff_tab[ i ][ 0 ] = i + 1;

    for( j = 1; j < MAX_R; j++ )
        bin_coeff_tab[ 0 ][ j ] = 0;

    for( i = 1; i < MAX_N; i++ )
        for( j = 1; j < MAX_R; j++ )
            bin_coeff_tab[ i ][ j ] = bin_coeff_tab[ i - 1 ][ j - 1 ] +
                bin_coeff_tab[ i - 1 ][ j ];

    is_calculated = TRUE;
}
int main()
{
        bin_coeff_init();
        return 0;
}

(There is no header file included, so I won't include the .i file)

If I try to compile this with both -O3 and -msse, I get a segmentation fault.

> gcc --version
gcc (GCC) 4.3.0 20080305 (alpha-testing) mingw-20080502

the assembler code file becomes:

        .file   "mytest.c"
        .def    ___main;        .scl    2;      .type   32;     .endef
        .text
        .p2align 2,,3
.globl _main
        .def    _main;  .scl    2;      .type   32;     .endef
_main:
        leal    4(%esp), %ecx
        andl    $-16, %esp
        pushl   -4(%ecx)
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %esi
        pushl   %ebx
        pushl   %ecx
        subl    $12, %esp
        call    ___main
        movl    $_bin_coeff_tab, %edx
        xorl    %eax, %eax
        .p2align 2,,3
L2:
        incl    %eax
        movl    %eax, (%edx)
        addl    $100, %edx
        cmpl    $40, %eax
        jne     L2
        movl    $0, _bin_coeff_tab+4
        movl    $0, _bin_coeff_tab+8
        movl    $0, _bin_coeff_tab+12
        xorps   %xmm0, %xmm0
        movaps  %xmm0, _bin_coeff_tab+16
        movaps  %xmm0, _bin_coeff_tab+32
        movaps  %xmm0, _bin_coeff_tab+48
        movaps  %xmm0, _bin_coeff_tab+64
        movaps  %xmm0, _bin_coeff_tab+80
        movl    $0, _bin_coeff_tab+96
        movl    $1, %esi
        .p2align 2,,3
L3:
        leal    (%esi,%esi,4), %eax
        leal    (%eax,%eax,4), %eax
        leal    _bin_coeff_tab-100(,%eax,4), %edx
        leal    _bin_coeff_tab+4(,%eax,4), %ebx
        movl    $1, %ecx
        .p2align 2,,3
L4:
        movl    4(%edx), %eax
        addl    (%edx), %eax
        movl    %eax, (%ebx)
        incl    %ecx
        addl    $4, %edx
        addl    $4, %ebx
        cmpl    $25, %ecx
        jne     L4
        incl    %esi
        cmpl    $40, %esi
        jne     L3
        movl    $1, _is_calculated
        xorl    %eax, %eax
        addl    $12, %esp
        popl    %ecx
        popl    %ebx
        popl    %esi
        leave
        leal    -4(%ecx), %esp
        ret
.lcomm _is_calculated,16
.lcomm _bin_coeff_tab,4000

Best regards,
-Øystein


-- 
           Summary: options -O3 and -msse does not cooperate ?
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: oystein at gnubg dot org
  GCC host triplet: windows (mingw)


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


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

* [Bug target/39194] options -O3 and -msse does not cooperate ?
  2009-02-14 18:49 [Bug c/39194] New: options -O3 and -msse does not cooperate ? oystein at gnubg dot org
@ 2009-02-14 19:24 ` rguenth at gcc dot gnu dot org
  2009-02-16  7:41 ` ubizjak at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-02-14 19:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2009-02-14 19:24 -------
I suppose _bin_coeff_tab is not properly aligned.  Maybe PE support is not
properly honoring DECL_ALIGN.  Please try also GCC 4.3.3 which has many
bugfixes compared to 4.3.0.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |target
   GCC host triplet|windows (mingw)             |
 GCC target triplet|                            |mingw32-*-*
           Keywords|                            |wrong-code


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


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

* [Bug target/39194] options -O3 and -msse does not cooperate ?
  2009-02-14 18:49 [Bug c/39194] New: options -O3 and -msse does not cooperate ? oystein at gnubg dot org
  2009-02-14 19:24 ` [Bug target/39194] " rguenth at gcc dot gnu dot org
@ 2009-02-16  7:41 ` ubizjak at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: ubizjak at gmail dot com @ 2009-02-16  7:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from ubizjak at gmail dot com  2009-02-16 07:41 -------
You can workaround this generic PE/COFF problem using -fno-common.

*** This bug has been marked as a duplicate of 37216 ***


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


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

end of thread, other threads:[~2009-02-16  7:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-14 18:49 [Bug c/39194] New: options -O3 and -msse does not cooperate ? oystein at gnubg dot org
2009-02-14 19:24 ` [Bug target/39194] " rguenth at gcc dot gnu dot org
2009-02-16  7:41 ` ubizjak at gmail dot com

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