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: 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?





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