qemu-devel
[Top][All Lists]
Advanced

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

Re: [RFC PATCH v2 09/44] target/loongarch: Implement vhaddw/vhsubw


From: gaosong
Subject: Re: [RFC PATCH v2 09/44] target/loongarch: Implement vhaddw/vhsubw
Date: Wed, 29 Mar 2023 11:24:00 +0800
User-agent: Mozilla/5.0 (X11; Linux loongarch64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0


在 2023/3/29 上午4:17, Richard Henderson 写道:
On 3/27/23 20:05, Song Gao wrote:
+#define DO_ODD_EVEN_S(NAME, BIT, T, E1, E2, DO_OP)                 \
+void HELPER(NAME)(CPULoongArchState *env,                          \
+                  uint32_t vd, uint32_t vj, uint32_t vk)           \
+{                                                                  \
+    int i;                                                         \
+    VReg *Vd = &(env->fpr[vd].vreg);                               \
+    VReg *Vj = &(env->fpr[vj].vreg);                               \
+    VReg *Vk = &(env->fpr[vk].vreg);                               \
+                                                                   \
+    for (i = 0; i < LSX_LEN/BIT; i++) {                            \
+        Vd->E1(i) = DO_OP((T)Vj->E2(2 * i + 1), (T)Vk->E2(2 * i)); \
+ }                                                              \
+}
...
+#define DO_ODD_EVEN_U(NAME, BIT, TD, TS, E1, E2, DO_OP)                     \ +void HELPER(NAME)(CPULoongArchState *env,                                    \ +                  uint32_t vd, uint32_t vj, uint32_t vk)                     \
+{ \
+    int i; \
+    VReg *Vd = &(env->fpr[vd].vreg); \
+    VReg *Vj = &(env->fpr[vj].vreg); \
+    VReg *Vk = &(env->fpr[vk].vreg); \
+ \
+    for (i = 0; i < LSX_LEN/BIT; i++) {                                      \ +        Vd->E1(i) = DO_OP((TD)(TS)Vj->E2(2 * i + 1), (TD)(TS)Vk->E2(2 * i)); \
+ } \
+}

In the first case we have one cast, in the second case we have two.  I wonder if it would be clearer to have both signed and unsigned members in the VReg union?

I really agree this.

Then these two macros could be combined.

I also think we could make use of (__typeof(Vd->E1(0))) instead of separately passing the output type?  It would appear to be less error-prone.

I will try this on v3.

Thanks.
Song Gao




reply via email to

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