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] minor correction in RTL simplification


hi,
The simplify_binary_operation_1 function in simplify-rtx.c, when trying
to simplify expressions like (a & a) and (a ^ a) uses pointer comparison
to check for equality of the two operands, which does not always capture
the required condition, and can lead to sub-optimal code. The attached
patch replaces this check by an rtx_equal_p check. The patch has been
tested on an i686-pc-linux-gnu target. comments?

regards
saurabh


ChangeLog
---------

2005-09-05  Saurabh Verma  <saurabh.verma@codito.com>

	* simplify-rtx.c (simplify_binary_operation_1): Correct the 
	condition for detecting cases like (a&a) and (a^a).

Index: simplify-rtx.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/simplify-rtx.c,v
retrieving revision 1.245
diff -p -u -r1.245 simplify-rtx.c
--- simplify-rtx.c	2 Sep 2005 12:04:22 -0000	1.245
+++ simplify-rtx.c	5 Sep 2005 09:11:08 -0000
@@ -1653,7 +1653,7 @@ simplify_binary_operation_1 (enum rtx_co
 	  && ((INTVAL (trueop1) & GET_MODE_MASK (mode))
 	      == GET_MODE_MASK (mode)))
 	return simplify_gen_unary (NOT, mode, op0, mode);
-      if (trueop0 == trueop1
+      if (rtx_equal_p (trueop0, trueop1)
 	  && ! side_effects_p (op0)
 	  && GET_MODE_CLASS (mode) != MODE_CC)
 	 return CONST0_RTX (mode);
@@ -1688,7 +1688,7 @@ simplify_binary_operation_1 (enum rtx_co
 	  && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT
 	  && (nonzero_bits (trueop0, mode) & ~INTVAL (trueop1)) == 0)
 	return op0;
-      if (trueop0 == trueop1 && ! side_effects_p (op0)
+      if (rtx_equal_p (trueop0, trueop1) && ! side_effects_p (op0)
 	  && GET_MODE_CLASS (mode) != MODE_CC)
 	return op0;
       /* A & (~A) -> 0 */

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