<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:spatel+llvm@rotateright.com" title="Sanjay Patel <spatel+llvm@rotateright.com>"> <span class="fn">Sanjay Patel</span></a>
</span> changed
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - gvn badly replaces a call to fptosi"
href="http://llvm.org/bugs/show_bug.cgi?id=21130">bug 21130</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">Status</td>
<td>NEW
</td>
<td>RESOLVED
</td>
</tr>
<tr>
<td style="text-align:right;">CC</td>
<td>
</td>
<td>spatel+llvm@rotateright.com
</td>
</tr>
<tr>
<td style="text-align:right;">Resolution</td>
<td>---
</td>
<td>INVALID
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - gvn badly replaces a call to fptosi"
href="http://llvm.org/bugs/show_bug.cgi?id=21130#c3">Comment # 3</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - gvn badly replaces a call to fptosi"
href="http://llvm.org/bugs/show_bug.cgi?id=21130">bug 21130</a>
from <span class="vcard"><a class="email" href="mailto:spatel+llvm@rotateright.com" title="Sanjay Patel <spatel+llvm@rotateright.com>"> <span class="fn">Sanjay Patel</span></a>
</span></b>
<pre>Both the LLVM Language Ref and the C standard (annex F.4) say that the code is
undefined, so anything goes:
fptosi:
"If the value won’t fit in the integer type, the results are undefined."
C - floating to integer conversion:
"...if the integral part of the floating value exceeds the range of the integer
type, then the "invalid" floating-point exception is raised and the resulting
value is unspecified."
Try using lrint()?
Clang does issue warnings when it's obvious that there's a conversion problem:
$ cat 21130.c
char foo() { return 156.0; }
$ ./clang 21130.c -c
21130.c:3:12: warning: implicit conversion from 'double' to 'char' changes
value from 156 to 127 [-Wliteral-conversion]
return 156.0;
~~~~~~ ^~~~~
1 warning generated.
...but your C test case is probably too complicated for that check.</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>