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

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

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

commit r17-6655-gdbb0de198bbd3c9b194218ae56292b7095201124
Author: Jeff Law <[email protected]>
Date:   Tue Nov 24 13:18:54 2026 -0700

    [PR rtl-optimization/128767] Simplify AND/OR special case down to umax/umin

    This next patch for pr128767.

    The basic problem this patch is meant to solve is discovery that some of
the
    runtime aliasing checks for loop versioning collapse down to min/max tests.

    Given X and Y, if if we have a test like (X <=u C1) & (Y <=u C1) we can
    simplify that into umax (X, Y) <=u C. There's an analogue for transforming
into
    umin.  Handling both turns out to be useful as well as well as the
inversions.

    In total these save about 67 million instructions in x264 on RISC-V on
paths
    that select between a scalar and vector loop, so small, but still worth
    improving.  Most of the meaningful cases were in x264_macroblock_*
routines.

    This has been bootstrapped and regression tested as part of a larger set of
    changes to improve these aliasing test sequences on x86_64, aarch64, K3, K1
and
    c920 designs.  It's also survived all the usual embedded targets, though I
    doubt there's any meaningful changes on those.

    Assisted-by: Claude for discovery, analysis and testcase generation.

    Pushing to the trunk after waiting on Sashiko (and yes, I know there's a
    Sashiko issue to resolve with my previous commit, testing that is in
flight).

            PR rtl-optimization/128767
    gcc
            * simplify-rtx.cc (simplify_unsigned_cmp_minmax): New function.
            (simplify_context::simplify_binary_operation_1): For AND/IOR, call
            simplify_unsigned_cmp_minmax.

    gcc/testsuite
            * gcc.target/riscv/zbb-minmax-cmp-uns-1.c: New test.
            * gcc.target/riscv/zbb-minmax-cmp-uns-2.c: New test.
            * gcc.target/riscv/zbb-minu-leu-1.c: New test.
            * gcc.target/riscv/zbb-minu-leu-2.c: New test.
            * gcc.target/riscv/zbb-minu-leu-3.c: New test.
            * gcc.target/riscv/zbb-minu-leu-4.c: New test.

Reply via email to