<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 - [x86] load/splat scalar constants for use with scalar FP logic ops?"
   href="https://bugs.llvm.org/show_bug.cgi?id=40905">40905</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[x86] load/splat scalar constants for use with scalar FP logic ops?
          </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>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>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Seen in:
<a href="https://reviews.llvm.org/D58282">https://reviews.llvm.org/D58282</a>

declare <4 x double> @llvm.copysign.v4f64(<4 x double>, <4 x double>)
define double @copysign_v4f64(<4 x double> %x, <4 x double> %y) nounwind {
  %v = call <4 x double> @llvm.copysign.v4f64(<4 x double> %x, <4 x double> %y)
  %r = extractelement <4 x double> %v, i32 0
  ret double %r
}

We convert this to a scalar op, but the x86 FP logic ops only allow load
folding with vector constants so:

$ ./llc -o - -mattr=avx copysign.ll 
LCPI0_0:
        .quad   -9223372036854775808    ## double -0
        .quad   -9223372036854775808    ## double -0
LCPI0_1:
        .quad   9223372036854775807     ## double NaN
        .quad   9223372036854775807     ## double NaN
        .section        __TEXT,__text,regular,pure_instructions
        .globl  _copysign_v4f64
        .p2align        4, 0x90
_copysign_v4f64:                  
        vandps  LCPI0_0(%rip), %xmm1, %xmm1
        vandps  LCPI0_1(%rip), %xmm0, %xmm0
        vorps   %xmm1, %xmm0, %xmm0
        vzeroupper
        retq

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

Should we broadcast scalar constants instead? The answer may depend on whether
we are optimizing for size and/or subtarget.</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>