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 c/28726] New: -fsched2-use-superblock produces wrong code


-fsched2-use-superblocks fails to order loop operations and loop jump
instruction correctly. The following example will show that
-fsched2-use-superblocks causes generation of wrong code.

Steps to reproduce:
Compile
>>>
#include <string.h>
#include <stdio.h>

int main()
{
        double retval = 0.0;
        const unsigned char *start = "\005\b\000";
        unsigned int len = strlen(start);
        const unsigned char *const end = start + len;
        while (start < end) {
            retval += *(start++);
        }
        printf("%lf\n", retval);
        return 0;
}
<<<
with -O2 -fsched2-use-superblocks -> Observe that 8.000 is printed (incorrect)
and with -O2 -> Observe that 13.000 is printed (correct)
Examining the generated assemblies, it shows that the loop does not include
the add operation:
>>> (loop code for -O2 -fsched2-use-superblocks)
.L10:
        fstp    %st(0)
.L5:
        movzbl  (%edx), %eax
        incl    %edx
        pushl   %eax
        fildl   (%esp)
        addl    $4, %esp
        cmpl    %edx, %ecx
        ja      .L10          <- this seems one instruction to early
        faddp   %st, %st(1)      
<<<
I'm not much into assembly, but i thought you might want to have a look at it.


-- 
           Summary: -fsched2-use-superblock produces wrong code
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sg313d at gmail dot com
 GCC build triplet: gcc-4.1.1/vanilla
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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