https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67781

            Bug ID: 67781
           Summary: Wrong code generated on mips32 with -O1
                    -fexpensive-optimizations
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jdboyer at media5corp dot com
  Target Milestone: ---

Created attachment 36422
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36422&action=edit
Test program that shows the problem

I'm using a custom build of gcc 5.2.0, for cross-compiling on mips32. It was
generated on a Centos 7 x86_64 system (gcc 4.8.2).

The configuration was done using the following arguments:
  --target=mips-linux --enable-tls --with-arch=mips32 --with-float=soft

Then, if I use the generated compiler to compile the attached program
"shift.c", the result will be wrong when using -O2, but good when using -O1.

More precisely, the argument -fexpensive-optimizations is most probably the
cause. Let's say I compile the program like this:

  mips-linux-gcc shift.c -o shift -O1 -fexpensive-optimizations

If I execute the program in the embedded system, the result is wrong:

  [root@10.11.254.210 jdboyer]# ./shift
  123456

If I compile it like this instead:

  mips-linux-gcc shift.c -o shift -O2 -fno-expensive-optimizations

The result is good:

  [root@10.11.254.210 jdboyer]# ./shift
  12345678

Reply via email to