https://gcc.gnu.org/g:01339d29b7663d85eea6145eac2b1ad1da428c11

commit r15-7250-g01339d29b7663d85eea6145eac2b1ad1da428c11
Author: Vladimir N. Makarov <vmaka...@redhat.com>
Date:   Tue Jan 28 08:37:33 2025 -0500

    [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:
---
 gcc/lra-constraints.cc                      |  6 ++++--
 gcc/testsuite/gcc.target/powerpc/pr118663.c | 10 ++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc
index 797222c9fbc2..ee3fd7a503aa 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 000000000000..8d3cbe07fc1f
--- /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;
+}

Reply via email to