diff mbox

Followup fix for auto-inc-dec.c, PR44404

Message ID 4C346442.9080600@codesourcery.com
State New
Headers show

Commit Message

Bernd Schmidt July 7, 2010, 11:25 a.m. UTC
Kazu recently made a change in auto-inc-dec.c to avoid using
count_occurrences in one case, since it doesn't handle hard registers
correctly.

There was a patch posted at
  http://gcc.gnu.org/ml/gcc-patches/2010-06/msg00514.html

which looks correct, but a different patch was checked in:

@@ -1068,6 +1068,13 @@ find_inc (bool first_try)
       /* For the post_add to work, the result_reg of the inc must not be
 	 used in the mem insn since this will become the new index
 	 register.  */
+      if (count_occurrences (PATTERN (mem_insn.insn), inc_insn.reg_res,
1) == 0
+	  && reg_overlap_mentioned_p (inc_insn.reg_res, PATTERN (mem_insn.insn)))
+	{
+	  debug_rtx (mem_insn.insn);
+	  debug_rtx (inc_insn.reg_res);
+	  gcc_unreachable ();
+	}
       if (count_occurrences (PATTERN (mem_insn.insn), inc_insn.reg_res,
1) != 0)
 	{
 	  if (dump_file)

which isn't actually fixing anything, just causing an abort when we
encounter the problematic situation.  This triggers on the PR44404
testcase if my ARM ldm/stm peephole patch is applied.

I'll be checking in the below as obvious after some testing.  There are
some more calls to count_occurrences in auto-inc-dec.c which worry me a
bit, but that's a problem for another day.


Bernd
PR rtl-optimization/44404
	* auto-inc-dec.c (find_inc): Avoid calling count_occurrences if
	possible, use reg_overlap_mentioned_p instead.

Comments

Kazu Hirata July 7, 2010, 12:50 p.m. UTC | #1
Hi Bernd,

> which looks correct, but a different patch was checked in:

Oops.  Thank you for fixing this.

Kazu Hirata
diff mbox

Patch

Index: auto-inc-dec.c
===================================================================
--- auto-inc-dec.c	(revision 161824)
+++ auto-inc-dec.c	(working copy)
@@ -1068,14 +1068,7 @@  find_inc (bool first_try)
       /* For the post_add to work, the result_reg of the inc must not be
 	 used in the mem insn since this will become the new index
 	 register.  */
-      if (count_occurrences (PATTERN (mem_insn.insn), inc_insn.reg_res, 1) == 0
-	  && reg_overlap_mentioned_p (inc_insn.reg_res, PATTERN (mem_insn.insn)))
-	{
-	  debug_rtx (mem_insn.insn);
-	  debug_rtx (inc_insn.reg_res);
-	  gcc_unreachable ();
-	}
-      if (count_occurrences (PATTERN (mem_insn.insn), inc_insn.reg_res, 1) != 0)
+      if (reg_overlap_mentioned_p (inc_insn.reg_res, PATTERN (mem_insn.insn)))
 	{
 	  if (dump_file)
 	    fprintf (dump_file, "base reg replacement failure.\n");