[llvm-bugs] [Bug 40053] New: _mm_adds_epu8 and _mm_subs_epu8 with constant operand don't generate paddusb/psubusb

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Dec 17 07:34:35 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=40053

            Bug ID: 40053
           Summary: _mm_adds_epu8 and _mm_subs_epu8 with constant operand
                    don't generate paddusb/psubusb
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: amanieu at gmail.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181217/96afa681/attachment.html>


More information about the llvm-bugs mailing list