[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC 02/15] target/riscv: rvb: count leading/trailing zeros

From: Richard Henderson
Subject: Re: [RFC 02/15] target/riscv: rvb: count leading/trailing zeros
Date: Thu, 19 Nov 2020 11:24:38 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

On 11/18/20 12:29 AM, frank.chang@sifive.com wrote:
> +static bool gen_cxzw(DisasContext *ctx, arg_r2 *a,
> +                     void(*func)(TCGv_i32, TCGv_i32, uint32_t))
> +static bool gen_cxz(DisasContext *ctx, arg_r2 *a,
> +                    void(*func)(TCGv, TCGv, target_ulong))

I think both of these are unnecessary and you should use the gen_unary that you
introduce in the next patch.  ctz/clz cannot produce a negative number and do
not need extension.

You should simply add wrappers like you do for gen_pcntw to truncate and 

static void gen_ctz(TCGv ret, TCGv arg1)
    tcg_gen_ctz_tl(ret, arg1, TARGET_LONG_BITS);

static void gen_clz(TCGv ret, TCGv arg1)
    tcg_gen_clz_tl(ret, arg1, TARGET_LONG_BITS);

static void gen_ctzw(TCGv ret, TCGv arg1)
    tcg_gen_ori_i64(ret, arg1, MAKE_64BIT_MASK(32, 32));
    tcg_gen_ctz_i64(ret, ret, 32);

static void gen_clzw(TCGv ret, TCGv arg1)
    tcg_gen_ext32u_i64(ret, arg1);
    tcg_gen_ctz_i64(ret, ret, 64);
    tcg_gen_subi_i64(ret, ret, 32);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]