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/45695] New: -O1 wrong-code by cmove


FSF GDB HEAD by FSF GCC 4.5.HEAD errors on `print 0|0' with -O1 and higher.

source below compiles to:
0000000000400455 <f>:
  400455:       53                      push   %rbx
  400456:       39 fa                   cmp    %edi,%edx
  400458:       0f 44 de                cmove  %esi,%ebx

but $ebx is left uninitialized for not-equal comparison.

Compilation flags: -O1
it passes = exit code 0 = with -O0
it fails  = exit code 1 = with -O1

PASS: gcc (GCC) 4.4.5 20100916 (prerelease)
FAIL: gcc (GCC) 4.5.2 20100916 (prerelease)
PASS: gcc (GCC) 4.6.0 20100916 (experimental)
FAIL: gcc-4.5.1-3.fc14.x86_64
not re-verified but PASS: gcc-4.5.1-1.fc14.x86_64


__attribute__((noinline, noclone)) void
g (int x)
{ 
  asm volatile ("");
}
__attribute__((noinline, noclone)) int
f (int a, int b, int d)
{
  int r = -1;
  b += d;
  if (d == a)
    r = b - d;
  g (b);
  return r; 
}
int 
main (void)
{ 
  asm volatile ("mov $42, %%rbx" : : : "rbx");
  return f (0, 1, 4) == 42 ? 1 : 0;
}


-- 
           Summary: -O1 wrong-code by cmove
           Product: gcc
           Version: 4.5.2
            Status: UNCONFIRMED
          Severity: blocker
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jan dot kratochvil at redhat dot com
GCC target triplet: x86_64-unknown-linux-gnu


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


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