This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[Patch]: Fix pb in libcall_dead_p


Hi!

With the 68HC11 port, I found a problem in flow.c in libcall_dead_p().

32-bit divisions are made with a library call and at the end
of the library call, I have the following two insns (you should get
quite the same with other ports, except for the parallel maybe): 

(insn 439 438 440 (parallel[ 
            (set (reg:SI 193)
                (reg:SI 0 x))
            (clobber (scratch:HI))
        ] ) 13 {movsi} (nil)
    (insn_list:REG_RETVAL 434 (expr_list:REG_EQUAL (expr_list (symbol_ref:HI ("__divsi3"))
                (expr_list (reg:SI 189)
                    (expr_list (const_int 1 [0x1])
                        (nil))))
            (nil))))

(insn 440 439 442 (parallel[ 
            (set (reg:SI 194)
                (reg:SI 0 x))
            (clobber (scratch:HI))
        ] ) 13 {movsi} (nil)
    (insn_list:REG_RETVAL 434 (expr_list:REG_EQUAL (div:SI (const_int 1 [0x1])
                (const_int 0 [0x0]))
            (nil))))


Everything is fine, but when insn 439 is checked in propagate_block_insn(),
it is found to be a insn_dead_p(). The register 193 is not used after that. We use register 194 instead.  So, it then
calls libcall_dead_p() which 
also finds this is dead because it does not handle the (parallel).
Then, it removes the library call, which is wrong.

I've fixed the problem by making libcall_dead_p() recognize the
(parallel) in the same way it handles the (set).  It ignores any
USE and CLOBBER.

Can you integrate this fix?

Thanks,
	Stephane

ChangeLog

2000-06-27  Stephane Carrez  <Stephane.Carrez@worldnet.fr>

	* flow.c (libcall_dead_p): Recognize PARALLEL and look at
	SET patterns in it.
--- /src/gnu/cygnus/gcc/gcc/flow.c	Sun Jun 25 11:20:05 2000
+++ gcc/gcc/flow.c	Sun Jun 25 12:38:26 2000
@@ -4063,6 +4063,28 @@ libcall_dead_p (pbi, x, note, insn)
 	  return insn_dead_p (pbi, call_pat, 1, REG_NOTES (call));
 	}
     }
+
+  /* If performing several activities, ignore the CLOBBER and USE
+     clauses to only look at real SET patterns.  */
+  else if (code == PARALLEL)
+    {
+      int i = XVECLEN (x, 0);
+
+      for (i--; i >= 0; i--)
+        {
+          rtx exp = XVECEXP (x, 0, i);
+          
+          if (GET_CODE (exp) == CLOBBER || GET_CODE (exp) == USE)
+            continue;
+
+          if (GET_CODE (exp) != SET)
+            return 1;
+          
+          if (! libcall_dead_p (pbi, exp, note, insn))
+            return 0;
+        }
+      return 1;
+    }
   return 1;
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]