<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 --- - No optimization of 'round' when arguments are known constants."
href="https://llvm.org/bugs/show_bug.cgi?id=31478">31478</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>No optimization of 'round' when arguments are known constants.
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>3.9
</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>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>brunojimen@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Hi,
When checking the assembly output of a program I discovered that calls to
'round' wouldn't get optimized away when the argument is a known constant.
For example, with this little test case (the printf is there so the compiler
wouldn't just remove the call to round)
#include <stdio.h>
#include <math.h>
int main(int argc, char *argv[])
{
printf("%lf\n",round(0.9));
return 0;
}
using `clang -O2 -S` I get that there's a call to round in the assembly, while
`gcc -O2 -S` can remove the call to round.
More interesting is the case with '1.' instead of '0.9', in which the assembly
shows '1.' as float, a call to roundf and a conversion from float to double.
This may be a duplicate of <a class="bz_bug_link
bz_status_NEW "
title="NEW --- - simplifylibcalls should optimize various floating point rounding utilities like lround or lrintf"
href="show_bug.cgi?id=22944">https://llvm.org/bugs/show_bug.cgi?id=22944</a> but that
is about simplifying the calls, while this is about constant propagation.
Thanks in advance!</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>