<html>
    <head>
      <base href="https://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 --- - [x86, FMA] use FMA instructions for negation instead of loading a constant and xor'ing?"
   href="https://llvm.org/bugs/show_bug.cgi?id=24366">24366</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[x86, FMA] use FMA instructions for negation instead of loading a constant and xor'ing?
          </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>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>With the addition of FMA instructions, x86 can negate FP values without loading
a constant:

$ cat nmul.ll 

define float @nmul(float %a, float %b) {
  %mul = fmul float %a, %b
  %neg = fsub float -0.0, %mul
  ret float %neg
}


$ ./llc -o - nmul.ll -mattr=fma 
    .section    __TEXT,__text,regular,pure_instructions
    .macosx_version_min 14, 4
    .section    __TEXT,__literal16,16byte_literals
    .align    4
LCPI0_0:
    .long    2147483648              ## 0x80000000
    .long    2147483648              ## 0x80000000
    .long    2147483648              ## 0x80000000
    .long    2147483648              ## 0x80000000
    .section    __TEXT,__text,regular,pure_instructions
    .globl    _nmul
    .align    4, 0x90
_nmul:                                  ## @nmul
    .cfi_startproc
## BB#0:
    vmulss    %xmm1, %xmm0, %xmm0
    vxorps    LCPI0_0(%rip), %xmm0, %xmm0
    retq

-------------------------------------------------------------------------------

Better speed/size, but does require a temp register:
  vxorps        %xmm2, %xmm2, %xmm2  <--- make zero cheaply for add operand
  vfnmadd213ss  %xmm2, %xmm1, %xmm0


I don't think this causes any IEEE-754 problems, but if it does, it should
still be possible to do this with -ffast-math?</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>