<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 - Improve codegen for shift by constant"
   href="https://bugs.llvm.org/show_bug.cgi?id=46281">46281</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Improve codegen for shift by constant
          </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>Linux
          </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>david.bolvansky@gmail.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>typedef char v16qi __attribute__ ((vector_size (16)));
typedef char v32qi __attribute__ ((vector_size (32)));

v16qi ashiftrt (v16qi a)
{
    return  a>>5;
}

v32qi arshiftrt2 (v32qi a)
{
    return  a>>5;
}


Clang -g0  -O3 -march=skylake

.LCPI0_0:
        .zero   16,7
.LCPI0_1:
        .zero   16,4
ashiftrt(char __vector(16)):                      # @ashiftrt(char
__vector(16))
        vpsrlw  xmm0, xmm0, 5
        vpand   xmm0, xmm0, xmmword ptr [rip + .LCPI0_0]
        vmovdqa xmm1, xmmword ptr [rip + .LCPI0_1] # xmm1 =
[4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4]
        vpxor   xmm0, xmm0, xmm1
        vpsubb  xmm0, xmm0, xmm1
        ret
.LCPI1_0:
        .zero   32,7
.LCPI1_1:
        .zero   32,4
arshiftrt2(char __vector(32)):                   # @arshiftrt2(char
__vector(32))
        vpsrlw  ymm0, ymm0, 5
        vpand   ymm0, ymm0, ymmword ptr [rip + .LCPI1_0]
        vmovdqa ymm1, ymmword ptr [rip + .LCPI1_1] # ymm1 =
[4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4]
        vpxor   ymm0, ymm0, ymm1
        vpsubb  ymm0, ymm0, ymm1
        ret


ICC -g0  -O3 -march=skylake

ashiftrt(char __vector(16)):
        vpsrlw    xmm1, xmm0, 5                                 #6.16
        vpand     xmm0, xmm1, XMMWORD PTR .L_2il0floatpacket.0[rip] #6.16
        ret                                                     #6.16
arshiftrt2(char __vector(32)):
        vpsrlw    ymm1, ymm0, 5                                 #11.16
        vpand     ymm0, ymm1, YMMWORD PTR .L_2il0floatpacket.1[rip] #11.16
        ret                                                     #11.16
.L_2il0floatpacket.1:
        .long  
0x07070707,0x07070707,0x07070707,0x07070707,0x07070707,0x07070707,0x07070707,0x07070707
.L_2il0floatpacket.0:
        .long   0x07070707,0x07070707,0x07070707,0x07070707



Godbolt: <a href="https://godbolt.org/z/LAibFf">https://godbolt.org/z/LAibFf</a></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>