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

--- Comment #4 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:065433b4ce8d9676ba3be4871c520b8257f21c14

commit r15-5482-g065433b4ce8d9676ba3be4871c520b8257f21c14
Author: Jeff Law <j...@ventanamicro.com>
Date:   Tue Nov 19 19:24:41 2024 -0700

    [RISC-V][PR target/117649] Fix branch on masked values splitter

    Andreas reported GCC mis-compiled GAS for risc-v  Thankfully he also
reduced it
    to a nice little testcase.

    So the whole point of the pattern in question is to "reduce" the constants
by
    right shifting away common unnecessary bits in RTL expressions like this:

    >   [(set (pc)
    >         (if_then_else (any_eq
    >                     (and:ANYI (match_operand:ANYI 1 "register_operand"
"r")
    >                           (match_operand 2 "shifted_const_arith_operand"
"i"))
    >                     (match_operand 3 "shifted_const_arith_operand" "i"))
    >          (label_ref (match_operand 0 "" ""))
    >          (pc)))

    When applicable, the reduced constants in operands 2/3 fit into a simm12
and
    thus do not need multi-instruction synthesis.  Note that we have to also
shift
    operand 1.

    That shift should have been an arithmetic shift, but was incorrectly coded
as a
    logical shift.

    Fixed with the obvious change on the right shift opcode.

    Expecting to push to the trunk once the pre-commit tester renders its
verdict.
    I've already tested in this my tester for rv32 and rv64.

            PR target/117649
    gcc/
            * config/riscv/riscv.md (branch on masked/shifted operands): Use
            arithmetic rather than logical shift for operand 1.

    gcc/testsuite

            * gcc.target/riscv/branch-1.c: Update expected output.
            * gcc.target/riscv/pr117649.c: New test.

Reply via email to