On 01/12/15 13:28, Jakub Jelinek wrote:
Hi!

This patch optimizes away TRUNC_MOD_EXPR by constant second argument
(if not 0 and not type's minimum) if the range of the first argument
is already known to be [-op1 + 1, op1 - 1] or its subset.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2015-01-12  Jakub Jelinek  <ja...@redhat.com>

        PR tree-optimization/64454
        * tree-vrp.c (simplify_div_or_mod_using_ranges): Optimize
        op0 % op1 into op0 if op0 is in range [-op1 + 1, op1 - 1]
        for signed or [0, op1 - 1] for unsigned modulo.
        (simplify_stmt_using_ranges): Call simplify_div_or_mod_using_ranges
        even if op1 does not satisfy integer_pow2p.

        * gcc.dg/pr64454.c: New test.
OK.
jeff

Reply via email to