On 12/17/20 7:55 AM, Jakub Jelinek wrote:
> Hi!
>
> We don't try to optimize for signed x, y (int) (x - 1U) * y + y
> into x * y, we can't do that with signed x * y, because the former
> is well defined for INT_MIN and -1, while the latter is not.
> We could perhaps optimize it during isel or some very late optimization
> where we'd turn magically flag_wrapv, but we don't do that yet.
>
> This patch optimizes it in simplify-rtx.c, such that we can optimize
> it during combine.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2020-12-17  Jakub Jelinek  <ja...@redhat.com>
>
>       PR rtl-optimization/98334
>       * simplify-rtx.c (simplify_context::simplify_binary_operation_1):
>       Optimize (X - 1) * Y + Y to X * Y or (X + 1) * Y - Y to X * Y.
>
>       * gcc.target/i386/pr98334.c: New test.
OK.  Though I think we could do this in gimple as well which would
probably eliminate the need to do it in RTL.

jeff

Reply via email to