[llvm-bugs] [Bug 47194] New: Broadcasting the high word in AVX2

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Aug 16 17:50:59 PDT 2020


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

            Bug ID: 47194
           Summary: Broadcasting the high word in AVX2
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky 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

From
https://stackoverflow.com/questions/57505111/broadcasting-the-high-word-in-avx2:

#include <immintrin.h>

__m256i bcast_mse(__m256i v) {
    __m256i temp = _mm256_permute2x128_si256(v, v, 0x11);
    __m256i ctrl = _mm256_set_epi8( 
        15, 14, 15, 14, 15, 14, 15, 14,
        15, 14, 15, 14, 15, 14, 15, 14,
        15, 14, 15, 14, 15, 14, 15, 14,
        15, 14, 15, 14, 15, 14, 15, 14
    ); 
    return _mm256_shuffle_epi8(temp, ctrl);
}

Clang -O3 -mavx2:
bcast_mse(long long __vector(4)):                      # @bcast_mse(long long
__vector(4))
        vpshufhw        ymm0, ymm0, 255                 # ymm0 =
ymm0[0,1,2,3,7,7,7,7,8,9,10,11,15,15,15,15]
        vpshufd ymm0, ymm0, 170                 # ymm0 = ymm0[2,2,2,2,6,6,6,6]
        vpermq  ymm0, ymm0, 170                 # ymm0 = ymm0[2,2,2,2]
        ret

GCC/ICC -O3 -mavx2:
bcast_mse(__m256i):
        vperm2i128 ymm1, ymm0, ymm0, 17                         #4.20
        vpshufb   ymm0, ymm1, YMMWORD PTR .L_2il0floatpacket.0[rip] #11.12
        ret                                                     #11.12
.L_2il0floatpacket.0:
        .long  
0x0f0e0f0e,0x0f0e0f0e,0x0f0e0f0e,0x0f0e0f0e,0x0f0e0f0e,0x0f0e0f0e,0x0f0e0f0e,0x0f0e0f0e


Godbolt:
https://godbolt.org/z/cWb9Po

-- 
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/20200817/9bf11192/attachment.html>


More information about the llvm-bugs mailing list