Skip to contentSkip to conversation

target-ppc: use softfloat min/max functions

PATCH In review Aurelien Jarno 3 participants 3 messages Apr 18, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-ppc: use softfloat min/max functions

Use the new softfloat float32_min() and float32_max() to implement the vminfp and vmaxfp instructions.

---
 target-ppc/op_helper.c |   16 +++++-----------
 1 files changed, 5 insertions(+), 11 deletions(-)
target-ppc/op_helper.c +5 -11
index 9aa108e..9058d78 100644
@@ -2369,22 +2369,16 @@ VMINMAX(uw, u32)
 #undef VMINMAX_DO
 #undef VMINMAX
 
-#define VMINMAXFP(suffix, rT, rF)                                       \
-    void helper_v##suffix (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)    \
+#define VMINMAXFP(suffix)                                               \
+    void helper_v##suffix##fp (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)\
     {                                                                   \
         int i;                                                          \
         for (i = 0; i < ARRAY_SIZE(r->f); i++) {                        \
-            HANDLE_NAN2(r->f[i], a->f[i], b->f[i]) {                    \
-                if (float32_lt_quiet(a->f[i], b->f[i], &env->vec_status)) { \
-                    r->f[i] = rT->f[i];                                 \
-                } else {                                                \
-                    r->f[i] = rF->f[i];                                 \
-                }                                                       \
-            }                                                           \
+            r->f[i] = float32_##suffix(a->f[i], b->f[i], &env->vec_status); \
         }                                                               \
     }
-VMINMAXFP(minfp, a, b)
-VMINMAXFP(maxfp, b, a)
+VMINMAXFP(min)
+VMINMAXFP(max)
 #undef VMINMAXFP
 
 void helper_vmladduhm (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
Signature · 1 line
1.7.2.3
#1 lore raw
Quoted 22 lines · Aurelien Jarno
target-ppc/op_helper.c +2 -9
index 9aa108e..9058d78 100644
@@ -2369,22 +2369,16 @@ VMINMAX(uw, u32)
  #undef VMINMAX_DO
  #undef VMINMAX
 
-#define VMINMAXFP(suffix, rT, rF)                                       \
-    void helper_v##suffix (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)    \
+#define VMINMAXFP(suffix)                                               \
+    void helper_v##suffix##fp (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)\
     {                                                                   \
         int i;                                                          \
         for (i = 0; i < ARRAY_SIZE(r->f); i++) {                        \
-            HANDLE_NAN2(r->f[i], a->f[i], b->f[i]) {                    \
-                if (float32_lt_quiet(a->f[i], b->f[i], &env->vec_status)) { \
-                    r->f[i] = rT->f[i];                                 \
-                } else {                                                \
-                    r->f[i] = rF->f[i];                                 \
-                }                                                       \
-            }                                                           \

target-ppc/op_helper.c VMINMAX(uw, u32) · line 2384

Quoted 10 lines
target-ppc/op_helper.c +3 -2
+            r->f[i] = float32_##suffix(a->f[i], b->f[i], &env->vec_status); \
         }                                                               \
     }
-VMINMAXFP(minfp, a, b)
-VMINMAXFP(maxfp, b, a)
+VMINMAXFP(min)
+VMINMAXFP(max)
  #undef VMINMAXFP
 
  void helper_vmladduhm (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)

I think you should be able to remove the HANDLE_NAN2 line from the VARITHFP macro (used for vaddfp, vsubfp) and then you can just say
VARITHFP(minfp, float32_min)
VARITHFP(maxfp, float32_max)
rather than needing a separate macro for them, right?

-- PMM

#2 lore raw
In reply to Aurelien Jarno
Quoted 22 lines · Aurelien Jarno

Use the new softfloat float32_min() and float32_max() to implement the vminfp and vmaxfp instructions.

---
target-ppc/op_helper.c | 16 +++++-----------

1 files changed, 5 insertions(+), 11 deletions(-)
target-ppc/op_helper.c +2 -2
index 9aa108e..9058d78 100644
@@ -2369,22 +2369,16 @@ VMINMAX(uw, u32)
 #undef VMINMAX_DO
 #undef VMINMAX
 
-#define VMINMAXFP(suffix, rT, rF)                                       \
-    void helper_v##suffix (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)    \
+#define VMINMAXFP(suffix)                                               \
+    void helper_v##suffix##fp (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)\
    {                                                                   \

target-ppc/op_helper.c VMINMAX(uw, u32) · line 2377

Quoted 10 lines
target-ppc/op_helper.c +1 -7
        int i;                                                          \
        for (i = 0; i < ARRAY_SIZE(r->f); i++) {                        \
-            HANDLE_NAN2(r->f[i], a->f[i], b->f[i]) {                    \
-                if (float32_lt_quiet(a->f[i], b->f[i], &env->vec_status)) { \
-                    r->f[i] = rT->f[i];                                 \
-                } else {                                                \
-                    r->f[i] = rF->f[i];                                 \
-                }                                                       \
-            }                                                           \
+            r->f[i] = float32_##suffix(a->f[i], b->f[i], &env->vec_status); \

Now that you've removed all the magic from the macro, it'd probably be easier to read if you open coded it, no? :)

Alex