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]

Re: [patch] Speed up operand_equal_p during SSA optimizations.


Hi Richard,

>     +  /* Hanle a common case first.  For SSA_NAMEs, we can get away with a
>     +     pointer comparison.  */
>     +  if (TREE_CODE (arg0) == SSA_NAME && TREE_CODE (arg1) == SSA_NAME)
>     +    return arg0 == arg1;
> 
> I have a few questions about this.
> 
> (1) Why is this before the STRIP_NOPS?  It seems wrong to treat SSA_NAMEs
> differently than anything else in this respect.

We have code to do another pointer comparison after STRIP_NOPS.

> (2) Shouldn't we return 0 there if OEP_ONLY_CONST?

Yes.  Currently, the tree optimizers call operand_equal_p with flags
being 0 IIRC.

> (3) Why isn't the "&&" an "||"?  If either operand is an SSA_NAME, the only
> way they can be the same is if both are identical.

A good point.

> (4) Isn't this also the case for VAR_DECL?

I guess so, but I don't want to complicate the new check.  After all,
this is a hack.  Without my patch, operand_equal_p works just as well,
only slower.

I'll be testing the attached patch.

Kazu Hirata

Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.478
diff -u -d -p -r1.478 fold-const.c
--- fold-const.c	24 Nov 2004 15:57:08 -0000	1.478
+++ fold-const.c	26 Nov 2004 20:55:02 -0000
@@ -2331,6 +2331,12 @@ truth_value_p (enum tree_code code)
 int
 operand_equal_p (tree arg0, tree arg1, unsigned int flags)
 {
+  /* Handle a common case first.  For SSA_NAMEs, we can get away with a
+     pointer comparison.  */
+  if (!flags
+      && (TREE_CODE (arg0) == SSA_NAME || TREE_CODE (arg1) == SSA_NAME))
+    return arg0 == arg1;
+
   /* If either is ERROR_MARK, they aren't equal.  */
   if (TREE_CODE (arg0) == ERROR_MARK || TREE_CODE (arg1) == ERROR_MARK)
     return 0;


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