Bug 90453 - PowerPC/AltiVec VSX: Provide vec_pack/vec_unpackh/vec_unpackl for 32<->64
Summary: PowerPC/AltiVec VSX: Provide vec_pack/vec_unpackh/vec_unpackl for 32<->64
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 8.3.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-13 15:03 UTC by Shawn Landden
Modified: 2019-05-19 21:18 UTC (History)
1 user (show)

See Also:
Host:
Target: powerpc*-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-05-18 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shawn Landden 2019-05-13 15:03:07 UTC
I know these are not part of the spec, but it would make coding easier, as a GNU extension.
Comment 1 Segher Boessenkool 2019-05-18 22:25:35 UTC
What does "32<->64" mean?
Comment 2 Shawn Landden 2019-05-18 22:45:13 UTC
vector unsigned long long unpacked;
vector unsigned int packedl, packedr;

unpacked = vec_pack(packedl, packedr);
packedl = vec_unpackh(unpacked);
packedr = vec_unpackl(unpacked);
Comment 3 Segher Boessenkool 2019-05-18 23:03:05 UTC
What should the semantics of this be?  There are four 32-bit elts each
in packedl and packedr, which of those go where in unpacked?

I think what you want to do can be expressed with just two or maybe three
existing builtins, but it's not clear to me exactly what you want.
Comment 4 Shawn Landden 2019-05-18 23:23:37 UTC
Oh my bad, I got it backwards

vector unsigned long long unpackedl, unpackedr;
vector unsigned int packed;

packed = vec_pack(unpackedl, unpackedr);
unpackedl = vec_unpackh(packed);
unpackedr = vec_unpackl(packed);

The point is that it is similar to the other pack/unpack unfunctions. Yet somehow this one doesn't exist (probably because there is no hardware instruction for it).
Comment 5 Segher Boessenkool 2019-05-19 01:17:15 UTC
vec_unpack* works on vectors of signed integers only, not unsigned.

You need to target at least power8 (-mcpu=power8) to get the long long
versions of this, i.e. the vpkudum and vupk[hl]sw instructions.

This is all documented correctly, as far as I see?  In the ISA doc,
in the ABI doc, and in the GCC docs?  (Power8 is ISA 2.07, we could add
some clarification for that).
Comment 6 Shawn Landden 2019-05-19 01:21:58 UTC
Ahh, sorry for wasting your time. I didn't notice the signed requirement, which is why it didn't work.
Comment 7 Segher Boessenkool 2019-05-19 21:18:22 UTC
Note that vec_pack works for unsigned as well.

For vec_unpack[hl] of unsigned you can do a vec_merge[hl] instead (with the
first arg a zero vector).