[LLVMbugs] [Bug 16464] New: wrong code at -O3 on x86_64-linux-gnu in 32-bit mode

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jun 26 00:10:56 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16464

            Bug ID: 16464
           Summary: wrong code at -O3 on x86_64-linux-gnu in 32-bit mode
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The following code is miscompiled by current clang trunk (as well as clang 3.2
and 3.3) on x86_64-linux-gnu at -O3 in 32-bit mode, resulting in a SIGFPE. This
is likely related to 16463, which manifests in both 32-bit and 64-bit modes. 

$ clang-trunk -v
clang version 3.4 (trunk 184829)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ clang-trunk -m32 -O2 reduced.c
$ a.out
$ clang-trunk -m32 -O3 reduced.c
$ a.out
Floating point exception (core dumped)
$ clang-3.3 -m32 -O3 reduced.c
$ a.out
Floating point exception (core dumped)
$ clang-3.2 -m32 -O3 reduced.c
$ a.out
Floating point exception (core dumped)
$
$ clang-trunk -m64 -O3 reduced.c
$ a.out
$ 


------------------------------------------------

int a, b, c, d, e, f;

int fn1 (int p)
{
  return p < 0 ? 0 : -p;
}

int fn2 (long long p, int q)
{
  return p && q && p > q ? 0 : p + 1;
}

int fn3 (int p)
{
  for (;;) { 
    e = (p == 0 ? 0 : 1 / p);
    for (c = 0; c < 1; c = a) { 
      f = fn2 (fn1(--e), p);
      if (b)
    return 0;
    }
  }
}

int main ()
{
  b++;
  fn3 (1 & d);
  return 0;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130626/684d045b/attachment.html>


More information about the llvm-bugs mailing list