Message ID | 56C504D1.7050908@linux.vnet.ibm.com |
---|---|
State | New |
Headers | show |
I have no comments on this patch beyond again suggesting that it would be desirable for some future float128 GCC patch to enable as many as possible of the x86 float128 tests (that is, tests of float128 anywhere in the GCC testsuite that currently are restricted to x86, x86_64 and ia64 targets or some subset thereof) also for powerpc (with appropriate dg- directives to allow target-specific compilation options to be added, say dg-add-options float128). While some of those tests are inapplicable to powerpc (e.g. gcc.dg/torture/float128-extendxf-underflow.c because it uses XFmode, and float128-mul-underflow.c, float128-truncdf-underflow.c, float128-truncsf-underflow.c because they test for after-rounding tininess detection, which is correct for x86 / ia64 but not for powerpc), others should apply to powerpc just as to x86 / ia64, and the tests do test various aspects of exceptions / rounding modes handling (and other issues, e.g. conversions in fp-int-convert-float128*), and it would not surprise me if they would have shown up some of the issues fixed by this patch.
On Wed, Feb 17, 2016 at 05:40:01PM -0600, Paul E. Murphy wrote: > - FP_INIT_ROUNDMODE writes junk to the fpscr. I assume this should be > reading the fpscr and initializing the local rounding mode variable > declared via _FP_DECL_EX. Yeah, looks that way. > - FP_TRAPPING_EXCEPTIONS evaluates to zero where used. It seems like it > should return a bit field of FP_EX_* bits indicating which trap is > enabled. Likewise, when these bits are set in the fpscr, the trap is > enabled. Yes, but > +/* A set bit indicates an exception is trapping. */ > +# define FP_TRAPPING_EXCEPTIONS ((_fpscr.i << 22) & FP_EX_ALL) why then a shift here, since FP_EX_* are defined as the actual register bits? Oh, I see. FP_EX_* are the status bits, and you want the enable bits. ie. bit 56 rather than bit 34, bit 57 rather than bit 35 and so on (bits numbered from 0 as msb). A comment to that effect might reduce head scratching.
diff --git a/libgcc/config/rs6000/sfp-machine.h b/libgcc/config/rs6000/sfp-machine.h index 75d5e1a..4bc0040 100644 --- a/libgcc/config/rs6000/sfp-machine.h +++ b/libgcc/config/rs6000/sfp-machine.h @@ -130,9 +130,9 @@ void __sfp_handle_exceptions (int); if (__builtin_expect (_fex, 0)) \ __sfp_handle_exceptions (_fex); \ } while (0); -/* A set bit indicates an exception is masked and a clear bit indicates it is - trapping. */ -# define FP_TRAPPING_EXCEPTIONS (~_fpscr & (FP_EX_ALL >> 22)) + +/* A set bit indicates an exception is trapping. */ +# define FP_TRAPPING_EXCEPTIONS ((_fpscr.i << 22) & FP_EX_ALL) # define FP_RND_NEAREST 0x0 # define FP_RND_ZERO 0x1 @@ -141,16 +141,16 @@ void __sfp_handle_exceptions (int); # define FP_RND_MASK 0x3 # define _FP_DECL_EX \ - unsigned long long _fpscr __attribute__ ((unused)) = FP_RND_NEAREST + union { unsigned long long i; double d; } _fpscr __attribute__ ((unused)) = \ + { .i = FP_RND_NEAREST } #define FP_INIT_ROUNDMODE \ do { \ - __asm__ __volatile__ ("mtfsf 255, %0" \ - : \ - : "f" (_fpscr)); \ + __asm__ __volatile__ ("mffs %0" \ + : "=f" (_fpscr.d)); \ } while (0) -# define FP_ROUNDMODE (_fpscr & FP_RND_MASK) +# define FP_ROUNDMODE (_fpscr.i & FP_RND_MASK) #endif /* !__FLOAT128__ */ /* Define ALIASNAME as a strong alias for NAME. */