This is the mail archive of the
mailing list for the GCC project.
Re: [patch] Speed up operand_equal_p during SSA optimizations.
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: kenner at vlsi1 dot ultra dot nyu dot edu
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 26 Nov 2004 15:58:54 -0500 (EST)
- Subject: Re: [patch] Speed up operand_equal_p during SSA optimizations.
- References: <10411262042.AA13472@vlsi1.ultra.nyu.edu>
> + /* 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,
I'll be testing the attached patch.
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)
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)