diff mbox

patch to fix PR80343

Message ID 1fe08600-7d1c-2255-cb5b-845eeeb85e88@redhat.com
State New
Headers show

Commit Message

Vladimir Makarov April 13, 2017, 6:09 p.m. UTC
The following patch fixes

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80343

   The patch was successfully bootstrapped and tested on x86-64.

   Committed as rev. 246914.
diff mbox

Patch

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 246907)
+++ ChangeLog	(working copy)
@@ -1,3 +1,9 @@ 
+2017-04-13  Vladimir Makarov  <vmakarov@redhat.com>
+
+	PR rtl-optimization/80343
+	* lra-remat.c (update_scratch_ops): Assign original hard reg to
+	new scratch pseudo.
+
 2017-04-13  Jeff Law  <law@redhat.com>
 
 	* reload1.c (eliminate_regs_1): Call gen_rtx_raw_SUBREG for SUBREGs
Index: lra-remat.c
===================================================================
--- lra-remat.c	(revision 246907)
+++ lra-remat.c	(working copy)
@@ -1024,6 +1024,7 @@  get_hard_regs (struct lra_insn_reg *reg,
 static void
 update_scratch_ops (rtx_insn *remat_insn)
 {
+  int hard_regno;
   lra_insn_recog_data_t id = lra_get_insn_recog_data (remat_insn);
   struct lra_static_insn_data *static_id = id->insn_static_data;
   for (int i = 0; i < static_id->n_operands; i++)
@@ -1034,9 +1035,17 @@  update_scratch_ops (rtx_insn *remat_insn
       int regno = REGNO (*loc);
       if (! lra_former_scratch_p (regno))
 	continue;
+      hard_regno = reg_renumber[regno];
       *loc = lra_create_new_reg (GET_MODE (*loc), *loc,
 				 lra_get_allocno_class (regno),
 				 "scratch pseudo copy");
+      if (hard_regno >= 0)
+	{
+	  reg_renumber[REGNO (*loc)] = hard_regno;
+	  if (lra_dump_file)
+	    fprintf (lra_dump_file, "	 Assigning the same %d to r%d\n",
+		     REGNO (*loc), hard_regno);
+	}
       lra_register_new_scratch_op (remat_insn, i);
     }
   
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog	(revision 246907)
+++ testsuite/ChangeLog	(working copy)
@@ -1,3 +1,8 @@ 
+2017-04-13  Vladimir Makarov  <vmakarov@redhat.com>
+
+	PR rtl-optimization/80343
+	* gcc.target/powerpc/pr80343.c: New.
+
 2017-04-13  Richard Biener  <rguenther@suse.de>
 
 	PR testsuite/80416
Index: testsuite/gcc.target/powerpc/pr80343.c
===================================================================
--- testsuite/gcc.target/powerpc/pr80343.c	(nonexistent)
+++ testsuite/gcc.target/powerpc/pr80343.c	(working copy)
@@ -0,0 +1,50 @@ 
+/* { dg-do compile { target powerpc-*-*spe } } */
+/* { dg-options "-O2 -ftracer -fPIC" } */
+long long int vi, ls;
+int wq, oa, to, fv;
+signed char zo;
+
+long long int
+ai (long long int ip, long long int jc, int gt)
+{
+  ip /= 3;
+  jc += ip;
+  if (ip != 0)
+    vi = 0;
+  vi += ls;
+
+  if (wq != oa)
+    {
+      int tz;
+
+      for (tz = 0; tz < 32; ++tz)
+        zo -= wq & gt;
+
+      if ((gt & 5) > oa)
+        {
+          zo += gt;
+          fv += zo + to;
+        }
+
+      if (gt != 0)
+        oa = 0;
+
+      if (fv != 0)
+        {
+          vi += wq;
+          ls += ip;
+          jc += (vi != 0) ? ip : ls;
+        }
+
+      while (tz != 0)
+        {
+          zo = wq;
+          tz = zo;
+        }
+
+      ++to;
+      wq = ip;
+    }
+
+  return jc;
+}