[preliminary patch] Fix rtl-optimization/27538.

Roger Sayle roger@eyesopen.com
Sat May 13 09:21:00 GMT 2006


Hi Kazu,
> Attached is a preliminary patch to fix rtl-optimization/27538.
> ...
> Now, I understand this is a hack, but I hope this is enough to start a
> discussion towards a correct fix.

Hmm.  I think you're close.  I suspect the best place to handle this is
in  expand_compound_operation where we should be extending the "varop"
operand ourselves, and where we have a safe fallback if that fails.
How about something like:

    modewidth = GET_MODE_BITSIZE (GET_MODE (x));
    if (modewidth + len >= pos)
!     tem = simplify_shift_const (NULL_RTX, unsignedp ? LSHIFTRT : ASHIFTRT,
! 				GET_MODE (x),
! 				simplify_shift_const (NULL_RTX, ASHIFT,
! 						      GET_MODE (x),
! 						      XEXP (x, 0),
! 						      modewidth - pos - len),
! 				modewidth - len);
!
    else if (unsignedp && len < HOST_BITS_PER_WIDE_INT)
      tem = simplify_and_const_int (NULL_RTX, GET_MODE (x),
  				  simplify_shift_const (NULL_RTX, LSHIFTRT,
--- 5736,5749 ----

    modewidth = GET_MODE_BITSIZE (GET_MODE (x));
    if (modewidth + len >= pos)
!     {
!       enum machine_mode mode = GET_MODE (x);
!       tem = gen_lowpart (mode, XEXP (x, 0));
!	if (!tem || GET_CODE (tem) == CLOBBER)
!         return x;
!       tem = simplify_shift_const (NULL_RTX, ASHIFT, mode,
! 				  tem, modewidth - pos - len);
!       tem = simplify_shift_const (NULL_RTX, unsignedp ? LSHIFTRT : ASHIFTRT,
! 				  mode, tem, modwidth - len);
!     }
    else if (unsignedp && len < HOST_BITS_PER_WIDE_INT)
      tem = simplify_and_const_int (NULL_RTX, GET_MODE (x),
  				  simplify_shift_const (NULL_RTX, LSHIFTRT,


> Comments?

This should have pretty much the same behaviour as your patch but
without the hackish maybe_simplify_shift_const.  Sound reasonable?
I agree that the invariants for simplify_shift_const of result_mode
vs. GET_MODE (varop) are pretty ugly through out combine.c.

Roger
--



More information about the Gcc-patches mailing list