The test passes the halves of the vector pair to
__builtin_mma_assemble_pair in little endian order unconditionally, so
on big endian the accumulators get them the wrong way round and the
test aborts with "Error 0,0,0".

Pass the halves in the correct order on big endian.

Tested on powerpc64-linux-gnu (-m64 and -m32) and powerpc64le-linux-gnu.

2026-09-07  Manjunath Matti  <[email protected]>

gcc/testsuite/
        PR target/126866
        * gcc.target/powerpc/mma-double-test.c (MMA): Swap the vector
        arguments to __builtin_mma_assemble_pair on big endian.

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]);
-- 
2.52.0

Reply via email to