[LLVMbugs] [Bug 8542] New: Clang miscompiles valid code with -O2 on x86 and x86-64

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Nov 3 14:03:19 PDT 2010


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

           Summary: Clang miscompiles valid code with -O2 on x86 and
                    x86-64
           Product: clang
           Version: 2.8
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: lloyd at randombit.net
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=5726)
 --> (http://llvm.org/bugs/attachment.cgi?id=5726)
Testcase

Attached is a simple test case which clang 2.8 miscompiles on x86 and x86-64
with -O2 or higher (I have not traced down the specific optimization flag which
causes the problem). With GCC or ICC (any optimization level) or Clang 2.8 with
-O0 or -O1, the output is

61000000

with Clang and -O2/-O3, it is:

F9000000

I've tried to minimize the test case as much as possible; it was extracted from
real code.

Interestingly, changing
   W &= rotate_right(0x00FFFFFF, 0);
to just
   W &= 0x00FFFFFFF;

on line 36

the miscompilation goes away (actually removing this rotation is is not
possible in the original source, which runs this in a loop with varying byte
offsets).

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list