Hi Jeff,

On Mon, 2024-09-02 at 12:53 -0600, Jeff Law wrote:
>  (define_insn_and_split "<optab>_shift_reverse<X:mode>"
>    [(set (match_operand:X 0 "register_operand" "=r")
>      (any_bitwise:X (ashift:X (match_operand:X 1 "register_operand" "r")
> @@ -2934,9 +2936,9 @@ (define_insn_and_split "<optab>_shift_reverse<X:mode>"
>    "(!SMALL_OPERAND (INTVAL (operands[3]))
>      && SMALL_OPERAND (INTVAL (operands[3]) >> INTVAL (operands[2]))
>      && popcount_hwi (INTVAL (operands[3])) > 1

I'm wondering why we need to check the popcount.  With this patch
applied:

long
test1 (long x)
{
  return (x & 0x110) << 12;
}

is compiled to:

test1:
        andi    a0,a0,272
        slli    a0,a0,12
        ret

as we've expected, but:

long
test2 (long x)
{
  return (x & 0x100) << 12;
}

is compiled to:

test:
        li      a5,1048576
        slli    a0,a0,12
        and     a0,a0,a5
        ret

So why must we spend an instruction to load the single-bit immediate?

-- 
Xi Ruoyao <xry...@xry111.site>
School of Aerospace Science and Technology, Xidian University

Reply via email to