How to tell PPC assembler VSX is available?

Jeffrey Walton
Sun Mar 11 00:21:00 GMT 2018

I'm trying to replace vec_xl_be, which seems to be missing in most
versions of GCC. I have the code shown below.

When I attempt to use VEC_XL_BE it results in:

$ g++ -DTEST_MAIN -g2 -O3 -mcpu=power8 sha256-p8.cxx -o sha256-p8.exe
/home/noloader/tmp/ccbDnfFr.s: Assembler messages:
/home/noloader/tmp/ccbDnfFr.s:758: Error: operand out of range (32 is
not between 0 and 31)
/home/noloader/tmp/ccbDnfFr.s:983: Error: operand out of range (48 is
not between 0 and 31)

According to IBM's docs at [1], -mcpu=power8 is the correct option;
and it enables other options, like -mvsx. Enabling other options in
turn, like -maltivec and -mvsx, does not help.

I've found several similar problems on the web. Most seem to be
related to the range of a constant. This feels more like an
architecture/configuration problem.

How can I tell the assembler the VSX registers are available? Or what
should I do to make this work?



typedef __vector unsigned int  uint32x4_p8;

uint32x4_p8 VEC_XL_BE(const uint8_t* data, int offset)
#if defined(__xlc__) || defined(__xlC__)
  return (uint32x4_p8)vec_xl_be(offset, (uint8_t*)data);
  uint32x4_p8 res;
  __asm(" lxvd2x  %x0, %1, %2    \n\t"
        : "=wa" (res)
        : "g" (data), "g" (offset));
  return res;



I'm working on GCC112 from the compile farm, which is ppc64-le. It is
the hand we are dealt.

$ gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16)

$ as --version
GNU assembler version 2.25.1-32.base.el7_4.1

More information about the Binutils mailing list