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]

[patch] cse.c: Avoid unnecessary calls to equiv_constant.


Hi,

Attached is a patch to avoid unnecessary calls to equiv_constant.

Consider the "if" statement shown in the patch.  After you take
"break;", all we have left to do is

  return new ? new : x;

So we don't need to call equiv_constant if we are taking "break;".

While compiling cc1-i files, the "if" statement has about a million
hits.  Of those, 0.7% take "break;".

Tested on i686-pc-linux-gnu.  OK to apply?

Kazu Hirata

2005-01-26  Kazu Hirata  <kazu@cs.umass.edu>

	* cse.c (fold_rtx): Call equiv_constant only when necessary.

Index: cse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cse.c,v
retrieving revision 1.331
diff -U4 -d -p -r1.331 cse.c
--- cse.c	23 Jan 2005 19:13:50 -0000	1.331
+++ cse.c	26 Jan 2005 00:48:19 -0000
@@ -3876,18 +3879,19 @@ fold_rtx (rtx x, rtx insn)
 #endif
 
 	  code = find_comparison_args (code, &folded_arg0, &folded_arg1,
 				       &mode_arg0, &mode_arg1);
-	  const_arg0 = equiv_constant (folded_arg0);
-	  const_arg1 = equiv_constant (folded_arg1);
 
 	  /* If the mode is VOIDmode or a MODE_CC mode, we don't know
 	     what kinds of things are being compared, so we can't do
 	     anything with this comparison.  */
 
 	  if (mode_arg0 == VOIDmode || GET_MODE_CLASS (mode_arg0) == MODE_CC)
 	    break;
 
+	  const_arg0 = equiv_constant (folded_arg0);
+	  const_arg1 = equiv_constant (folded_arg1);
+
 	  /* If we do not now have two constants being compared, see
 	     if we can nevertheless deduce some things about the
 	     comparison.  */
 	  if (const_arg0 == 0 || const_arg1 == 0)


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