<html>
    <head>
      <base href="http://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 --- - missed optimization: recognize fnabs (FP negative absolute value) (x86-64)"
   href="http://llvm.org/bugs/show_bug.cgi?id=20578">20578</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>missed optimization: recognize fnabs (FP negative absolute value) (x86-64)
          </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>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>spatel+llvm@rotateright.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Ouch - 32 bytes of constant pool data to turn on a single bit.

Using llc built from r214897:

$ cat fnabs.c
#include <math.h>
float foo(float a) {
  return -fabs(a);
}

or in LLVM IR:

$ cat fnabs.ll
define float @foo(float %a) {
  %fabsf = tail call float @fabsf(float %a) #1
  %fsub = fsub float -0.0, %fabsf
  ret float %fsub
}

declare float @fabsf(float)
attributes #1 = { readnone }

$ ./llc -mtriple=x86_64-unknown-unknown fnabs.ll -o -
    .text
    .file    "fnabs.ll"
    .section    .rodata.cst16,"aM",@progbits,16
    .align    16
.LCPI0_0:
    .long    2147483647              # float nan
    .long    2147483647              # float nan
    .long    2147483647              # float nan
    .long    2147483647              # float nan
.LCPI0_1:
    .long    2147483648              # float -0.000000e+00
    .long    2147483648              # float -0.000000e+00
    .long    2147483648              # float -0.000000e+00
    .long    2147483648              # float -0.000000e+00
    .text
    .globl    foo
    .align    16, 0x90
    .type    foo,@function
foo:                                    # @foo
    .cfi_startproc
# BB#0:
    andps    .LCPI0_0(%rip), %xmm0
    xorps    .LCPI0_1(%rip), %xmm0
    retq</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>