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

--- Comment #1 from Jeffrey A. Law <law at gcc dot gnu.org> ---
For rv64 I think the first and second sequences are probably optimal.

The 3rd can be better implemented with a logical right shift and comparison
against a simplified constant:

        srli    a0, a0, 32
        sltiu   a0, a0, 3

The 4th can be improved using similar ideas to:

        srli    a0, a0, 32
        sltiu   a0, a0, 3
        xori    a0, a0, 1

But what would be even better (the li has no incoming data dependency):
        srli    a0, a0, 32
        li      temp, 2
        sgtu    a0,a0,temp


In both the func3 and func4 cases we probably need to fix the mvconst_internal
issues for risc-v.

Reply via email to