qemu-devel
[Top][All Lists]
Advanced

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

Re: [RFC PATCH v2 30/44] target/loongarch: Implement vclo vclz


From: gaosong
Subject: Re: [RFC PATCH v2 30/44] target/loongarch: Implement vclo vclz
Date: Fri, 7 Apr 2023 15:40:36 +0800
User-agent: Mozilla/5.0 (X11; Linux loongarch64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0


在 2023/4/2 上午11:34, Richard Henderson 写道:
On 3/27/23 20:06, Song Gao wrote:
+#define DO_CLO_B(N)  (clz32((uint8_t)~N) - 24)
+#define DO_CLO_H(N)  (clz32((uint16_t)~N) - 16)

I think this is wrong.
It is wried,  the result is always right. :-\
and  (clz32(~N) - 24)  or (clz32((uint32_t)~N) - 24) is wrong.
You *want* the high bits to be set, so that they are ones, and included in the count, which you then subtract off.  You want the "real" count to start after the 24th leading 1.

Yes,
and  we use clz32(),   how about the following way?

#define DO_CLO_B(N)  (clz32( ~N & 0xff) -24)
#define DO_CLO_H(N)  (clz32( ~N & 0xffff) -16)

Thanks.
Song Gao




reply via email to

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