* [Qemu-devel] [PATCH v2 1/5] softfloat: make float_muladd_negate_* flags independent
2012-09-11 18:47 [Qemu-devel] [PATCH v2 0/5] target-ppc: get rid of manual NaN handling in vector functions Aurelien Jarno
@ 2012-09-11 18:47 ` Aurelien Jarno
2012-09-13 23:23 ` Alexander Graf
2012-09-11 18:47 ` [Qemu-devel] [PATCH v2 2/5] target-ppc: simplify NaN propagation for vector functions Aurelien Jarno
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Aurelien Jarno @ 2012-09-11 18:47 UTC (permalink / raw)
To: qemu-devel; +Cc: Max Filippov, Alexander Graf, Peter Maydell
From: Max Filippov <jcmvbkbc@gmail.com>
Flags passed into float{32,64}_muladd are treated as bits; assign
independent bits to float_muladd_negate_* to allow precise control over
what gets negated in float{32,64}_muladd.
Cc: Alexander Graf <agraf@suse.de>
Cc: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
fpu/softfloat.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fpu/softfloat.h b/fpu/softfloat.h
index feec3a1..2860ca0 100644
--- a/fpu/softfloat.h
+++ b/fpu/softfloat.h
@@ -219,7 +219,7 @@ void float_raise( int8 flags STATUS_PARAM);
enum {
float_muladd_negate_c = 1,
float_muladd_negate_product = 2,
- float_muladd_negate_result = 3,
+ float_muladd_negate_result = 4,
};
/*----------------------------------------------------------------------------
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/5] softfloat: make float_muladd_negate_* flags independent
2012-09-11 18:47 ` [Qemu-devel] [PATCH v2 1/5] softfloat: make float_muladd_negate_* flags independent Aurelien Jarno
@ 2012-09-13 23:23 ` Alexander Graf
2012-09-14 5:57 ` Aurelien Jarno
0 siblings, 1 reply; 8+ messages in thread
From: Alexander Graf @ 2012-09-13 23:23 UTC (permalink / raw)
To: Aurelien Jarno; +Cc: Max Filippov, qemu-devel, Peter Maydell
On 11.09.2012, at 20:47, Aurelien Jarno wrote:
> From: Max Filippov <jcmvbkbc@gmail.com>
>
> Flags passed into float{32,64}_muladd are treated as bits; assign
> independent bits to float_muladd_negate_* to allow precise control over
> what gets negated in float{32,64}_muladd.
>
> Cc: Alexander Graf <agraf@suse.de>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Thanks, applied all to ppc-next. Please provide a cover letter next time - that makes it easier for me to grasp what the purpose of a patch set is :). It's also a more natural fit for the applied message.
Alex
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/5] softfloat: make float_muladd_negate_* flags independent
2012-09-13 23:23 ` Alexander Graf
@ 2012-09-14 5:57 ` Aurelien Jarno
0 siblings, 0 replies; 8+ messages in thread
From: Aurelien Jarno @ 2012-09-14 5:57 UTC (permalink / raw)
To: Alexander Graf; +Cc: Max Filippov, qemu-devel, Peter Maydell
On Fri, Sep 14, 2012 at 01:23:16AM +0200, Alexander Graf wrote:
>
> On 11.09.2012, at 20:47, Aurelien Jarno wrote:
>
> > From: Max Filippov <jcmvbkbc@gmail.com>
> >
> > Flags passed into float{32,64}_muladd are treated as bits; assign
> > independent bits to float_muladd_negate_* to allow precise control over
> > what gets negated in float{32,64}_muladd.
> >
> > Cc: Alexander Graf <agraf@suse.de>
> > Cc: Peter Maydell <peter.maydell@linaro.org>
> > Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
> > Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
>
> Thanks, applied all to ppc-next. Please provide a cover letter next time - that makes it easier for me to grasp what the purpose of a patch set is :). It's also a more natural fit for the applied message.
>
Thanks. There was a cover letter in this new version, but I did a
mistake and it only went to the list, not to you. Will pay attention
next time.
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v2 2/5] target-ppc: simplify NaN propagation for vector functions
2012-09-11 18:47 [Qemu-devel] [PATCH v2 0/5] target-ppc: get rid of manual NaN handling in vector functions Aurelien Jarno
2012-09-11 18:47 ` [Qemu-devel] [PATCH v2 1/5] softfloat: make float_muladd_negate_* flags independent Aurelien Jarno
@ 2012-09-11 18:47 ` Aurelien Jarno
2012-09-11 18:47 ` [Qemu-devel] [PATCH v2 3/5] target-ppc: use the softfloat min/max functions Aurelien Jarno
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Aurelien Jarno @ 2012-09-11 18:47 UTC (permalink / raw)
To: qemu-devel; +Cc: Alexander Graf, Aurelien Jarno
Commit e024e881bb1a8b5085026589360d26ed97acdd64 provided a pickNaN()
function for PowerPC, implementing the correct NaN propagation rules.
Therefore there is no need to test the operands manually, we can rely
on the softfloat code to do that.
Cc: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
target-ppc/int_helper.c | 26 +++++++-------------------
1 file changed, 7 insertions(+), 19 deletions(-)
diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c
index f638b2a..5b2a3c8 100644
--- a/target-ppc/int_helper.c
+++ b/target-ppc/int_helper.c
@@ -409,9 +409,7 @@ VARITH(uwm, u32)
int i; \
\
for (i = 0; i < ARRAY_SIZE(r->f); i++) { \
- HANDLE_NAN2(r->f[i], a->f[i], b->f[i]) { \
- r->f[i] = func(a->f[i], b->f[i], &env->vec_status); \
- } \
+ r->f[i] = func(a->f[i], b->f[i], &env->vec_status); \
} \
}
VARITHFP(addfp, float32_add)
@@ -1039,9 +1037,7 @@ void helper_vrefp(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *b)
int i;
for (i = 0; i < ARRAY_SIZE(r->f); i++) {
- HANDLE_NAN1(r->f[i], b->f[i]) {
- r->f[i] = float32_div(float32_one, b->f[i], &env->vec_status);
- }
+ r->f[i] = float32_div(float32_one, b->f[i], &env->vec_status);
}
}
@@ -1054,9 +1050,7 @@ void helper_vrefp(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *b)
\
set_float_rounding_mode(rounding, &s); \
for (i = 0; i < ARRAY_SIZE(r->f); i++) { \
- HANDLE_NAN1(r->f[i], b->f[i]) { \
- r->f[i] = float32_round_to_int (b->f[i], &s); \
- } \
+ r->f[i] = float32_round_to_int (b->f[i], &s); \
} \
}
VRFI(n, float_round_nearest_even)
@@ -1089,11 +1083,9 @@ void helper_vrsqrtefp(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *b)
int i;
for (i = 0; i < ARRAY_SIZE(r->f); i++) {
- HANDLE_NAN1(r->f[i], b->f[i]) {
- float32 t = float32_sqrt(b->f[i], &env->vec_status);
+ float32 t = float32_sqrt(b->f[i], &env->vec_status);
- r->f[i] = float32_div(float32_one, t, &env->vec_status);
- }
+ r->f[i] = float32_div(float32_one, t, &env->vec_status);
}
}
@@ -1109,9 +1101,7 @@ void helper_vexptefp(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *b)
int i;
for (i = 0; i < ARRAY_SIZE(r->f); i++) {
- HANDLE_NAN1(r->f[i], b->f[i]) {
- r->f[i] = float32_exp2(b->f[i], &env->vec_status);
- }
+ r->f[i] = float32_exp2(b->f[i], &env->vec_status);
}
}
@@ -1120,9 +1110,7 @@ void helper_vlogefp(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *b)
int i;
for (i = 0; i < ARRAY_SIZE(r->f); i++) {
- HANDLE_NAN1(r->f[i], b->f[i]) {
- r->f[i] = float32_log2(b->f[i], &env->vec_status);
- }
+ r->f[i] = float32_log2(b->f[i], &env->vec_status);
}
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v2 3/5] target-ppc: use the softfloat min/max functions
2012-09-11 18:47 [Qemu-devel] [PATCH v2 0/5] target-ppc: get rid of manual NaN handling in vector functions Aurelien Jarno
2012-09-11 18:47 ` [Qemu-devel] [PATCH v2 1/5] softfloat: make float_muladd_negate_* flags independent Aurelien Jarno
2012-09-11 18:47 ` [Qemu-devel] [PATCH v2 2/5] target-ppc: simplify NaN propagation for vector functions Aurelien Jarno
@ 2012-09-11 18:47 ` Aurelien Jarno
2012-09-11 18:47 ` [Qemu-devel] [PATCH v2 4/5] target-ppc: use the softfloat float32_muladd function Aurelien Jarno
2012-09-11 18:47 ` [Qemu-devel] [PATCH v2 5/5] target-ppc: get rid of the HANDLE_NAN{1, 2, 3} macros Aurelien Jarno
4 siblings, 0 replies; 8+ messages in thread
From: Aurelien Jarno @ 2012-09-11 18:47 UTC (permalink / raw)
To: qemu-devel; +Cc: Alexander Graf, Aurelien Jarno
Use the new softfloat float32_min() and float32_max() to implement the
vminfp and vmaxfp instructions. As a bonus we can get rid of the call to
the HANDLE_NAN2 macro, as the NaN handling is directly done at the
softfloat level.
Cc: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
target-ppc/int_helper.c | 23 ++---------------------
1 file changed, 2 insertions(+), 21 deletions(-)
diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c
index 5b2a3c8..6141243 100644
--- a/target-ppc/int_helper.c
+++ b/target-ppc/int_helper.c
@@ -414,6 +414,8 @@ VARITH(uwm, u32)
}
VARITHFP(addfp, float32_add)
VARITHFP(subfp, float32_sub)
+VARITHFP(minfp, float32_min)
+VARITHFP(maxfp, float32_max)
#undef VARITHFP
#define VARITHSAT_CASE(type, op, cvt, element) \
@@ -728,27 +730,6 @@ VMINMAX(uw, u32)
#undef VMINMAX_DO
#undef VMINMAX
-#define VMINMAXFP(suffix, rT, rF) \
- void helper_v##suffix(CPUPPCState *env, 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]; \
- } \
- } \
- } \
- }
-VMINMAXFP(minfp, a, b)
-VMINMAXFP(maxfp, b, a)
-#undef VMINMAXFP
-
void helper_vmladduhm(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
{
int i;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v2 4/5] target-ppc: use the softfloat float32_muladd function
2012-09-11 18:47 [Qemu-devel] [PATCH v2 0/5] target-ppc: get rid of manual NaN handling in vector functions Aurelien Jarno
` (2 preceding siblings ...)
2012-09-11 18:47 ` [Qemu-devel] [PATCH v2 3/5] target-ppc: use the softfloat min/max functions Aurelien Jarno
@ 2012-09-11 18:47 ` Aurelien Jarno
2012-09-11 18:47 ` [Qemu-devel] [PATCH v2 5/5] target-ppc: get rid of the HANDLE_NAN{1, 2, 3} macros Aurelien Jarno
4 siblings, 0 replies; 8+ messages in thread
From: Aurelien Jarno @ 2012-09-11 18:47 UTC (permalink / raw)
To: qemu-devel; +Cc: Alexander Graf, Aurelien Jarno
Use the new softfloat float32_muladd() function to implement the vmaddfp
and vnmsubfp instructions. As a bonus we can get rid of the call to the
HANDLE_NAN3 macro, as the NaN handling is directly done at the softfloat
level.
Cc: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
target-ppc/int_helper.c | 57 ++++++++++++-----------------------------------
1 file changed, 14 insertions(+), 43 deletions(-)
diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c
index 6141243..6f9beff 100644
--- a/target-ppc/int_helper.c
+++ b/target-ppc/int_helper.c
@@ -418,6 +418,20 @@ VARITHFP(minfp, float32_min)
VARITHFP(maxfp, float32_max)
#undef VARITHFP
+#define VARITHFPFMA(suffix, type) \
+ void helper_v##suffix(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, \
+ ppc_avr_t *b, ppc_avr_t *c) \
+ { \
+ int i; \
+ for (i = 0; i < ARRAY_SIZE(r->f); i++) { \
+ r->f[i] = float32_muladd(a->f[i], c->f[i], b->f[i], \
+ type, &env->vec_status); \
+ } \
+ }
+VARITHFPFMA(maddfp, 0);
+VARITHFPFMA(nmsubfp, float_muladd_negate_result | float_muladd_negate_c);
+#undef VARITHFPFMA
+
#define VARITHSAT_CASE(type, op, cvt, element) \
{ \
type result = (type)a->element[i] op (type)b->element[i]; \
@@ -649,27 +663,6 @@ VCT(uxs, cvtsduw, u32)
VCT(sxs, cvtsdsw, s32)
#undef VCT
-void helper_vmaddfp(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b,
- ppc_avr_t *c)
-{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(r->f); i++) {
- HANDLE_NAN3(r->f[i], a->f[i], b->f[i], c->f[i]) {
- /* Need to do the computation in higher precision and round
- * once at the end. */
- float64 af, bf, cf, t;
-
- af = float32_to_float64(a->f[i], &env->vec_status);
- bf = float32_to_float64(b->f[i], &env->vec_status);
- cf = float32_to_float64(c->f[i], &env->vec_status);
- t = float64_mul(af, cf, &env->vec_status);
- t = float64_add(t, bf, &env->vec_status);
- r->f[i] = float64_to_float32(t, &env->vec_status);
- }
- }
-}
-
void helper_vmhaddshs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a,
ppc_avr_t *b, ppc_avr_t *c)
{
@@ -909,28 +902,6 @@ VMUL(uh, u16, u32)
#undef VMUL_DO
#undef VMUL
-void helper_vnmsubfp(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a,
- ppc_avr_t *b, ppc_avr_t *c)
-{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(r->f); i++) {
- HANDLE_NAN3(r->f[i], a->f[i], b->f[i], c->f[i]) {
- /* Need to do the computation is higher precision and round
- * once at the end. */
- float64 af, bf, cf, t;
-
- af = float32_to_float64(a->f[i], &env->vec_status);
- bf = float32_to_float64(b->f[i], &env->vec_status);
- cf = float32_to_float64(c->f[i], &env->vec_status);
- t = float64_mul(af, cf, &env->vec_status);
- t = float64_sub(t, bf, &env->vec_status);
- t = float64_chs(t);
- r->f[i] = float64_to_float32(t, &env->vec_status);
- }
- }
-}
-
void helper_vperm(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b,
ppc_avr_t *c)
{
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v2 5/5] target-ppc: get rid of the HANDLE_NAN{1, 2, 3} macros
2012-09-11 18:47 [Qemu-devel] [PATCH v2 0/5] target-ppc: get rid of manual NaN handling in vector functions Aurelien Jarno
` (3 preceding siblings ...)
2012-09-11 18:47 ` [Qemu-devel] [PATCH v2 4/5] target-ppc: use the softfloat float32_muladd function Aurelien Jarno
@ 2012-09-11 18:47 ` Aurelien Jarno
4 siblings, 0 replies; 8+ messages in thread
From: Aurelien Jarno @ 2012-09-11 18:47 UTC (permalink / raw)
To: qemu-devel; +Cc: Alexander Graf, Aurelien Jarno
We can finally get rid of the ugly HANDLE_NAN{1,2,3} macros.
Cc: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
target-ppc/int_helper.c | 21 ---------------------
1 file changed, 21 deletions(-)
diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c
index 6f9beff..f39b4f6 100644
--- a/target-ppc/int_helper.c
+++ b/target-ppc/int_helper.c
@@ -287,23 +287,6 @@ target_ulong helper_602_mfrom(target_ulong arg)
for (index = ARRAY_SIZE(r->element)-1; index >= 0; index--)
#endif
-/* If X is a NaN, store the corresponding QNaN into RESULT. Otherwise,
- * execute the following block. */
-#define DO_HANDLE_NAN(result, x) \
- if (float32_is_any_nan(x)) { \
- CPU_FloatU __f; \
- __f.f = x; \
- __f.l = __f.l | (1 << 22); /* Set QNaN bit. */ \
- result = __f.f; \
- } else
-
-#define HANDLE_NAN1(result, x) \
- DO_HANDLE_NAN(result, x)
-#define HANDLE_NAN2(result, x, y) \
- DO_HANDLE_NAN(result, x) DO_HANDLE_NAN(result, y)
-#define HANDLE_NAN3(result, x, y, z) \
- DO_HANDLE_NAN(result, x) DO_HANDLE_NAN(result, y) DO_HANDLE_NAN(result, z)
-
/* Saturating arithmetic helpers. */
#define SATCVT(from, to, from_type, to_type, min, max) \
static inline to_type cvt##from##to(from_type x, int *sat) \
@@ -1413,10 +1396,6 @@ VUPK(lsh, s32, s16, UPKLO)
#undef UPKHI
#undef UPKLO
-#undef DO_HANDLE_NAN
-#undef HANDLE_NAN1
-#undef HANDLE_NAN2
-#undef HANDLE_NAN3
#undef VECTOR_FOR_INORDER_I
#undef HI_IDX
#undef LO_IDX
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread