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

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Naveen H.S <[email protected]>:

https://gcc.gnu.org/g:f36a26b24c524434b11908f0e56ff33dba517f6b

commit r17-1951-gf36a26b24c524434b11908f0e56ff33dba517f6b
Author: Naveen <[email protected]>
Date:   Sun Jun 28 20:36:13 2026 -0700

    match.pd: Simplify (signed)A >= 0 & (A & INT_MAX) != 0 to (signed)A > 0
[PR112390]

    The patch adds simplifications for the pattern where a sign-bit check and a
    lower-bits check are combined with a bitwise or logical AND/OR:

      (1) ((signed)A >= 0) &/&& ((A & INT_MAX) != 0)  -->  (signed)A > 0
      (2) ((signed)A <  0) |/|| ((A & INT_MAX) == 0)  -->  (signed)A <= 0

    Both patterns arise naturally from code that separately tests the sign
    bit and the magnitude of an unsigned integer.  The combined expression
    is equivalent to a single signed comparison, and the simplification
    eliminates the intermediate BIT_AND_EXPR mask as well as the weaker
    comparison operator.

    gcc/ChangeLog:
            PR tree-optimization/112390
            * match.pd: Add simplifications for combined sign-bit and
            magnitude checks:
            ((signed)A >= 0) &/&& ((A & INT_MAX) != 0) -> (signed)A > 0
            ((signed)A <  0) |/|| ((A & INT_MAX) == 0) -> (signed)A <= 0

    gcc/testsuite/ChangeLog:
            PR tree-optimization/112390
            * gcc.dg/pr112390.c: New test.
            * gcc.dg/pr112390_bitint.c: New test.

    Signed-off-by: Naveen <[email protected]>
  • [Bug tree-optimization/112390] ... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to