https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127092

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrea Pinski <[email protected]>:

https://gcc.gnu.org/g:0acb69bf9bb0db14b7e230fb5370257c530fb6e8

commit r17-3869-g0acb69bf9bb0db14b7e230fb5370257c530fb6e8
Author: Andrea Pinski <[email protected]>
Date:   Mon Aug 31 21:22:49 2026 -0700

    range-op: Fix some divisions [PR127092]

    This was an oversight of not knowing there are a few different
    integer divisions and how they will round.
    When `a < b` and for non-negative a and b, `a/b` will be 0 iff for
    truncate (TRUNC_DIV_EXPR), exact (EXACT_DIV_EXPR)
    and floor division (FLOOR_DIV_EXPR).
    Ceiling division (CEIL_DIV_EXPR) will be 1 for positive a and zero when a
is 0.
    Rounding division (ROUND_DIV_EXPR) it is based on the how far a is from b.
    We can skip the ceiling division case since it is not used that much.
    And rounding division case is too hard to figure out here so that is
skipped
    also.

    Bootstrapped and tested on x86_64-linux-gnu.

            PR tree-optimization/127092

    gcc/ChangeLog:

            * range-op.cc (operator_div::op1_op2_relation_effect): Only
            handle TRUNC_DIV_EXPR, EXACT_DIV_EXPR and FLOOR_DIV_EXPR
            for the `a < b` case.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/pr127092-1.f90: New test.

    Signed-off-by: Andrea Pinski <[email protected]>

Reply via email to