https://gcc.gnu.org/g:fab96de044f1f023f52d43af866205d17d8895fb
commit r15-6751-gfab96de044f1f023f52d43af866205d17d8895fb Author: Vladimir N. Makarov <vmaka...@redhat.com> Date: Thu Jan 9 16:22:02 2025 -0500 [PR118017][LRA]: Don't inherit reg of non-uniform reg class In the PR case LRA inherited value of register of class INT_SSE_REGS which resulted in LRA cycling when LRA tried to use different move alternatives with SSE/general regs and memory. The patch rejects to inherit such (non-uniform) classes to prevent cycling. gcc/ChangeLog: PR target/118017 * lra-constraints.cc (inherit_reload_reg): Check reg class on uniformity. gcc/testsuite/ChangeLog: PR target/118017 * gcc.target/i386/pr118017.c: New. Diff: --- gcc/lra-constraints.cc | 14 ++++++++++++++ gcc/testsuite/gcc.target/i386/pr118017.c | 21 +++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc index a0f05b290dde..8f32e98f1c47 100644 --- a/gcc/lra-constraints.cc +++ b/gcc/lra-constraints.cc @@ -5878,6 +5878,20 @@ inherit_reload_reg (bool def_p, int original_regno, } return false; } + if (ira_reg_class_min_nregs[rclass][GET_MODE (original_reg)] + != ira_reg_class_max_nregs[rclass][GET_MODE (original_reg)]) + { + if (lra_dump_file != NULL) + { + fprintf (lra_dump_file, + " Rejecting inheritance for %d " + "because of requiring non-uniform class %s\n", + original_regno, reg_class_names[rclass]); + fprintf (lra_dump_file, + " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); + } + return false; + } new_reg = lra_create_new_reg (GET_MODE (original_reg), original_reg, rclass, NULL, "inheritance"); start_sequence (); diff --git a/gcc/testsuite/gcc.target/i386/pr118017.c b/gcc/testsuite/gcc.target/i386/pr118017.c new file mode 100644 index 000000000000..c82d71e8d293 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr118017.c @@ -0,0 +1,21 @@ +/* PR target/118017 */ +/* { dg-do compile } */ +/* { dg-options "-Og -frounding-math -mno-80387 -mno-mmx -Wno-psabi" } */ + +typedef __attribute__((__vector_size__ (64))) _Float128 F; +typedef __attribute__((__vector_size__ (64))) _Decimal64 G; +typedef __attribute__((__vector_size__ (64))) _Decimal128 H; + +void +bar(_Float32, _BitInt(1025), _BitInt(1025), _Float128, __int128, __int128, F, + int, int, G, _Float64, __int128, __int128, H, F); + + +void +foo () +{ + bar ((__int128)68435455, 0, 0, 0, 0, 0, (F){}, 0, 0, (G){3689348814741910323}, + 0, 0, 0, (H){0, (_Decimal128) ((__int128) 860933398830926 << 64), + (_Decimal128) ((__int128) 966483857959145 << 64), 4}, + (F){(__int128) 3689348814741910323 << 64 | 3}); +}