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

--- Comment #8 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:54dd6575fa5ba7554396039820bee88d4dddab6d

commit r17-2184-g54dd6575fa5ba7554396039820bee88d4dddab6d
Author: Naveen <[email protected]>
Date:   Tue Jul 7 01:41:44 2026 -0700

    tree-optimization: Extend CDCE memset shrink-wrapping to {0, N} ranges
[PR102202]

    The patch extends the CDCE shrink-wrapping support added for PR102202.

    The existing transform handles memset calls whose length is known to be
    in [0, 1].  It bypasses the call for length zero and specializes the
    nonzero path to a constant length of one.

    Extend this to exact two-value length ranges {0, N}, where N is a
    nonzero integer constant.  The zero-length path is still bypassed and
    the nonzero path is specialized to the constant N.  In particular, the
    transform does not accept an ordinary interval [0, N] since such an
    interval can contain values other than zero and N.

    The range query now returns the nonzero member of either a [0, 1] range
    or an exact {0, N} range.  The existing [0, 1] behavior is preserved.

    gcc/ChangeLog:
            PR tree-optimization/102202
            * tree-call-cdce.cc: Include "value-query.h" and "value-range.h".
            (len_has_boolean_range_p): Remove.
            (get_len_nonzero_value): New function. Return the nonzero member of
            LEN's value range when it is a boolean range [0, 1] or an exact
            two-value set {0, N}.
            (can_shrink_wrap_len_p): Replace len_has_boolean_range_p call with
            get_len_nonzero_value. Add NONZERO_LEN output parameter and set it
            to the returned nonzero value on success.
            (shrink_wrap_len_call): Use it to pin the length argument on the
            guarded call path instead of build_one_cst.
            (shrink_wrap_conditional_dead_built_in_calls): Declare local
            nonzero_len and pass it to can_shrink_wrap_len_p and forward it to
            shrink_wrap_len_call.
            (pass_call_cdce::execute): Pass nullptr as NONZERO_LEN to
            can_shrink_wrap_len_p.

    gcc/testsuite/ChangeLog:
            PR tree-optimization/102202
            * gcc.dg/pr102202-3.c: New test.
            * gcc.dg/pr102202-4.c: New test.

    Signed-off-by: Naveen <[email protected]>

Reply via email to