[LLVMbugs] [Bug 16891] New: Optimization bug with -Ofast

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Aug 14 15:23:15 PDT 2013


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

            Bug ID: 16891
           Summary: Optimization bug with -Ofast
           Product: clang
           Version: 3.3
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: neotron at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 11036
  --> http://llvm.org/bugs/attachment.cgi?id=11036&action=edit
Example program showing the issue.

This bug appears when compiling for iOS Simulator or iOS device using this
Clang version:

Apple LLVM version 5.0 (clang-500.1.63) (based on LLVM 3.3svn)


When compiling with -Ofast, a specific loop produces incorrect resuls. Works
with -Os. It appears that the optimizer believes a long value bitor another
long value shifted by 32 results in -1 instead of just remaining the same value
as you started with. The attached code works if both "long" are replaced with
int64_t.

Steps to Reproduce:

Compile attached code with:

clang -arch i386 -Os ~/bug.cpp -o bugopts 

to get this result:

Val = 1, byte = 1
Val = 5633, byte = 22
Val = 5633, byte = 0
Val = 5633, byte = 0
Val = 5633, byte = 0
Val = 5633, byte = 0
Val = 5633, byte = 0
Val = 5633, byte = 0
Value is 5633

Use this:

clang -arch i386 -Ofast ~/bug.cpp -o bugoptfast 

and you get this result:

Val = 1, byte = 1
Val = 5633, byte = 22
Val = 5633, byte = 0
Val = 5633, byte = 0
Val = -1, byte = 0
Val = -1, byte = 0
Val = -1, byte = 0
Val = -1, byte = 0
Value is 0

Also logged with Apple as issue  14739667

-- 
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/20130814/4cce3e32/attachment.html>


More information about the llvm-bugs mailing list