<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 - llvm.minnum and llvm.maxnum do not handle -0.0 as required by IEEE-754"
href="https://bugs.llvm.org/show_bug.cgi?id=49886">49886</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>llvm.minnum and llvm.maxnum do not handle -0.0 as required by IEEE-754
</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>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Common Code Generator Code
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>chiovolonit@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Note: this applies for both `llvm.minnum` and `llvm.maxnum`, although for the
most part I'm just going to talk about the min case — both have this bug,
though.
The documentation for `llvm.minnum.*` says:
<span class="quote">> Follows the IEEE-754 semantics for minNum, except for handling of signaling
> NaNs</span >
But it goes on to say
<span class="quote">> If the operands compare equal, returns a value that compares equal to both
> operands. This means that fmin(+/-0.0, +/-0.0) could return either -0.0 or
> 0.0.</span >
These two statements are in contradiction, at as of IEEE-754 2019 (section 9.6,
"Minimum and maximum operations"), which states:
<span class="quote">> minimumNumber(x, y) is `x` if `x<y`, `y` if `y < x`, and the number if one
> operand is a number and the other is a NaN. For this operation, −0 compares
> less than +0. If `x = y` and signs are the same it is either `x` or `y`. If
> both operands are NaNs, a quiet NaN is returned, according to 6.2. If either
> operand is a signaling NaN, an invalid operation exception is signaled, but
> unless both operands are NaNs, the signaling NaN is otherwise ignored and
> not converted to a quiet NaN as stated in 6.2 for other operations.</span >
In particular, "For this operation, −0 compares less than +0".
In Rust (<a href="https://github.com/rust-lang/rust/issues/83984">https://github.com/rust-lang/rust/issues/83984</a>) we use `llvm.minnum`
and `llvm.maxnum` for our normal float min/max operations, and would like these
to be compliant with the IEEE-754 functions, with respect to -0.0.
Alternatively, if this cannot be fixed, it would be nice to have a pair of set
of min/max functions that do implement the IEEE754 semantics (and also probably
update the documentation to say that the handling of -0.0 differs from IEEE-754
as well)
P.S. We cannot use `llvm.minimum` — While it would handle -0.0 properly, they
handle NaNs completely differently, and we've documented the current "returns
non-NaN for NaN input" behavior
P.P.S. I had no clue what component to put this under, sorry.</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>