https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127148

--- Comment #1 from Jeevitha <jeevitha at gcc dot gnu.org> ---
vec_extractm:

Purpose: Collect the high-order bits of each element of the input vector.

Result value: The contents of the high-order bit of each element of a are
concatenated and placed
in the rightmost bits of r, with other bits of r set to 0.

Consider for char:

For a vector unsigned char, there are 16 elements, so vec_extractm collects the
low-order bit (bit[0]) from each of the 16 bytes.

The vec_extractm intrinsic is mapped to the corresponding instruction for char
elements:

vextractbm RT,VRB
The instruction operates as follows:
do i = 0 to 15
GPR[RT].bit[48+i] ← VSR[VRB+32].byte[i].bit[0]
end
GPR[RT].bit[0:47] ← 0


For this testcase:

vbc_bi_src[0] = 0xFF;
  vbc_bi_src[1] = 0xFF;
  vbc_bi_src[2] = 0x0;
  vbc_bi_src[3] = 0x0;
  vbc_bi_src[4] = 0x0;
  vbc_bi_src[5] = 0x0;
  vbc_bi_src[6] = 0xFF;
  vbc_bi_src[7] = 0xFF;
  vbc_bi_src[8] = 0xFF;
  vbc_bi_src[9] = 0xFF;
  vbc_bi_src[10] = 0xFF;
  vbc_bi_src[11] = 0xFF;
  vbc_bi_src[12] = 0xFF;
  vbc_bi_src[13] = 0x0;
  vbc_bi_src[14] = 0xFF;
  vbc_bi_src[15] = 0xFF;

  expected_result_wi = 0b1101111111000011;

  result_wi = vec_extractm (vbc_bi_src);
----------------------------------------

Instruction generated: vextractbm r2,v0

So vector vbc_bi_src is expressed like:

vbc_bi_src -> v0

LE:  
{uint128 = 0xffff00ffffffffffffff00000000ffff, v4_float = {0xffff, 0xffff0000,
0xffffffff, 0xffff00ff},
  v4_int32 = {0xffff, 0xffff0000, 0xffffffff, 0xffff00ff}, v8_int16 = {0xffff,
0x0, 0x0, 0xffff, 0xffff, 0xffff, 0xff,
    0xffff}, v16_int8 = {0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x0, 0xff, 0xff}}

BE:
{uint128 = 0xffff00000000ffffffffffffff00ffff, v4_float = {0xffff0000, 0xffff,
0xffffffff, 0xff00ffff}, v4_int32 = {
    0xffff0000, 0xffff, 0xffffffff, 0xff00ffff}, v8_int16 = {0xffff, 0x0, 0x0,
0xffff, 0xffff, 0xffff, 0xff00, 0xffff},
  v16_int8 = {0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0x0, 0xff, 0xff}}

The difference is in how the 128-bit vector is laid out in the hex
representation.

On LE:

uint128 = 0xffff00ffffffffffffff00000000ffff

The low-order bit of each byte is:
1 1 0 1 1 1 1 1 1 1 0 0 0 0 1 1

On BE:

uint128 = 0xffff00000000ffffffffffffff00ffff

The low-order bit of each byte is:
1 1 0 0 0 0 1 1 1 1 1 1 1 0 1 1

The testcase should therefore account for the target endianness when checking
the expected result.

Reply via email to