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

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jeff Law <l...@gcc.gnu.org>:

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

commit r15-4224-gc8957c8779954c3b0bade1dde0a8987b4db157b4
Author: Jovan Vukic <jovan.vu...@rt-rk.com>
Date:   Wed Oct 9 16:53:38 2024 -0600

    RISC-V: Optimize branches with shifted immediate operands

    After the valuable feedback I received, itâs clear to me that the
    oversight was in the tests showing the benefits of the patch. In the
    test file, I added functions f5 and f6, which now generate more
    efficient code with fewer instructions.

    Before the patch:

    f5:
            li      a4,2097152
            addi    a4,a4,-2048
            li      a5,1167360
            and     a0,a0,a4
            addi    a5,a5,-2048
            beq     a0,a5,.L4

    f6:
            li      a5,3407872
            addi    a5,a5,-2048
            and     a0,a0,a5
            li      a5,1114112
            beq     a0,a5,.L7

    After the patch:

    f5:
            srli    a5,a0,11
            andi    a5,a5,1023
            li      a4,569
            beq     a5,a4,.L5

    f6:
            srli    a5,a0,11
            andi    a5,a5,1663
            li      a4,544
            beq     a5,a4,.L9

            PR target/115921

    gcc/ChangeLog:

            * config/riscv/iterators.md (any_eq): New code iterator.
            * config/riscv/riscv.h (COMMON_TRAILING_ZEROS): New macro.
            (SMALL_AFTER_COMMON_TRAILING_SHIFT): Ditto.
            * config/riscv/riscv.md
(*branch<ANYI:mode>_shiftedarith_<optab>_shifted):
            New pattern.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/branch-1.c: Additional tests.

Reply via email to