<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Optimization bug with -Ofast"
href="http://llvm.org/bugs/show_bug.cgi?id=16891">16891</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Optimization bug with -Ofast
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.3
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>neotron@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=11036" name="attach_11036" title="Example program showing the issue.">attachment 11036</a> <a href="attachment.cgi?id=11036&action=edit" title="Example program showing the issue.">[details]</a></span>
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</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>