gccinline-assemblypowerpcaltivec

Power8 vsldoi built-in or replacement


I'm trying to port some ASM code into C/C++ using built-ins. The ASM code has:

+  # Unpack a-h data from the packed vector to a vector register each
+  
+  vsldoi 10, 9, 9, 12
+  vsldoi 11, 9, 9, 8
+  vsldoi 12, 9, 9, 4

I can't find a built-in for vec_vsldoi. When I search IBM's site I get 0 hits. I think vec_sldw is close but it takes 3 arguments instead of 4.

My first question is, is there a built-in for vec_vsldoi? if not, do we use vec_sldw or something else?

We are supporting GCC 4.8 in addition to XL C/C++. GCC appears to lack both intrinsics. I think I have a replacement, but I have my reservations. A test program shows the assembler can assemble vsldoi.

// GCC 4.8 is missing vec_sldw and vec_vsldoi
#if defined(XLC_VERSION)
# define VEC_VSLDOI(a,b,c) vec_vsldoi(a,b,c)
#elif defined(GCC_VERSION)
# define VEC_VSLDOI(a,b,c) VEC_VSLDOI_TEMPLATE<c>(a,b)
template<unsigned int C>
uint8x16_p8 VEC_VSLDOI_TEMPLATE(uint8x16_p8 a, const uint8x16_p8& b)
{
    uint8x16_p8 r;
    __asm
    (
        "vsldoi %0, %1, %2, %3    \t\n"
        : "=v" (t) : "v" (a), "v" (b), "I" (C) : "cc"
    );
    return r;
}
#endif

My second question is, is the extended GCC ASM correct, or should we be doing something else?


Solution

  • Does vec_sld meet your needs? https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.2.0/com.ibm.zos.v2r2.cbcpx01/bif_vec_sld.htm (admittedly not a "POWER" reference, but relevant nonetheless).

    $ gcc --version
    gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11)
    Copyright (C) 2015 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    $ gcc -c vec_sld.c
    $ objdump -d vec_sld.o | grep vsl
      4c:   2c 09 00 10     vsldoi  v0,v0,v1,4