https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127157
Bug ID: 127157
Summary: rs6000: xxgenpc-runnable.c test fails on BE,
vec_genpcvm generates wrong results on LE as well
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: avinashd at gcc dot gnu.org
Reporter: avinashd at gcc dot gnu.org
CC: jskumari at gcc dot gnu.org, meissner at gcc dot gnu.org
Blocks: 125965
Target Milestone: ---
Target: powerpc64le
The documented behaviour of vec_genpcvm does not match with what is happening
in LE targets in powerpc.
Based on the documentation for
r = vec_genpcvm (a, b)
""Result value: In what follows, b must have a value of 0, 1, 2, or 3. a
contains a bit mask where the
high-order bit in each element is set if the permute mask should specify
expansion or compression of
that element, as explained below.""
Let us take the example for b=0
""If b = 0, r is assigned the value of the permute control vector required to
enable a left-indexed
permute to implement an expansion of the leftmost elements of a source vector
into the elements of
a result vector specified by the element mask in a.""
The leftmost elements of source vector are stored in right most elements in the
vector registers in LE target. Therefore, the guide also mentions:
""Endian considerations: The mask argument of the underlying instructions is
specified in big-endian
order. For correct bi-endian semantics, the mask must be reversed by the
compiler for little-endian
targets.""
What I understand by this, is that expected results must be same in both LE and
BE.
But the examples given in the guide is also wrong, and reversing the mask also
would generate incorrect results.
The next comment has the demonstration with an example.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125965
[Bug 125965] rs6000: Few Power10 big-endian tests fail due to endian-dependent
expected values