|
| From: | Richard Henderson |
| Subject: | Re: [PATCH 03/10] target/ppc: Implemented vector divide instructions |
| Date: | Wed, 30 Mar 2022 15:06:31 -0600 |
| User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 |
On 3/30/22 14:25, Lucas Mateus Castro(alqotel) wrote:
+#define TRANS_VDIV_VMOD(FLAGS, NAME, VECE, FNI4_FUNC, FNI8_FUNC) \
+static bool trans_##NAME(DisasContext *ctx, arg_VX *a) \
+{ \
+ static const GVecGen3 op[2] = { \
+ { \
+ .fni4 = FNI4_FUNC, \
+ .fni8 = FNI8_FUNC, \
+ .vece = MO_32 \
+ }, \
+ { \
+ .fni4 = FNI4_FUNC, \
+ .fni8 = FNI8_FUNC, \
+ .vece = MO_64 \
+ }, \
+ }; \
There is zero point in having a two element array here: (1) VECE is a constant (2) The unused array element is actively wrong.
+#define DIV_VEC(NAME, SZ, DIV) \
+static void do_vx_##NAME(TCGv_##SZ t, TCGv_##SZ a, TCGv_##SZ b) \
+{ \
+ TCGv_##SZ zero = tcg_constant_##SZ(0), one = tcg_constant_##SZ(1); \
+ /* \
+ * If N/0 the instruction used by the backend might deliver \
+ * a signal to the process and the hardware returns 0 when \
+ * N/0, so if b = 0 return 0/1 \
+ */ \
+ tcg_gen_movcond_##SZ(TCG_COND_EQ, a, b, zero, zero, a); \
+ tcg_gen_movcond_##SZ(TCG_COND_EQ, b, b, zero, one, b); \
+ DIV(t, a, b); \
+}
The manual says N/0 = undefined. I don't think it's important to require 0.The signed versions still need to check for int_min / -1, which will fault on x86. Compare vs gen_op_arith_div{w,d}.
r~
| [Prev in Thread] | Current Thread | [Next in Thread] |