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]
Other format: [Raw text]

[RFA] CONSTANT_RTX_P patch to builtins.c


I was looking into the bcp-1.c failure on mipsisa64-elf and came across
this. Conveniently it happens to fix the failure too - and I'll admit
now that I'm not positive what it does to compile times. :) Then again,
we're already looping over every insn so...

Anyhow, I believe that for_each_rtx is the proper way to loop over the
insns: 1) so we won't miss anything, and 2) i believe it's safe to
remove any qualifiers like sign/zero_extend, subreg from it. It also has
the side effect of being a lot cleaner.

Roger: You and I had already spoken about this - what do you think here?

Thoughts? OK?

-eric

-- 
Eric Christopher <echristo@redhat.com>

2003-10-16  Eric Christopher  <echristo@redhat.com>

	* builtins.c (is_constant_p_rtx): New function.
	(purge_builtin_constant_p): Use. Call
	for_each_rtx in loop.

Index: builtins.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/builtins.c,v
retrieving revision 1.259
diff -u -p -w -r1.259 builtins.c
--- builtins.c	11 Oct 2003 21:11:21 -0000	1.259
+++ builtins.c	16 Oct 2003 08:30:47 -0000
@@ -6666,28 +6666,47 @@ default_expand_builtin (tree exp ATTRIBU
   return NULL_RTX;
 }
 
-/* Instantiate all remaining CONSTANT_P_RTX nodes.  */
+/* Helper function to determine CONSTANT_P_RTX called through
+   for_each_rtx.  Returns true iff the rtl is CONSTANT_P_RTX.  */
+
+static int
+is_constant_p_rtx (rtx *rtl, void *data)
+{
+  int constant = (int)&data;
+
+  if (*rtl == NULL_RTX)
+    return 0;
+
+  if (GET_CODE (*rtl) == CONSTANT_P_RTX)
+    {
+      constant = CONSTANT_P (XEXP (*rtl, 0));
+      return 1;
+    }
+
+  return 0;
+}
+
+/* Resolve all remaining CONSTANT_P_RTX nodes.  */
 
 void
 purge_builtin_constant_p (void)
 {
-  rtx insn, set, arg, new, note;
+  rtx insn, set, new, note;
+  int constant = 0;
 
   for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
     if (INSN_P (insn)
-	&& (set = single_set (insn)) != NULL_RTX
-	&& (GET_CODE (arg = SET_SRC (set)) == CONSTANT_P_RTX
-	    || (GET_CODE (arg) == SUBREG
-		&& (GET_CODE (arg = SUBREG_REG (arg))
-		    == CONSTANT_P_RTX))))
+	&& (set = single_set (insn)) != NULL_RTX)
+      {
+	if (for_each_rtx (&insn, is_constant_p_rtx, &constant))
       {
-	arg = XEXP (arg, 0);
-	new = CONSTANT_P (arg) ? const1_rtx : const0_rtx;
+	    new = constant ? const1_rtx : const0_rtx;
 	validate_change (insn, &SET_SRC (set), new, 0);
 
 	/* Remove the REG_EQUAL note from the insn.  */
 	if ((note = find_reg_note (insn, REG_EQUAL, NULL_RTX)) != 0)
 	  remove_note (insn, note);
+	  }
       }
 }
 



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