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]

Simplify shifts better in combine


Hi,
this patch simplifies few more shifts that are known to be constant.

Honza

/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
/* { dg-options "-O2 -march=k8" } */
/* { dg-final { scan-assembler "sal" } } */
unsigned char magic;
int
t()
{
  int m=magic;
  return m>>10;
}

Wed Feb 19 18:45:45 CET 2003  Jan Hubicka  <jh at suse dot cz>
	* combine.c (simplify_shift_const):  Simplify few special cases
	into constants.
Index: combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.323.2.10
diff -c -3 -p -r1.323.2.10 combine.c
*** combine.c	16 Feb 2003 18:50:05 -0000	1.323.2.10
--- combine.c	19 Feb 2003 17:45:28 -0000
*************** simplify_shift_const (x, code, result_mo
*** 9417,9422 ****
--- 9417,9436 ----
  	      == 0))
  	code = LSHIFTRT;
  
+       if (code == ASHIFTRT
+ 	  && (num_sign_bit_copies (varop, shift_mode) + count
+ 	      >= GET_MODE_BITSIZE (shift_mode)))
+ 	return constm1_rtx;
+       if (code == LSHIFTRT
+ 	  && GET_MODE_BITSIZE (shift_mode) <= HOST_BITS_PER_WIDE_INT
+ 	  && !((unsigned)nonzero_bits (varop, shift_mode) >> count))
+ 	return const0_rtx;
+       if (code == ASHIFT
+ 	  && GET_MODE_BITSIZE (shift_mode) <= HOST_BITS_PER_WIDE_INT
+ 	  && !(((unsigned)nonzero_bits (varop, shift_mode) << count)
+ 	       && GET_MODE_MASK (shift_mode)))
+ 	return const0_rtx;
+ 
        switch (GET_CODE (varop))
  	{
  	case SIGN_EXTEND:


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