diff mbox

fixed two issues in handling debug_insn.

Message ID 7FB04A5C213E9943A72EE127DB74F0ADA6897ACFF2@SJEXCHCCR02.corp.ad.broadcom.com
State New
Headers show

Commit Message

Bingfeng Mei July 16, 2010, 12:15 p.m. UTC
Hello,

I fixed two issues in handling debug_insn. The first is in ddg.c. 
Number of nodes should exclude those of debug_insns to determine
whether a loop is a empty one. 

The second is in loop-doloop.c. The original code checks validity
of the previous instruction, but will fail if the previous instruction(s)
is debug_insn. 

Both issues were found on our private port with our modulo scheduler.
I didn't try to reproduce for other targets since they are obvious.
I tested the patch on x86_64, which passed tests and is bootstrapped. 

OK for trunk? (maybe 4.5 too?)

Cheers,
Bingfeng


2010-07-16  Bingfeng Mei  <bmei@broadcom.com>
	* ddg.c (create_ddg): Exclude nodes of debug_insn in counting nodes
        of a loop.
        * loop-doloop.c (doloop_condition_get): Skip possible debug_insn.

Comments

Jakub Jelinek July 16, 2010, 12:24 p.m. UTC | #1
On Fri, Jul 16, 2010 at 05:15:21AM -0700, Bingfeng Mei wrote:

> --- loop-doloop.c       (revision 162258)
> +++ loop-doloop.c       (working copy)
> @@ -104,11 +104,15 @@
>    if (GET_CODE (pattern) != PARALLEL)
>      {
>        rtx cond;
> +      rtx prev_insn = PREV_INSN (doloop_pat);
> 
> -      /* We expect the decrement to immediately precede the branch.  */
> +      /* We expect the decrement to immediately precede the branch.
> +         Need to skip possible debug_insn */
> +      while (prev_insn != NULL_RTX && DEBUG_INSN_P (prev_insn))
> +        prev_insn = PREV_INSN (prev_insn);
> 
> -      if ((PREV_INSN (doloop_pat) == NULL_RTX)
> -          || !INSN_P (PREV_INSN (doloop_pat)))
> +      if ((prev_insn == NULL_RTX)
> +          || !INSN_P (prev_insn))
>          return 0;
> 
>        cmp = pattern;

Why don't you just do
      rtx prev_insn = prev_nondebug_insn (doloop_pat);

      if (prev_insn == NULL_RTX || !INSN_P (prev_insn))
	return 0;

?

	Jakub
diff mbox

Patch

Index: ddg.c
===================================================================
--- ddg.c       (revision 162258)
+++ ddg.c       (working copy)
@@ -488,7 +488,7 @@ 
     }

   /* There is nothing to do for this BB.  */
-  if (num_nodes <= 1)
+  if ((num_nodes - g->num_debug) <= 1)
     {
       free (g);
       return NULL;
Index: loop-doloop.c
===================================================================
--- loop-doloop.c       (revision 162258)
+++ loop-doloop.c       (working copy)
@@ -104,11 +104,15 @@ 
   if (GET_CODE (pattern) != PARALLEL)
     {
       rtx cond;
+      rtx prev_insn = PREV_INSN (doloop_pat);

-      /* We expect the decrement to immediately precede the branch.  */
+      /* We expect the decrement to immediately precede the branch.
+         Need to skip possible debug_insn */
+      while (prev_insn != NULL_RTX && DEBUG_INSN_P (prev_insn))
+        prev_insn = PREV_INSN (prev_insn);

-      if ((PREV_INSN (doloop_pat) == NULL_RTX)
-          || !INSN_P (PREV_INSN (doloop_pat)))
+      if ((prev_insn == NULL_RTX)
+          || !INSN_P (prev_insn))
         return 0;

       cmp = pattern;