target-ppc: fix nego and subf*o instructions
PATCH 1/1 target-ppc: fix nego and subf*o instructions
The overflow computation of nego and subf*o instructions has been broken in commit ffe30937. This patch fixes it.
With this change the PPC emulation passes the Gwenole Beauchesne testsuite again.
--- target-ppc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-ppc/translate.c +1 -1
@@ -749,7 +749,7 @@ static inline void gen_op_arith_compute_ov(DisasContext *ctx, TCGv arg0,tcg_gen_xor_tl (cpu_ov, arg0, arg1);tcg_gen_xor_tl (t0, arg1, arg2);if (sub) { -tcg_gen_and_tl (cpu_ov, cpu_ov, t0); +tcg_gen_andc_tl (cpu_ov, t0, cpu_ov); }else {tcg_gen_andc_tl (cpu_ov, cpu_ov, t0); }
Signature · 1 line
1.7.10.4
Quoted 18 lines · Aurelien Jarno
The overflow computation of nego and subf*o instructions has been broken in commit
ffe30937. This patch fixes it.With this change the PPC emulation passes the Gwenole Beauchesne testsuite again.
Cc Alexander Graf <[email protected]>Cc Richard Henderson <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>--- target-ppc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target-ppc/translate.c +0
-0
target-ppc/translate.c static inline void gen_op_arith_compute_ov(DisasContext *ctx, TCGv arg0, · line 755
Quoted 8 lines
target-ppc/translate.c +1
-1@@ -749,7 +749,7 @@ static inline void gen_op_arith_compute_ov(DisasContext *ctx, TCGv arg0,tcg_gen_xor_tl (cpu_ov, arg0, arg1);tcg_gen_xor_tl (t0, arg1, arg2);if (sub) { -tcg_gen_and_tl (cpu_ov, cpu_ov, t0); +tcg_gen_andc_tl (cpu_ov, t0, cpu_ov); }else {tcg_gen_andc_tl (cpu_ov, cpu_ov, t0); }
I'm a bit confused. This is the exact same algorithm that's used on ARM and i386. And as far as I can determine, all three platforms have the same definition of "overflow".
r~
Quoted 26 lines · Richard Henderson
Quoted 25 lines · Aurelien Jarno
The overflow computation of nego and subf*o instructions has been broken in commit
ffe30937. This patch fixes it.With this change the PPC emulation passes the Gwenole Beauchesne testsuite again.
Cc Alexander Graf <[email protected]>Cc Richard Henderson <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>--- target-ppc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target-ppc/translate.c +1
-1@@ -749,7 +749,7 @@ static inline void gen_op_arith_compute_ov(DisasContext *ctx, TCGv arg0, tcg_gen_xor_tl(cpu_ov, arg0, arg1);tcg_gen_xor_tl (t0, arg1, arg2);if (sub) { -tcg_gen_and_tl (cpu_ov, cpu_ov, t0); +tcg_gen_andc_tl (cpu_ov, t0, cpu_ov);
Quoted 8 lines
Quoted 3 lines
target-ppc/translate.c +0
-0}else {tcg_gen_andc_tl (cpu_ov, cpu_ov, t0);}I'm a bit confused. This is the exact same algorithm that's used on ARM and i386. And as far as I can determine, all three platforms have the same definition of "overflow".
I think it's not quite the same as ARM because the two arguments to subtract are reversed for PPC (ie PPC is 'subtract from', not 'subtract'). I think that means you want 'xor_tl(cpu_ov, arg0, arg2)' for your first xor, maybe? (untested)
-- PMM
Quoted 36 lines · Peter Maydell
Quoted 26 lines · Richard Henderson
Quoted 25 lines · Aurelien Jarno
The overflow computation of nego and subf*o instructions has been broken in commit
ffe30937. This patch fixes it.With this change the PPC emulation passes the Gwenole Beauchesne testsuite again.
Cc Alexander Graf <[email protected]>Cc Richard Henderson <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>--- target-ppc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target-ppc/translate.c +1
-1@@ -749,7 +749,7 @@ static inline void gen_op_arith_compute_ov(DisasContext *ctx, TCGv arg0, tcg_gen_xor_tl(cpu_ov, arg0, arg1);tcg_gen_xor_tl (t0, arg1, arg2);if (sub) { -tcg_gen_and_tl (cpu_ov, cpu_ov, t0); +tcg_gen_andc_tl (cpu_ov, t0, cpu_ov);Quoted 8 lines
Quoted 3 lines
target-ppc/translate.c +0
-0}else {tcg_gen_andc_tl (cpu_ov, cpu_ov, t0);}I'm a bit confused. This is the exact same algorithm that's used on ARM and i386. And as far as I can determine, all three platforms have the same definition of "overflow".
Quoted 4 lines
I think it's not quite the same as ARM because the two arguments to subtract are reversed for PPC (ie PPC is 'subtract from', not 'subtract'). I think that means you want '
xor_tl(cpu_ov, arg0, arg2)' for your first xor, maybe? (untested)
Indeed, this way of doing also works, and is also cleaner. I'll send a new version of the patch. Thanks.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Quoted 7 lines · Peter Maydell
Quoted 3 lines
Quoted 3 lines
I'm a bit confused. This is the exact same algorithm that's used on ARM and i386. And as far as I can determine, all three platforms have the same definition of "overflow".
I think it's not quite the same as ARM because the two arguments to subtract are reversed for PPC (ie PPC is 'subtract from', not 'subtract'). I think that means you want '
xor_tl(cpu_ov, arg0, arg2)' for your first xor, maybe? (untested)
Oh, duh. Of course.
r~
Quoted 23 lines · Richard Henderson
Quoted 22 lines · Aurelien Jarno
The overflow computation of nego and subf*o instructions has been broken in commit
ffe30937. This patch fixes it.With this change the PPC emulation passes the Gwenole Beauchesne testsuite again.
Cc Alexander Graf <[email protected]>Cc Richard Henderson <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>--- target-ppc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target-ppc/translate.c +0
-1@@ -749,7 +749,7 @@ static inline void gen_op_arith_compute_ov(DisasContext *ctx, TCGv arg0,tcg_gen_xor_tl (cpu_ov, arg0, arg1);tcg_gen_xor_tl (t0, arg1, arg2);if (sub) { -tcg_gen_and_tl (cpu_ov, cpu_ov, t0);
Quoted 9 lines
target-ppc/translate.c static inline void gen_op_arith_compute_ov(DisasContext *ctx, TCGv arg0, · line 755
Quoted 4 lines
target-ppc/translate.c +1
-0+tcg_gen_andc_tl (cpu_ov, t0, cpu_ov); }else {tcg_gen_andc_tl (cpu_ov, cpu_ov, t0); }I'm a bit confused. This is the exact same algorithm that's used on ARM and i386. And as far as I can determine, all three platforms have the same definition of "overflow".
I based my patch on the previous version of the code, which swaps *both* the brcond conditions testing the results of the xor. As far I understand the brcond are replaced by the and/andc in your patch.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net