* [PATCH v2] MIPS: math-emu: do not use bools for arithmetic
@ 2017-08-14 10:21 Manuel Lauss
2017-08-14 11:25 ` Maciej W. Rozycki
0 siblings, 1 reply; 3+ messages in thread
From: Manuel Lauss @ 2017-08-14 10:21 UTC (permalink / raw)
To: Linux-MIPS; +Cc: Ralf Baechle, Maciej W . Rozycki, Manuel Lauss
GCC-7 complains about a boolean value being used with an arithmetic
AND:
arch/mips/math-emu/cp1emu.c: In function 'cop1Emulate':
arch/mips/math-emu/cp1emu.c:838:14: warning: '~' on a boolean expression [-Wbool-operation]
fpr = (x) & ~(cop1_64bit(xcp) == 0); \
^
arch/mips/math-emu/cp1emu.c:1068:3: note: in expansion of macro 'DITOREG'
DITOREG(dval, MIPSInst_RT(ir));
^~~~~~~
arch/mips/math-emu/cp1emu.c:838:14: note: did you mean to use logical not?
fpr = (x) & ~(cop1_64bit(xcp) == 0); \
Since cop1_64bit() returns and int, just flip the LSB.
Suggested-by: Maciej W. Rozycki <macro@imgtec.com>
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
---
v2: just use xor, as suggested by Maciej. No size changes this time, but still
untested due to lack of hardfloat userland.
arch/mips/math-emu/cp1emu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
index f08a7b4facb9..53a3b73a28d5 100644
--- a/arch/mips/math-emu/cp1emu.c
+++ b/arch/mips/math-emu/cp1emu.c
@@ -830,12 +830,12 @@ do { \
} while (0)
#define DIFROMREG(di, x) \
- ((di) = get_fpr64(&ctx->fpr[(x) & ~(cop1_64bit(xcp) == 0)], 0))
+ ((di) = get_fpr64(&ctx->fpr[(x) & ~(cop1_64bit(xcp) ^ 1)], 0))
#define DITOREG(di, x) \
do { \
unsigned fpr, i; \
- fpr = (x) & ~(cop1_64bit(xcp) == 0); \
+ fpr = (x) & ~(cop1_64bit(xcp) ^ 1); \
set_fpr64(&ctx->fpr[fpr], 0, di); \
for (i = 1; i < ARRAY_SIZE(ctx->fpr[x].val64); i++) \
set_fpr64(&ctx->fpr[fpr], i, 0); \
--
2.14.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] MIPS: math-emu: do not use bools for arithmetic
2017-08-14 10:21 [PATCH v2] MIPS: math-emu: do not use bools for arithmetic Manuel Lauss
@ 2017-08-14 11:25 ` Maciej W. Rozycki
2017-08-15 7:03 ` Manuel Lauss
0 siblings, 1 reply; 3+ messages in thread
From: Maciej W. Rozycki @ 2017-08-14 11:25 UTC (permalink / raw)
To: Manuel Lauss; +Cc: Linux-MIPS, Ralf Baechle
On Mon, 14 Aug 2017, Manuel Lauss wrote:
> ---
> v2: just use xor, as suggested by Maciej. No size changes this time, but still
> untested due to lack of hardfloat userland.
D'oh, I was wondering what you meant by writing: "binary size reduction"
and didn't get that you meant a size reduction of the binary object file
produced rather than a transformation made by the compiler to the binary
expression used. That looks odd indeed -- have you tried comparing the
output from `objdump -d' with and without the original patch applied?
Your change looks obviously correct to me, however I can push it through
GCC and/or glibc IEEE 754 math regression testing if it'll make you feel
more confident about it.
Meanwhile:
Reviewed-by: Maciej W. Rozycki <macro@imgtec.com>
Maciej
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] MIPS: math-emu: do not use bools for arithmetic
2017-08-14 11:25 ` Maciej W. Rozycki
@ 2017-08-15 7:03 ` Manuel Lauss
0 siblings, 0 replies; 3+ messages in thread
From: Manuel Lauss @ 2017-08-15 7:03 UTC (permalink / raw)
To: Maciej W. Rozycki; +Cc: Linux-MIPS, Ralf Baechle
On Mon, Aug 14, 2017 at 1:25 PM, Maciej W. Rozycki <macro@imgtec.com> wrote:
> On Mon, 14 Aug 2017, Manuel Lauss wrote:
>
>> ---
>> v2: just use xor, as suggested by Maciej. No size changes this time, but still
>> untested due to lack of hardfloat userland.
>
> D'oh, I was wondering what you meant by writing: "binary size reduction"
> and didn't get that you meant a size reduction of the binary object file
> produced rather than a transformation made by the compiler to the binary
> expression used. That looks odd indeed -- have you tried comparing the
> output from `objdump -d' with and without the original patch applied?
>
> Your change looks obviously correct to me, however I can push it through
> GCC and/or glibc IEEE 754 math regression testing if it'll make you feel
> more confident about it.
No need. I've updated to gcc-7.2 and the differences are gone, the binary
cp1emu.o created with and without this patch are completely identical.
Thanks!
Manuel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-15 7:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-14 10:21 [PATCH v2] MIPS: math-emu: do not use bools for arithmetic Manuel Lauss
2017-08-14 11:25 ` Maciej W. Rozycki
2017-08-15 7:03 ` Manuel Lauss
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox