]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PR118663][LRA]: Change secondary memory mode only if there are regs holding the...
authorVladimir N. Makarov <vmakarov@redhat.com>
Tue, 28 Jan 2025 13:37:33 +0000 (08:37 -0500)
committerVladimir N. Makarov <vmakarov@redhat.com>
Tue, 28 Jan 2025 13:41:04 +0000 (08:41 -0500)
  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.

gcc/lra-constraints.cc
gcc/testsuite/gcc.target/powerpc/pr118663.c [new file with mode: 0644]

index 797222c9fbc26589c2d25f8fd111a75a7d78b570..ee3fd7a503aa15c159fc1f2096a4252a2bc3834b 100644 (file)
@@ -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 (file)
index 0000000..8d3cbe0
--- /dev/null
@@ -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;
+}