* [RFC PATCH] MIPS: math-emu: do not use bools for arithmetic
@ 2017-07-31 9:21 Manuel Lauss
2017-08-09 8:14 ` Maciej W. Rozycki
0 siblings, 1 reply; 4+ messages in thread
From: Manuel Lauss @ 2017-07-31 9:21 UTC (permalink / raw)
To: Linux-MIPS, Paul Burton, Ralf Baechle; +Cc: 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); \
Fix this by testing the bool and returning an int.
This also shrinks the size of the file object file by 312 bytes:
text data bss dec hex filename
11432 0 0 11432 2ca8 cp1emu.o-alt
11120 0 0 11120 2b70 cp1emu.o
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
---
I'm unsure whether the patch is really correct, due to the unexpected
binary size reduction. I do not have a hardfloat mips32 userland at hand
therefore I'd appreciate it if someone could test it!
Thanks!
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..f3a9bf5285e0 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) == 0 ? 1 : 0)], 0))
#define DITOREG(di, x) \
do { \
unsigned fpr, i; \
- fpr = (x) & ~(cop1_64bit(xcp) == 0); \
+ fpr = (x) & ~(cop1_64bit(xcp) == 0 ? 1 : 0); \
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.13.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] MIPS: math-emu: do not use bools for arithmetic
2017-07-31 9:21 [RFC PATCH] MIPS: math-emu: do not use bools for arithmetic Manuel Lauss
@ 2017-08-09 8:14 ` Maciej W. Rozycki
2017-08-09 10:45 ` Manuel Lauss
0 siblings, 1 reply; 4+ messages in thread
From: Maciej W. Rozycki @ 2017-08-09 8:14 UTC (permalink / raw)
To: Manuel Lauss; +Cc: Linux-MIPS, Paul Burton, Ralf Baechle
On Mon, 31 Jul 2017, Manuel Lauss wrote:
> I'm unsure whether the patch is really correct, due to the unexpected
> binary size reduction. I do not have a hardfloat mips32 userland at hand
> therefore I'd appreciate it if someone could test it!
What exactly are you unsure about? Double operations using odd register
indices in the 32-bit FPR mode are architecturally unpredictable. Is this
what concerns you?
> diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
> index f08a7b4facb9..f3a9bf5285e0 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) == 0 ? 1 : 0)], 0))
Umm, I find the expression somewhat hard to follow. How about:
((di) = get_fpr64(&ctx->fpr[(x) & ~(cop1_64bit(xcp) ^ 1))
?
> #define DITOREG(di, x) \
> do { \
> unsigned fpr, i; \
> - fpr = (x) & ~(cop1_64bit(xcp) == 0); \
> + fpr = (x) & ~(cop1_64bit(xcp) == 0 ? 1 : 0); \
Likewise:
fpr = (x) & ~(cop1_64bit(xcp) ^ 1); \
?
Maciej
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] MIPS: math-emu: do not use bools for arithmetic
2017-08-09 8:14 ` Maciej W. Rozycki
@ 2017-08-09 10:45 ` Manuel Lauss
2017-08-09 10:53 ` Maciej W. Rozycki
0 siblings, 1 reply; 4+ messages in thread
From: Manuel Lauss @ 2017-08-09 10:45 UTC (permalink / raw)
To: Maciej W. Rozycki; +Cc: Linux-MIPS, Paul Burton, Ralf Baechle
On Wed, Aug 9, 2017 at 10:14 AM, Maciej W. Rozycki <macro@imgtec.com> wrote:
> On Mon, 31 Jul 2017, Manuel Lauss wrote:
>
>> I'm unsure whether the patch is really correct, due to the unexpected
>> binary size reduction. I do not have a hardfloat mips32 userland at hand
>> therefore I'd appreciate it if someone could test it!
>
> What exactly are you unsure about? Double operations using odd register
> indices in the 32-bit FPR mode are architecturally unpredictable. Is this
> what concerns you?
I was not able to find a definition for get_fpr by grepping the tree
for it, so I wasn't
sure whether only the LSB or all mattered.
Manuel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] MIPS: math-emu: do not use bools for arithmetic
2017-08-09 10:45 ` Manuel Lauss
@ 2017-08-09 10:53 ` Maciej W. Rozycki
0 siblings, 0 replies; 4+ messages in thread
From: Maciej W. Rozycki @ 2017-08-09 10:53 UTC (permalink / raw)
To: Manuel Lauss; +Cc: Linux-MIPS, Paul Burton, Ralf Baechle
On Wed, 9 Aug 2017, Manuel Lauss wrote:
> > What exactly are you unsure about? Double operations using odd register
> > indices in the 32-bit FPR mode are architecturally unpredictable. Is this
> > what concerns you?
>
> I was not able to find a definition for get_fpr by grepping the tree
> for it, so I wasn't
> sure whether only the LSB or all mattered.
It's in arch/mips/include/asm/processor.h; see BUILD_FPR_ACCESS.
Maciej
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-09 11:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-31 9:21 [RFC PATCH] MIPS: math-emu: do not use bools for arithmetic Manuel Lauss
2017-08-09 8:14 ` Maciej W. Rozycki
2017-08-09 10:45 ` Manuel Lauss
2017-08-09 10:53 ` Maciej W. Rozycki
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.