Hi, As peter mentioned there would be issues in supporting __vector_quad for prior cpus, I have removed its support on power9. This patch only adds support for using __vector_pair from power9 and later.
In v2 proposed alternate solution to represent OOmode and contiguous aligned GPRs, but I realize that having different meanings of OOmode for different target would not be right. Bootstrapped and regtested on powerpc64le with no regressions. Kindly review. Changes from v2: - Pivot to original solution, but just support __vector_pair. Changes from v1: - Support movxo/movoo for POWERPC64 as well. - Update test cases to check errors with -m32 option. Thanks and regards, Avinash Jayakar This patch allows power9 target also to use the opaque type __vector_pair. The loads/stores for OOmode (linked to this type) are done using 2 lxv/stxv insns which were introduced in power isa 3.0/power9. The error message on its usage has been changed accordingly. 2025-11-27 Avinash Jayakar <[email protected]> PR 106736 PR 108272 gcc/ChangeLog: * config/rs6000/mma.md (*movoo_p9): Insn and split for power9. * config/rs6000/mma.md (movoo): Support power 9 vector. * config/rs6000/rs6000.cc (rs6000_hard_regno_mode_ok_uncached): Allow power 9 also to allocate VSX regs for OO mode. (rs6000_opaque_type_invalid_use_p): Update error message for usage of __vector_pair. gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr106736-2.c: Fail for p8. * gcc.target/powerpc/pr106736-5.c: Fail for p8. * gcc.target/powerpc/pr108272-2.c: Fail for p8. * gcc.target/powerpc/pr108272-4.c: Fail for p8. --- gcc/config/rs6000/mma.md | 22 ++++++++++++++++++- gcc/config/rs6000/rs6000.cc | 8 ++++--- gcc/testsuite/gcc.target/powerpc/pr106736-2.c | 7 +++--- gcc/testsuite/gcc.target/powerpc/pr106736-5.c | 7 +++--- gcc/testsuite/gcc.target/powerpc/pr108272-2.c | 7 +++--- gcc/testsuite/gcc.target/powerpc/pr108272-4.c | 7 +++--- 6 files changed, 38 insertions(+), 20 deletions(-) diff --git a/gcc/config/rs6000/mma.md b/gcc/config/rs6000/mma.md index 85f3a926682..04beb493dd1 100644 --- a/gcc/config/rs6000/mma.md +++ b/gcc/config/rs6000/mma.md @@ -269,7 +269,7 @@ (match_operand:OO 1 "input_operand"))] "" { - if (TARGET_MMA) + if (TARGET_MMA || TARGET_P9_VECTOR) { rs6000_emit_move (operands[0], operands[1], OOmode); DONE; @@ -312,6 +312,26 @@ (set_attr "size" "256") (set_attr "length" "*,*,8")]) +(define_insn_and_split "*movoo_p9" + [(set (match_operand:OO 0 "nonimmediate_operand" "=wa,ZwO,wa") + (match_operand:OO 1 "input_operand" "ZwO,wa,wa"))] + "TARGET_P9_VECTOR && !TARGET_MMA + && (gpc_reg_operand (operands[0], OOmode) + || gpc_reg_operand (operands[1], OOmode))" + "@ + # + # + #" + "&& reload_completed" + [(const_int 0)] +{ + rs6000_split_multireg_move (operands[0], operands[1]); + DONE; +} + [(set_attr "type" "vecload,vecstore,veclogical") + (set_attr "size" "256") + (set_attr "length" "*,*,8")]) + ;; Vector quad support. XOmode can only live in FPRs. (define_expand "movxo" diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 1d5cd25c0f0..b3e04b91234 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -1861,7 +1861,8 @@ rs6000_hard_regno_mode_ok_uncached (int regno, machine_mode mode) /* Vector pair modes need even/odd VSX register pairs. Only allow vector registers. */ if (mode == OOmode) - return (TARGET_MMA && VSX_REGNO_P (regno) && (regno & 1) == 0); + return ((TARGET_MMA || TARGET_P9_VECTOR) && VSX_REGNO_P (regno) + && (regno & 1) == 0); /* MMA accumulator modes need FPR registers divisible by 4. */ if (mode == XOmode) @@ -29314,9 +29315,10 @@ rs6000_opaque_type_invalid_use_p (gimple *stmt) error ("type %<__vector_quad%> requires the %qs option", "-mmma"); return true; } - else if (mv == vector_pair_type_node) + else if (mv == vector_pair_type_node && !TARGET_P9_VECTOR) { - error ("type %<__vector_pair%> requires the %qs option", "-mmma"); + error ("type %<__vector_pair%> requires the %qs option\ + (supported on power9 and later)", "-mvsx"); return true; } return false; diff --git a/gcc/testsuite/gcc.target/powerpc/pr106736-2.c b/gcc/testsuite/gcc.target/powerpc/pr106736-2.c index 12ad936fccc..66e5bf834e6 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr106736-2.c +++ b/gcc/testsuite/gcc.target/powerpc/pr106736-2.c @@ -1,8 +1,7 @@ -/* { dg-require-effective-target powerpc_p9modulo_ok } */ -/* If the default cpu type is power10 or later, type __vector_pair is +/* If the default cpu type is power9 or later, type __vector_pair is supported. To keep the test point available all the time, this case - specifies -mdejagnu-cpu=power9 here. */ -/* { dg-options "-mdejagnu-cpu=power9" } */ + specifies -mdejagnu-cpu=power8 here. */ +/* { dg-options "-mdejagnu-cpu=power8" } */ /* Verify there is no ICE and don't check the error messages on unsupported type since they could be fragile and are not test points of this case. */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr106736-5.c b/gcc/testsuite/gcc.target/powerpc/pr106736-5.c index d7370b81e81..e7609997270 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr106736-5.c +++ b/gcc/testsuite/gcc.target/powerpc/pr106736-5.c @@ -1,8 +1,7 @@ -/* { dg-require-effective-target powerpc_p9modulo_ok } */ -/* If the default cpu type is power10 or later, type __vector_pair is +/* If the default cpu type is power9 or later, type __vector_pair is supported. To keep the test point available all the time, this case - specifies -mdejagnu-cpu=power9 here. */ -/* { dg-options "-mdejagnu-cpu=power9" } */ + specifies -mdejagnu-cpu=power8 here. */ +/* { dg-options "-mdejagnu-cpu=power8" } */ /* Verify there is no ICE and don't check the error messages on unsupported type since they could be fragile and are not test points of this case. */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr108272-2.c b/gcc/testsuite/gcc.target/powerpc/pr108272-2.c index 51b2100d0f1..c08767beea0 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr108272-2.c +++ b/gcc/testsuite/gcc.target/powerpc/pr108272-2.c @@ -1,8 +1,7 @@ -/* { dg-require-effective-target powerpc_p9modulo_ok } */ -/* If the default cpu type is power10 or later, type __vector_pair is +/* If the default cpu type is power9 or later, type __vector_pair is supported. To keep the test point available all the time, this case - specifies -mdejagnu-cpu=power9 here. */ -/* { dg-options "-mdejagnu-cpu=power9" } */ + specifies -mdejagnu-cpu=power8 here. */ +/* { dg-options "-mdejagnu-cpu=power8" } */ /* Verify there is no ICE and don't check the error messages on unsupported type since they could be fragile and are not test points of this case. */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr108272-4.c b/gcc/testsuite/gcc.target/powerpc/pr108272-4.c index 7eecd6c5a0d..13b2f8862c9 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr108272-4.c +++ b/gcc/testsuite/gcc.target/powerpc/pr108272-4.c @@ -1,8 +1,7 @@ -/* { dg-require-effective-target powerpc_p9modulo_ok } */ -/* If the default cpu type is power10 or later, type __vector_pair is +/* If the default cpu type is power9 or later, type __vector_pair is supported. To keep the test point available all the time, this case - specifies -mdejagnu-cpu=power9 here. */ -/* { dg-options "-mdejagnu-cpu=power9" } */ + specifies -mdejagnu-cpu=power8 here. */ +/* { dg-options "-mdejagnu-cpu=power8" } */ /* Verify there is no ICE and don't check the error messages on unsupported type since they could be fragile and are not test points of this case. */ -- 2.51.0
