<html>
<head>
<base href="https://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 --- - bad code generated code for branches (&, &&)" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23827&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=VF9cKMK37QU5uZVhcTbVLMWd2UAFicSigFxIL3NBQZM&s=umrSuzL-hju8xG-9vzsTH0t1RQUpSnIjlsjlc8Tmq7w&e=">23827</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>bad code generated code for branches (&, &&)
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>fkastrati@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>consider the following code snippet (c++):
void ampamp(int x, int y) {
if (x < 3 && y > 10 )
printf("%d%d", x, y);
}
void amp(int x, int y) {
if ((x < 3) & (y > 10) )
printf("%d%d", x, y);
}
the assembly code generated by clang++ (all versions I tested), is not optimal.
Basically, for both methods the assembly code is identical. For the method
"amp" (with single `&') there should be generated only one jump, as branch
misprediction penalty is very high otherwise
As a side note: the code by intel's compiler (ICC) is however generating
optimal code for such scenarios, at least for versions icc13, and icc15 that
I've tested.
See: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__goo.gl_oiTPX5&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=VF9cKMK37QU5uZVhcTbVLMWd2UAFicSigFxIL3NBQZM&s=EOFBNcIjT_xwINx395SxU7c_HdjTstjc5l0ha3DYoXU&e=">http://goo.gl/oiTPX5</a></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>