This is the mail archive of the
mailing list for the GCC project.
[RFC] Do pointer comparison first in operand_equal_p
- From: Diego Novillo <dnovillo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Roger Sayle <roger at eyesopen dot com>
- Date: Fri, 13 May 2005 11:00:42 -0400
- Subject: [RFC] Do pointer comparison first in operand_equal_p
This patch implements what I asked in
The time savings are negligible but measurable in the tree passes
(saves about 1% of compile time in the tree optimizers).
Bootstrapped and tested x86, x86_64, ia64 and ppc64.
Jeff had some doubts about the approach. Roger, what do you
think? Any reason why this would be unsafe in general?
* fold-const.c (operand_equal_p): Do pointer comparison first
for operands with no side effects.
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.578
diff -d -u -p -r1.578 fold-const.c
--- fold-const.c 11 May 2005 15:21:23 -0000 1.578
+++ fold-const.c 13 May 2005 14:50:55 -0000
@@ -2363,6 +2363,10 @@ truth_value_p (enum tree_code code)
operand_equal_p (tree arg0, tree arg1, unsigned int flags)
+ /* An operand is always equal to itself if it doesn't side effects. */
+ if (arg0 == arg1 && !TREE_SIDE_EFFECTS (arg0))
+ return 1;
/* If either is ERROR_MARK, they aren't equal. */
if (TREE_CODE (arg0) == ERROR_MARK || TREE_CODE (arg1) == ERROR_MARK)