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] combine.c: Convert (ne (and (lshiftrt (xor X CST) Y) 1) 0)into (eq (and (lshiftrt X Y) 1) 0). (take 2)


Hi,

Attached is a revised version of

http://gcc.gnu.org/ml/gcc-patches/2003-07/msg01358.html

incorporating suggestions from Jim Wilson at

http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00685.html

Visually inspected the replacements and built each affected target.

Tested on i686-pc-linux-gnu and h8300-hms.

OK to apply?

Kazu Hirata

2003-09-14  Kazu Hirata  <kazu@cs.umass.edu>

	* combine.c (simplify_comparison): Convert
	(ne (and (lshiftrt (xor X CST) Y) 1) 0) into
	(eq (and (lshiftrt X Y) 1) 0).

Index: combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.386
diff -c -r1.386 combine.c
*** combine.c	11 Sep 2003 13:01:32 -0000	1.386
--- combine.c	11 Sep 2003 15:39:58 -0000
***************
*** 10983,11001 ****
  	    }
  
  	  /* Convert (ne (and (lshiftrt (not X)) 1) 0) to
! 	     (eq (and (lshiftrt X) 1) 0).  */
  	  if (const_op == 0 && equality_comparison_p
  	      && XEXP (op0, 1) == const1_rtx
! 	      && GET_CODE (XEXP (op0, 0)) == LSHIFTRT
! 	      && GET_CODE (XEXP (XEXP (op0, 0), 0)) == NOT)
  	    {
! 	      op0 = simplify_and_const_int
! 		(op0, mode,
! 		 gen_rtx_LSHIFTRT (mode, XEXP (XEXP (XEXP (op0, 0), 0), 0),
! 				   XEXP (XEXP (op0, 0), 1)),
! 		 (HOST_WIDE_INT) 1);
! 	      code = (code == NE ? EQ : NE);
! 	      continue;
  	    }
  	  break;
  
--- 10983,11012 ----
  	    }
  
  	  /* Convert (ne (and (lshiftrt (not X)) 1) 0) to
! 	     (eq (and (lshiftrt X) 1) 0).
! 	     Also handle the case where (not X) is expressed using xor.  */
  	  if (const_op == 0 && equality_comparison_p
  	      && XEXP (op0, 1) == const1_rtx
! 	      && GET_CODE (XEXP (op0, 0)) == LSHIFTRT)
  	    {
! 	      rtx shift_op = XEXP (XEXP (op0, 0), 0);
! 	      rtx shift_count = XEXP (XEXP (op0, 0), 1);
! 
! 	      if (GET_CODE (shift_op) == NOT
! 		  || (GET_CODE (shift_op) == XOR
! 		      && GET_CODE (XEXP (shift_op, 1)) == CONST_INT
! 		      && GET_CODE (shift_count) == CONST_INT
! 		      && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT
! 		      && (INTVAL (XEXP (shift_op, 1))
! 			  == (HOST_WIDE_INT) 1 << INTVAL (shift_count))))
! 		{
! 		  op0 = simplify_and_const_int
! 		    (NULL_RTX, mode,
! 		     gen_rtx_LSHIFTRT (mode, XEXP (shift_op, 0), shift_count),
! 		     (HOST_WIDE_INT) 1);
! 		  code = (code == NE ? EQ : NE);
! 		  continue;
! 		}
  	    }
  	  break;
  


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