diff mbox

patch to fix PR79949

Message ID 9895d610-01c8-0afd-7e77-0bafec71a795@redhat.com
State New
Headers show

Commit Message

Vladimir Makarov March 9, 2017, 2:44 p.m. UTC
A patch in the attachment fixes

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

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

Committed as rev. 246003.
diff mbox

Patch

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 246002)
+++ ChangeLog	(working copy)
@@ -1,3 +1,9 @@ 
+2017-03-09  Vladimir Makarov  <vmakarov@redhat.com>
+
+	PR rtl-optimization/79949
+	* lra-constraints.c (process_alt_operands): Check memory when
+	trying to predict a cycle.  Print about the overall increase.
+
 2017-03-09  Richard Biener  <rguenther@suse.de>
 
 	PR middle-end/79971
Index: lra-constraints.c
===================================================================
--- lra-constraints.c	(revision 246002)
+++ lra-constraints.c	(working copy)
@@ -2766,13 +2766,15 @@  process_alt_operands (int only_alternati
 		  && REG_P (no_subreg_reg_operand[1])
 		  /* Check that we reload memory not the memory
 		     address.  */
-		  && !curr_alt_offmemok[0]
+		  && ! (curr_alt_offmemok[0]
+			&& MEM_P (no_subreg_reg_operand[0]))
 		  && reg_in_class_p (no_subreg_reg_operand[1], curr_alt[0]))
 	      || (curr_alt_win[0] && ! curr_alt_win[1]
 		  && REG_P (no_subreg_reg_operand[0])
 		  /* Check that we reload memory not the memory
 		     address.  */
-		  && !curr_alt_offmemok[1]
+		  && ! (curr_alt_offmemok[1]
+			&& MEM_P (no_subreg_reg_operand[1]))
 		  && reg_in_class_p (no_subreg_reg_operand[0], curr_alt[1])
 		  && (! CONST_POOL_OK_P (curr_operand_mode[1],
 					 no_subreg_reg_operand[1])
@@ -2785,8 +2787,11 @@  process_alt_operands (int only_alternati
 		  && GET_CODE (no_subreg_reg_operand[1]) != PLUS)))
 	{
 	  /* We have a move insn and a new reload insn will be similar
-	     to the current insn.  We should avoid such situation as it
-	     results in LRA cycling.  */
+	     to the current insn.  We should avoid such situation as
+	     it results in LRA cycling.  */
+	  if (lra_dump_file != NULL)
+	    fprintf (lra_dump_file,
+		     "            Cycle danger: overall += LRA_MAX_REJECT\n");
 	  overall += LRA_MAX_REJECT;
 	}
       ok_p = true;