<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] suboptimal codegen for vector with string of set bits (-1)"
   href="https://llvm.org/bugs/show_bug.cgi?id=26301">26301</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[x86] suboptimal codegen for vector with string of set bits (-1)
          </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>I noticed this while looking at vmaskmov codegen because that (unnecessarily)
uses vector masks with elements of all ones or zeros:

define <4 x i32> @high_64_ones() {
  ret <4 x i32><i32 0, i32 0, i32 -1, i32 -1>
}

define <2 x i64> @high_64_ones_alt() {
  ret <2 x i64><i64 0, i64 -1>
}

$  ./llc high_ones.ll  -o -

_high_64_ones:                          ## @high_64_ones
    movaps    LCPI0_0(%rip), %xmm0    ## xmm0 = [0,0,4294967295,4294967295]
    retq

_high_64_ones_alt:                      ## @high_64_ones_alt
    movq    $-1, %rax
    movd    %rax, %xmm0
    pslldq    $8, %xmm0               ## xmm0 =
zero,zero,zero,zero,zero,zero,zero,zero,xmm0[0,1,2,3,4,5,6,7]
    retq

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

Some might argue that the 1st case is fine; don't burden the vector units
because loads (and memory space?) are free on big Intel core systems. But I
think the 2nd would be better as:

  pcmpeqd %xmm0, %xmm0  // splat 1 bits all the way across
  pslldq  $8, %xmm0     // shift in the zeros

...to avoid the move from integer to SSE register. And that's the codegen we
should produce by default for both cases.</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>