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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to