This is the mail archive of the 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: [PATCH] Fix *two* AVR backend bugs (PR19293 + PR19329)

On Sun, Jan 23, 2005 at 08:17:25PM -0500, Paul Schlie wrote:

> If you're not going to treat positive out-of-range shift as a no-op,
> it might make sense to treat arithmetic right-shifts > mode-size as
> equivalent to it's maximum valid arithmetic right-shift, thereby:
>  (((signed >> y) >> y) == ((signed) x >> (2 * y))
> Thereby effectively saturating all positive shifts; but wonder if <= 0
> shifts might be most efficiently handled as a no-op, i.e. logically only
> shifting  while count > 0 ?

See the patch I sent yesterday - it is supposed to do exactly that.
All shift counts <= 0 are handled as a no-op in out_shift_with_cnt.
For ashl* and lshr*, shift count >= mode_size returns 0.
For ashr*, shift count >= mode_size works like (mode_size - 1)
which copies the sign bit to all bits of the result.

The optimization in out_shift_with_cnt (where one bit is set in
__zero_reg__) only works for constant shift count in the range 1...7
and only if no hand-optimized code was output by an earlier "switch"
statement - it's not "modulo 8".  No out of range counts here.

> (but still wonder if GCC things the cc is set for shifts of 0 if not
> optimized away?)

See my patch - it includes a change in notice_update_cc for ashrqi3.



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