From: Vladimir N. Makarov Date: Tue, 28 Jan 2025 13:37:33 +0000 (-0500) Subject: [PR118663][LRA]: Change secondary memory mode only if there are regs holding the... X-Git-Tag: basepoints/gcc-16~2303 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01339d29b7663d85eea6145eac2b1ad1da428c11;p=thirdparty%2Fgcc.git [PR118663][LRA]: Change secondary memory mode only if there are regs holding the changed mode My recent patch for PR118067 changes the secondary memory mode if all regs of the pseudo reg class are prohibited in the secondary mode. But the patch does not check a special case when the corresponding target hook returns this mode although there are no hard regs of pseudo class holding value of the mode at all. This results in given PR and this patch fixes it. gcc/ChangeLog: PR target/118663 * lra-constraints.cc (invalid_mode_reg_p): Check empty reg_class_contents. gcc/testsuite/ChangeLog: PR target/118663 * gcc.target/powerpc/pr118663.c: New. --- diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc index 797222c9fbc..ee3fd7a503a 100644 --- a/gcc/lra-constraints.cc +++ b/gcc/lra-constraints.cc @@ -4138,8 +4138,10 @@ static bool invalid_mode_reg_p (enum machine_mode mode, rtx x) if (! REG_P (x)) return false; enum reg_class rclass = get_reg_class (REGNO (x)); - return hard_reg_set_subset_p (reg_class_contents[rclass], - ira_prohibited_class_mode_regs[rclass][mode]); + return (!hard_reg_set_empty_p (reg_class_contents[rclass]) + && hard_reg_set_subset_p + (reg_class_contents[rclass], + ira_prohibited_class_mode_regs[rclass][mode])); } /* Main entry point of the constraint code: search the body of the diff --git a/gcc/testsuite/gcc.target/powerpc/pr118663.c b/gcc/testsuite/gcc.target/powerpc/pr118663.c new file mode 100644 index 00000000000..8d3cbe07fc1 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr118663.c @@ -0,0 +1,10 @@ +/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */ +/* { dg-options "-mcpu=601 -w -O2 -m64" } */ + +extern void bar (void); +void +foo (_Decimal32 *dst, _Decimal32 src) +{ + bar (); + *dst = src; +}