<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 - _mm_adds_epu8 and _mm_subs_epu8 with constant operand don't generate paddusb/psubusb"
   href="https://bugs.llvm.org/show_bug.cgi?id=40053">40053</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>_mm_adds_epu8 and _mm_subs_epu8 with constant operand don't generate paddusb/psubusb
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </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>amanieu@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>It seems that instruction selection can't see through the transformations done
on the constants.

This is a regression from 7.0 where these intrinsics would compile to a single
instruction.

Source:

#include <emmintrin.h>

__m128i test_add(__m128i x) {
    __m128i c = _mm_set1_epi8(1);
    return _mm_adds_epu8(x, c);
}

__m128i test_sub(__m128i x) {
    __m128i c = _mm_set1_epi8(1);
    return _mm_subs_epu8(x, c);
}

Assembly (trunk):

test_add:
  pcmpeqd xmm1, xmm1
  movdqa xmm2, xmm0
  psubb xmm2, xmm1
  pcmpeqb xmm0, xmm1
  por xmm0, xmm2
  ret

.LCPI1_0:
  .zero 16,1
test_sub:
  pmaxub xmm0, xmmword ptr [rip + .LCPI1_0]
  pcmpeqd xmm1, xmm1
  paddb xmm0, xmm1
  ret

Assembly (7.0):

.LCPI0_0:
  .zero 16,1
test_add:
  paddusb .LCPI0_0(%rip), %xmm0
  retq

.LCPI1_0:
  .zero 16,1
test_sub:
  psubusb .LCPI1_0(%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>