diff mbox

LRA fix for 80160

Message ID e6913ced-1dfc-c2ae-0e2f-507cd05cc289@redhat.com
State New
Headers show

Commit Message

Bernd Schmidt March 25, 2017, 1:12 a.m. UTC
This fixes two PRs; we shouldn't try to avoid spilling a reg if it has 
an alternate class it can use.

Bootstrapped and tested on x86_64-linux, approved by Vlad, committed.


Bernd
diff mbox

Patch

Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog	(revision 246472)
+++ gcc/ChangeLog	(working copy)
@@ -1,3 +1,10 @@ 
+2017-03-25  Bernd Schmidt  <bschmidt@redhat.com>
+
+	PR rtl-optimization/80160
+	PR rtl-optimization/80159
+	* lra-assigns.c (must_not_spill_p): Tighten new test to also take
+	reg_alternate_class into account.
+
 2017-03-24  Vladimir Makarov  <vmakarov@redhat.com>
 
 	PR target/80148
Index: gcc/lra-assigns.c
===================================================================
--- gcc/lra-assigns.c	(revision 246472)
+++ gcc/lra-assigns.c	(working copy)
@@ -908,7 +908,8 @@  must_not_spill_p (unsigned spill_regno)
      does not solve the general case where existing reloads fully
      cover a limited register class.  */
   if (!bitmap_bit_p (&non_reload_pseudos, spill_regno)
-      && reg_class_size [reg_preferred_class (spill_regno)] == 1)
+      && reg_class_size [reg_preferred_class (spill_regno)] == 1
+      && reg_alternate_class (spill_regno) == NO_REGS)
     return true;
   return false;
 }
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog	(revision 246472)
+++ gcc/testsuite/ChangeLog	(working copy)
@@ -1,3 +1,10 @@ 
+2017-03-25  Bernd Schmidt  <bschmidt@redhat.com>
+
+	PR rtl-optimization/80160
+	PR rtl-optimization/80159
+
+	* gcc.target/i386/pr80160.c: New test.
+
 2017-03-24  Jakub Jelinek  <jakub@redhat.com>
 
 	PR sanitizer/79904
Index: gcc/testsuite/gcc.target/i386/pr80160.c
===================================================================
--- gcc/testsuite/gcc.target/i386/pr80160.c	(nonexistent)
+++ gcc/testsuite/gcc.target/i386/pr80160.c	(working copy)
@@ -0,0 +1,45 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-omit-frame-pointer -w" } */
+/* { dg-additional-options "-march=pentium-mmx" { target ia32 } } */
+
+typedef struct { long long a; } a_t;
+int *a, b;
+a_t *e, c;
+long long f;
+void fn (int);
+void fn2 (void);
+int fn3 (a_t);
+void fn4 (a_t);
+a_t foo (long long val) { return (a_t){val}; }
+static void
+bar (int ka)
+{
+  unsigned i;
+  for (i = 0; i < 512; i++) {
+    long d;
+    c = (a_t){d};
+    fn2 ();
+  }
+  fn (ka);
+}
+void
+test (void)
+{
+  a_t g;
+  a_t *h, j;
+  h = e;
+  j = *h;
+  if (e == (a_t *) 1) {
+    a_t k = {fn3 (j)};
+    fn4 (j);
+    long l;
+    g = foo((long long)b << 2 | l);
+    k = g;
+    if (j.a != k.a) {
+      a_t m = g;
+      int n = m.a, o = m.a >> 32;
+      asm ("# %0 %1 %2 %3" : "=m"(*a), "+A"(f) : "b"(n), "c"(o));
+    }
+  }
+  bar ((int) h);
+}