<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 - vector approximate reciprocal square root generates bad code on x86"
   href="https://bugs.llvm.org/show_bug.cgi?id=37344">37344</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>vector approximate reciprocal square root generates bad code on x86
          </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>The following LLVM IR (see it live: <a href="https://godbolt.org/g/88kuky">https://godbolt.org/g/88kuky</a>) computes the
approximate vector reciprocal square root rsqrt(x) ~= 1/ sqrt(x):

declare <4 x float> @llvm.sqrt.v4f32(<4 x float>)
define <4 x float> @rsqrt(<4 x float>)  {
  %a = call afn <4 x float> @llvm.sqrt.v4f32(<4 x float> %0)
  %c = fdiv <4 x float> <float 1.000000e+00, float 1.000000e+00, float
1.000000e+00, float 1.000000e+00>, %a
  ret <4 x float> %c
}

On x86_64 with -O3 and sse4.2 they generate the following assembly:

LCPI0_0:
  .long 1065353216 # float 1
  .long 1065353216 # float 1
  .long 1065353216 # float 1
  .long 1065353216 # float 1
rsqrt: # @rsqrt
  sqrtps xmm1, xmm0
  movaps xmm0, xmmword ptr [rip + .LCPI0_0]
  divps xmm0, xmm1
  ret

However, it should just generate a call to rsqrtps .

I've tried with fast math flags but haven't been able to generate rsqrtps yet.</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>