<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 --- - Inconsistent behavior in FP_TO_UINT compared to gcc-4.9"
href="https://llvm.org/bugs/show_bug.cgi?id=24805">24805</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Inconsistent behavior in FP_TO_UINT compared to gcc-4.9
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>Backend: AArch64
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>koviankevin@hotmail.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>Consider the following test case:
==========================================================
#include <stdio.h>
unsigned char a = 255;
double b = 18;
int main() {
printf("%d", a *= b);
return 0;
}
==========================================================
command: clang -target aarch64 -O2 test.c
The output is 4590 in clang, but 238 in GCC4.9
I'm not sure it is a bug or just an undefined behavior, since the value if the
fp is larger than range of i8
I found that the node (i8 = FP_TO_UINT f64) is promoted to
(i32 = FP_TO_SINT f64) + (i32 = AssertZext i8) in
DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT
And the AssertZExt node is combined with the AND node(for zero extend
operation) after that when DAG combining since the DAGCombiner assumes the bit9
to bit31 of AssertZExt node are zeros.
As a result, the value is not truncated to i8.</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>