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]

Re: Fold constant shifts in combine


> > > The sign extension is not handled correctly.
> > Hmm, I will try to dig into this at the evening.
> 
> Thanks.  I had a hard drive fail on one of my systems last week and
> will be spending the next couple of days trying to recover as much as
> possible.
> 
> The above code is used in slightly different variants to disassemble
> the PA "bl" instruction.  The affects function pointer canonicalization
> on hppa-linux and disassebly in binutils.
> 
> The problem has something to do with the "+=" or pointer addition
> in the testcase.  The latter involves a left shift, so this maybe
> the code affected by your patch.  The correct offset is calculated
> if the result of the bit extraction, recomposition and sign extension
> is assigned to an int variable.
Hi,
the problem is that function deals with moving inner operands outside
that I missed.  I am testing the attached patch and will install it as
obivous in case it will pass.

Thanks for the testcase! (and wish you good luck with rescuescing your
data)
Honza

Mon Feb 24 18:23:15 CET 2003  Jan Hubicka  <jh at suse dot cz>
	* combine.c (simplify_shift_const):  Fix previous patch.
Index: combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.342
diff -c -3 -p -r1.342 combine.c
*** combine.c	20 Feb 2003 20:56:51 -0000	1.342
--- combine.c	24 Feb 2003 17:23:04 -0000
*************** simplify_shift_const (x, code, result_mo
*** 9434,9445 ****
        if (code == LSHIFTRT
  	  && GET_MODE_BITSIZE (shift_mode) <= HOST_BITS_PER_WIDE_INT
  	  && !(nonzero_bits (varop, shift_mode) >> count))
! 	return const0_rtx;
        if (code == ASHIFT
  	  && GET_MODE_BITSIZE (shift_mode) <= HOST_BITS_PER_WIDE_INT
  	  && !((nonzero_bits (varop, shift_mode) << count)
  	       & GET_MODE_MASK (shift_mode)))
! 	return const0_rtx;
  
        switch (GET_CODE (varop))
  	{
--- 9434,9445 ----
        if (code == LSHIFTRT
  	  && GET_MODE_BITSIZE (shift_mode) <= HOST_BITS_PER_WIDE_INT
  	  && !(nonzero_bits (varop, shift_mode) >> count))
! 	varop = const0_rtx;
        if (code == ASHIFT
  	  && GET_MODE_BITSIZE (shift_mode) <= HOST_BITS_PER_WIDE_INT
  	  && !((nonzero_bits (varop, shift_mode) << count)
  	       & GET_MODE_MASK (shift_mode)))
! 	varop = const0_rtx;
  
        switch (GET_CODE (varop))
  	{


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