<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - strange optimization for cos(cos(20)) with math.h but not cmath"
href="https://bugs.llvm.org/show_bug.cgi?id=34240">34240</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>strange optimization for cos(cos(20)) with math.h but not cmath
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>xaxxon@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Recursive call with cos(cos(20)) in the body is reduced to no-op with cmath but
with math.h the generated code makes the recursive calls.
With only cos(20) both headers result in the generated code being a no-op.
#include <math.h>
void recurseTest(int level){
for(int i =0; i < 15; i++){
cos(cos(20));
recurseTest(level +1);
}
}
Strange behavior with math.h:
<a href="https://godbolt.org/g/y9gZW7">https://godbolt.org/g/y9gZW7</a>
Desired behavior with cmath instead:
<a href="https://godbolt.org/g/rh9BMg">https://godbolt.org/g/rh9BMg</a>
Desired behavior with math.h and only cos(20) not cos(cos(20))
<a href="https://godbolt.org/g/tn6EDg">https://godbolt.org/g/tn6EDg</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>