Hi,

On 24/08/26 5:16 pm, Manjunath S Matti wrote:
> The register order of the two vector arguments to
> __builtin_mma_assemble_pair is endian dependent, but the test passes
> them in little-endian order unconditionally.  On big endian the
> accumulator therefore receives the halves of the vector pair transposed
> and the computed matrix product does not match the scalar reference, so
> the test aborts with "Error 0,0,0".
> 
> Swap the two halves on big endian.  Tested on powerpc64-linux-gnu
> (-m64 and -m32) and powerpc64le-linux-gnu.
> 
> 2026-08-24  Manjunath Matti  <[email protected]>
> 
> gcc/testsuite/
>       * gcc.target/powerpc/mma-double-test.c (MMA): Swap the vector
>         arguments to __builtin_mma_assemble_pair on big endian.
> 

Can you please add PR target/126866 to the gcc/testsuite/ChangeLog
entry as appropriate?

> diff --git a/gcc/testsuite/gcc.target/powerpc/mma-double-test.c 
> b/gcc/testsuite/gcc.target/powerpc/mma-double-test.c
> index 254af7f8f79..3ef4da5281f 100644
> --- a/gcc/testsuite/gcc.target/powerpc/mma-double-test.c
> +++ b/gcc/testsuite/gcc.target/powerpc/mma-double-test.c
> @@ -52,7 +52,13 @@ MMA (int m, int n, int k, double *A, double *B, double *C)
>             vec_t *rowA = (vec_t *) & AO[i * 16];
>             __vector_pair rowB;
>             vec_t *rb = (vec_t *) & BO[i * 4];
> +/* The register order of __builtin_mma_assemble_pair is endian
> +   dependent, so the halves must be swapped on big endian.  */
> +#ifdef __BIG_ENDIAN__
> +           __builtin_mma_assemble_pair (&rowB, rb[0], rb[1]);
> +#else
>             __builtin_mma_assemble_pair (&rowB, rb[1], rb[0]);
> +#endif
>             __builtin_mma_xvf64gerpp (&acc0, rowB, rowA[0]);
>             __builtin_mma_xvf64gerpp (&acc1, rowB, rowA[1]);
>             __builtin_mma_xvf64gerpp (&acc2, rowB, rowA[2]);

I see PR96236, which handles __builtin_mma_disassemble_acc, so disassemble is
endian-independent. If __builtin_mma_assemble_pair is endian-dependent,
could you clarify the reason for this difference?

I also see that in rs6000-builtins.cc we already swap the operands for
__builtin_mma_assemble_pair on little-endian targets:

if (fcode == RS6000_BIF_ASSEMBLE_PAIR_V_INTERNAL && !WORDS_BIG_ENDIAN)
  std::swap (op[1], op[2]);

Can you please take a look at this?

Thanks,
Jeevitha.

Reply via email to