[llvm-bugs] [Bug 42825] New: [X86][SSE] Failure to flip VPBLENDVB inputs with an inverted selection mask

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 30 06:43:08 PDT 2019


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

            Bug ID: 42825
           Summary: [X86][SSE] Failure to flip VPBLENDVB inputs with an
                    inverted selection mask
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: llvm-dev at redking.me.uk
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

Current Codegen: https://godbolt.org/z/hseT6Z

__m128i sel2(__m128i x, __m128i y, __m128i s) {
    return _mm_blendv_epi8(x, y, _mm_xor_si128(s, _mm_set1_epi32(-1)));
}

clang -g0 -O3 -march=btver2

define <2 x i64> @_Z4sel2Dv2_xS_S_(<2 x i64>, <2 x i64>, <2 x i64>) {
  %4 = bitcast <2 x i64> %0 to <16 x i8>
  %5 = bitcast <2 x i64> %1 to <16 x i8>
  %6 = bitcast <2 x i64> %2 to <16 x i8>
  %7 = xor <16 x i8> %6, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8
-1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
  %8 = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %4, <16 x i8> %5,
<16 x i8> %7) #2
  %9 = bitcast <16 x i8> %8 to <2 x i64>
  ret <2 x i64> %9
}

_Z4sel2Dv2_xS_S_:
  vpcmpeqd %xmm3, %xmm3, %xmm3
  vpxor %xmm3, %xmm2, %xmm2
  vpblendvb %xmm2, %xmm1, %xmm0, %xmm0
  retq

we should be able to flip the inputs and remove the selection mask inversion:

_Z4sel2Dv2_xS_S_:
  vpblendvb %xmm2, %xmm0, %xmm1, %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/20190730/99305795/attachment.html>


More information about the llvm-bugs mailing list