This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] FPU IEEE 754 for MIPS r5900
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: JÃrgen Urban <JuergenUrban at gmx dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 07 Jul 2013 09:15:37 +0100
- Subject: Re: [PATCH] FPU IEEE 754 for MIPS r5900
- References: <trinity-19396fd5-d26f-429c-89a4-e9afbeb36722-1370202342791 at 3capp-gmx-bs38> <87zjv77ygt dot fsf at talisman dot default> <trinity-72aeaa96-31d1-436d-931a-473776c0f820-1370302263406 at 3capp-gmx-bs39> <87r4gh92dy dot fsf at talisman dot default> <trinity-c66f9fbe-87ad-4f32-b20d-727b789b8bd8-1373145909922 at 3capp-gmx-bs07>
"JÃrgen Urban" <JuergenUrban@gmx.de> writes:
> I used the SPU code in GCC as example for creating an
> r5900_single_format structure. The patch is attached to the e-mail. I
> want to submit this patch.
Thanks. Are there any real differences though? E.g. in your version
you set has_sign_dependent_rounding, but that's not necessary when the
only rounding mode is towards zero. has_sign_dependent_rounding says
whether rounding X vs. -X can give numbers of different magnitude.
(It was actually because of r5900 that this distinction was added.)
I'm also not sure it makes sense to choose a different NaN encoding
when NaNs aren't supported anyway.
It would be good if we could reuse spu_single_format directly.
> To be able to use it, you need to use mipsr5900el and
> "--with-float=single". "--with-float=hard" results in double float
> because of MIPS ISA III.
This isn't quite right as-is. The code that applies the --with-float
setting is:
#define OPTION_DEFAULT_SPECS \
... \
{"float", "%{!msoft-float:%{!mhard-float:-m%(VALUE)-float}}" }, \
in mips.h. So -mdouble-float wouldn't override --with-float=single, etc.
single vs. double has traditionally been a separate choice from hard
vs. soft (which is a bit unfortunate given that single vs. double makes
no sense for soft float). Maybe we should have --with-fpu=single and
--with-fpu=double instead.
> I didn't changed the default in config.gcc. It is still soft float,
> because floating point doesn't behave as defined by IEEE 754. I don't
> see much improvement. This is the case on the PS2 and the PS3. For
> example inf minus inf should be NaN, but on both systems it is 0.
> I tested it on r5900 and the PS3 SPU. Both calculates the same result
> despite the MODE_HAS_* implementation. This means that there is a
> patch needed in the generic part (i.e. not mips) of the GCC.
But the format doesn't have an infinity representation, does it?
The IEEE infinity encoding is instead treated as a large number.
So it sounds like a bug if GCC is treating any (r5900|spu)_single_format
value as infinity to be begin with.
> @@ -989,7 +991,7 @@
> /* True if trunc.w.s and trunc.w.d are real (not synthetic)
> instructions. Both require TARGET_HARD_FLOAT, and trunc.w.d
> also requires TARGET_DOUBLE_FLOAT. */
> -#define ISA_HAS_TRUNC_W (!ISA_MIPS1)
> +#define ISA_HAS_TRUNC_W (!ISA_MIPS1 || TARGET_MIPS5900)
>
> /* ISA includes the MIPS32r2 seb and seh instructions. */
> #define ISA_HAS_SEB_SEH ((ISA_MIPS32R2 \
This part shouldn't be necessary. The ISA_* and TARGET_MIPS* macros are
kept in sync, so it can never be the case that ISA_MIPS1 && TARGET_MIPS5900.
(E.g. -mips1 -march=r5900 is rejected.)
Thanks,
Richard