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]

Be careful in combine.c when commuting XOR and ASHIFRT


This fixes a bug in compiling the Ada run-time file s-crc32.adb on Alpha/VMS.
Tested on x86-pc-linux.

2004-01-30  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* combine.c (simplify_shift_const, case XOR): Be careful when
	commuting XOR with ASHIFTRT.

*** combine.c	25 Jan 2004 11:11:47 -0000	1.404
--- combine.c	30 Jan 2004 14:40:23 -0000
*************** simplify_shift_const (rtx x, enum rtx_co
*** 9569,9572 ****
--- 9569,9577 ----
  
  	  if (GET_CODE (XEXP (varop, 1)) == CONST_INT
+ 	      /* We can't do this if we have (ashiftrt (xor))  and the
+ 		 constant has its sign bit set in shift_mode.  */
+ 	      && !(code == ASHIFTRT && GET_CODE (varop) == XOR
+ 		   && 0 > trunc_int_for_mode (INTVAL (XEXP (varop, 1)),
+ 					      shift_mode))
  	      && (new = simplify_binary_operation (code, result_mode,
  						   XEXP (varop, 1),
*************** simplify_shift_const (rtx x, enum rtx_co
*** 9582,9597 ****
  	  /* If we can't do that, try to simplify the shift in each arm of the
  	     logical expression, make a new logical expression, and apply
! 	     the inverse distributive law.  */
! 	  {
! 	    rtx lhs = simplify_shift_const (NULL_RTX, code, shift_mode,
! 					    XEXP (varop, 0), count);
! 	    rtx rhs = simplify_shift_const (NULL_RTX, code, shift_mode,
! 					    XEXP (varop, 1), count);
  
! 	    varop = gen_binary (GET_CODE (varop), shift_mode, lhs, rhs);
! 	    varop = apply_distributive_law (varop);
  
! 	    count = 0;
! 	  }
  	  break;
  
--- 9587,9606 ----
  	  /* If we can't do that, try to simplify the shift in each arm of the
  	     logical expression, make a new logical expression, and apply
! 	     the inverse distributive law.  This also can't be done
! 	     for some (ashiftrt (xor)).  */
! 	  if (code != ASHIFTRT || GET_CODE (varop)!= XOR
! 	      || 0 <= trunc_int_for_mode (INTVAL (XEXP (varop, 1)),
! 					  shift_mode))
! 	    {
! 	      rtx lhs = simplify_shift_const (NULL_RTX, code, shift_mode,
! 					      XEXP (varop, 0), count);
! 	      rtx rhs = simplify_shift_const (NULL_RTX, code, shift_mode,
! 					      XEXP (varop, 1), count);
  
! 	      varop = gen_binary (GET_CODE (varop), shift_mode, lhs, rhs);
! 	      varop = apply_distributive_law (varop);
  
! 	      count = 0;
! 	    }
  	  break;
  


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