[prev in list] [next in list] [prev in thread] [next in thread]
List: llvm-bugs
Subject: [llvm-bugs] [Bug 39112] New: incorrect optimization with signaling NaN and implicit conversion in fa
From: via llvm-bugs <llvm-bugs () lists ! llvm ! org>
Date: 2018-09-28 11:48:14
Message-ID: bug-39112-206 () http ! bugs ! llvm ! org/
[Download RAW message or body]
--1538135294.372A0.17941
Date: Fri, 28 Sep 2018 04:48:14 -0700
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://bugs.llvm.org/
Auto-Submitted: auto-generated
https://bugs.llvm.org/show_bug.cgi?id=39112
Bug ID: 39112
Summary: incorrect optimization with signaling NaN and implicit
conversion in fabs: missing exception
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs@nondot.org
Reporter: vincent-llvm@vinc17.net
CC: llvm-bugs@lists.llvm.org
With a code that does something like
float f = fabs (double_snan)
one does not get the FE_INVALID exception with -O.
Details:
#include <stdio.h>
#include <inttypes.h>
#include <math.h>
#include <fenv.h>
typedef union { float f; uint32_t i; } ieee_float_t;
int main (void)
{
volatile ieee_float_t x, y;
volatile double d;
x.i = 0x7f800001;
printf ("0. %x (%g)\n", x.i, x.f);
feclearexcept (FE_INVALID);
y.f = fabs (x.f);
if (fetestexcept (FE_INVALID))
printf ("2. FE_INVALID\n");
printf ("2. %x (%g)\n", y.i, y.f);
return 0;
}
yields:
cventin% clang-8 snan.c -o snan -lm
cventin% ./snan
0. 7f800001 (nan)
2. FE_INVALID
2. 7fc00001 (nan)
which is correct (due to the float-to-double conversion of sNaN), but
cventin% clang-8 snan.c -o snan -lm -O
cventin% ./snan
0. 7f800001 (nan)
2. 7f800001 (nan)
The FE_INVALID exception is missing, and the result is a signaling NaN instead
of a quiet NaN.
Tested with the clang-8 1:8~svn342638-1 Debian package (x86_64 architecture).
--
You are receiving this mail because:
You are on the CC list for the bug.
--1538135294.372A0.17941
Date: Fri, 28 Sep 2018 04:48:14 -0700
MIME-Version: 1.0
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://bugs.llvm.org/
Auto-Submitted: auto-generated
<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 - incorrect optimization with signaling NaN and implicit conversion in \
fabs: missing exception" \
href="https://bugs.llvm.org/show_bug.cgi?id=39112">39112</a> </td>
</tr>
<tr>
<th>Summary</th>
<td>incorrect optimization with signaling NaN and implicit conversion in \
fabs: missing exception </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>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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>vincent-llvm@vinc17.net
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>With a code that does something like
float f = fabs (double_snan)
one does not get the FE_INVALID exception with -O.
Details:
#include <stdio.h>
#include <inttypes.h>
#include <math.h>
#include <fenv.h>
typedef union { float f; uint32_t i; } ieee_float_t;
int main (void)
{
volatile ieee_float_t x, y;
volatile double d;
x.i = 0x7f800001;
printf ("0. %x (%g)\n", x.i, x.f);
feclearexcept (FE_INVALID);
y.f = fabs (x.f);
if (fetestexcept (FE_INVALID))
printf ("2. FE_INVALID\n");
printf ("2. %x (%g)\n", y.i, y.f);
return 0;
}
yields:
cventin% clang-8 snan.c -o snan -lm
cventin% ./snan
0. 7f800001 (nan)
2. FE_INVALID
2. 7fc00001 (nan)
which is correct (due to the float-to-double conversion of sNaN), but
cventin% clang-8 snan.c -o snan -lm -O
cventin% ./snan
0. 7f800001 (nan)
2. 7f800001 (nan)
The FE_INVALID exception is missing, and the result is a signaling NaN instead
of a quiet NaN.
Tested with the clang-8 1:8~svn342638-1 Debian package (x86_64 architecture).</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>
--1538135294.372A0.17941--
[Attachment #3 (text/plain)]
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic