This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix wrong-code bug caused by combine_simplify_rtx()
- From: Paul Schlie <schlie at comcast dot net>
- To: Richard Sandiford <rsandifo at redhat dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 08 Apr 2005 12:12:31 -0400
- Subject: Re: Fix wrong-code bug caused by combine_simplify_rtx()
> Anyway, combine misoptimises:
>
> int s;
> ...
> (signed char) (s - 100) - 5
>
> rewriting it into:
>
> (plus:SI (sign_extend:SI (subreg:QI (reg:SI s) 0))
> (const_int -105))
The following would have been optimally correct:
(sign_ext:QI (plus:QI (subreg:QI (reg:SI s) 0)
(const_int -105)))
As there's no reason to perform modular operations with greater precision
than it's target. (and the terminal sign_extend simply denotes the resulting
value as being signed as may be required if it's a sub-expression).
(the code should be swapping the inner sign-extend with the outer modular
operation, thereby simplifying by demoting the rank of both in the process.)
Maybe this should be fixed, rather than removed?