On 1/16/21 11:13 AM, Jakub Jelinek wrote:
> Hi!
>
> The following patch tests both x / y * y and x - x % y expansion for the
> former GIMPLE code and chooses the cheaper of those sequences.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2021-01-16 Jakub Jelinek <ja...@redhat.com>
>
> PR tree-optimization/96696
> * expr.c (expand_expr_divmod): New function.
> (expand_expr_real_2) <case TRNC_DIV_EXPR>: Use it for truncations and
> divisions. Formatting fixes.
> <case MULT_EXPR>: Optimize x / y * y as x - x % y if the latter is
> cheaper.
>
> * gcc.target/i386/pr96696.c: New test.
Given this is strictly a missed optimization, I'd lean towards deferring
to gcc-12 at this point. Thoughts?
jeff