<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.experimental.vector.reduce.{fmin,fmax} incorrect for vectors with NaN in the last place"
   href="https://bugs.llvm.org/show_bug.cgi?id=36982">36982</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>llvm.experimental.vector.reduce.{fmin,fmax} incorrect for vectors with NaN in the last place
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>gonzalobg88@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>On x86_64:

define float @example::foo(<2 x float>* noalias nocapture readonly
dereferenceable(8) %x) unnamed_addr #0 {
  %0 = load <2 x float>, <2 x float>* %x, align 8
  %1 = tail call float @llvm.experimental.vector.reduce.fmin.f32.v2f32(<2 x
float> %0)
  ret float %1
}

lowers to:

example::foo:
  movq xmm0, qword ptr [rdi]
  pshufd xmm1, xmm0, 229
  minps xmm0, xmm1
  ret

which for the following inputs produces the respective outputs:

 * <1.0, -1.0> => -1.0
 * <NaN, -1.0> => -1.0
 * <-1.0, NaN> => NaN

I think this is basically equivalent to a vector fcmp + select, but the default
semantics of the reductions (that is, without math flags) should be that of
minnum/maxnum. 

The llvm.experimental.vector.reduce.fmin/fmax intrinsics do not specify their
semantics in the reference, so it is hard to tell whether the current behavior
is intended or an oversight.

This bug is Rust's bug: <a href="https://github.com/rust-lang-nursery/stdsimd/issues/408">https://github.com/rust-lang-nursery/stdsimd/issues/408</a></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>