This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: eliminate more warnings
- From: Ben Elliston <bje at au1 dot ibm dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Cc: Trevor_Smigiel <Trevor_Smigiel at playstation dot sony dot com>, Ian Lance Taylor <ian at airs dot com>
- Date: Thu, 18 Dec 2008 15:32:35 +1100
- Subject: PATCH: eliminate more warnings
This patch eliminates a few more warnings (in fp-bit and in the SPU
backend). Tested with a testsuite run on spu-elf, no regressions.
Okay for the trunk?
Ben
2008-12-18 Ben Elliston <bje@au.ibm.com>
* config/spu/multi3.c (__multi3): Provide prototype.
(__multi3): Type pun via a union to prevent type-punning warnings.
* config/spu/divmodti4.c (__udivmodti4): Likewise.
* config/soft-fp/op-common.h (_FP_DECL): Initialise _e field.
* config/fp-bit.h (pack_d): Constify argument.
* config/fp-bit.c (makenan): Constify return type. Remove casts.
(isnan): Constify argument.
(isinf): Likewise.
(iszero): Likewise.
(pack_d): Likewise.
(_fpadd_parts): Constify return type.
(_fpmul_parts): Likewise.
(_fpdiv_parts): Likewise.
Index: config/spu/divmodti4.c
===================================================================
--- config/spu/divmodti4.c (revision 142805)
+++ config/spu/divmodti4.c (working copy)
@@ -75,6 +75,10 @@
qword r0 = si_il (0);
qword m1 = si_fsmbi (0x000f);
qword mask, r1, n1;
+ union {
+ qword *q;
+ UTItype *uti;
+ } u;
d0 = si_shlqbybi (si_shlqbi (d0, shift), shift);
bit = si_shlqbybi (si_shlqbi (bit, shift), shift);
@@ -103,8 +107,12 @@
}
while (si_to_uint (si_orx (bit)));
if (rp)
- *rp = *(UTItype *) & n0;
- return *(UTItype *) & r0;
+ {
+ u.q = &n0;
+ *rp = *u.uti;
+ }
+ u.q = &r0;
+ return *u.uti;
}
UTItype
Index: config/spu/multi3.c
===================================================================
--- config/spu/multi3.c (revision 142805)
+++ config/spu/multi3.c (working copy)
@@ -24,8 +24,9 @@
#include <spu_intrinsics.h>
typedef int TItype __attribute__ ((mode (TI)));
+TItype __multi3 (TItype l, TItype r);
-/* A straight forward vectorization and unrolling of
+/* A straightforward vectorization and unrolling of
* short l[8], r[8];
* TItype total = 0;
* for (i = 0; i < 8; i++)
@@ -35,6 +36,11 @@
TItype
__multi3 (TItype l, TItype r)
{
+ union {
+ qword *q;
+ TItype *t;
+ } qword_ti_union;
+
qword u = *(qword *) & l;
qword v = *(qword *) & r;
qword splat0 = si_shufb (v, v, si_ilh (0x0001));
@@ -95,5 +101,7 @@
total = si_cgx (total10, carry, total);
total = si_shlqbyi (total, 4);
total = si_addx (total10, carry, total);
- return *(TItype *) & total;
+
+ qword_ti_union.q = &total;
+ return *qword_ti_union.t;
}
Index: config/fp-bit.c
===================================================================
--- config/fp-bit.c (revision 142805)
+++ config/fp-bit.c (working copy)
@@ -139,22 +139,21 @@
#endif
INLINE
-static fp_number_type *
+static const fp_number_type *
makenan (void)
{
- /* Discard the const qualifier... */
#ifdef TFLOAT
- return (fp_number_type *) (& __thenan_tf);
+ return & __thenan_tf;
#elif defined FLOAT
- return (fp_number_type *) (& __thenan_sf);
+ return & __thenan_sf;
#else
- return (fp_number_type *) (& __thenan_df);
+ return & __thenan_df;
#endif
}
INLINE
static int
-isnan ( fp_number_type * x)
+isnan (const fp_number_type *x)
{
return __builtin_expect (x->class == CLASS_SNAN || x->class == CLASS_QNAN,
0);
@@ -162,7 +161,7 @@
INLINE
static int
-isinf ( fp_number_type * x)
+isinf (const fp_number_type * x)
{
return __builtin_expect (x->class == CLASS_INFINITY, 0);
}
@@ -171,7 +170,7 @@
INLINE
static int
-iszero ( fp_number_type * x)
+iszero (const fp_number_type * x)
{
return x->class == CLASS_ZERO;
}
@@ -199,11 +198,11 @@
return __clzsi2 (n);
}
-extern FLO_type pack_d ( fp_number_type * );
+extern FLO_type pack_d (const fp_number_type * );
#if defined(L_pack_df) || defined(L_pack_sf) || defined(L_pack_tf)
FLO_type
-pack_d ( fp_number_type * src)
+pack_d (const fp_number_type *src)
{
FLO_union_type dst;
fractype fraction = src->fraction.ll; /* wasn't unsigned before? */
@@ -596,7 +595,7 @@
#endif /* L_unpack_df || L_unpack_sf */
#if defined(L_addsub_sf) || defined(L_addsub_df) || defined(L_addsub_tf)
-static fp_number_type *
+static const fp_number_type *
_fpadd_parts (fp_number_type * a,
fp_number_type * b,
fp_number_type * tmp)
@@ -734,7 +733,6 @@
tmp->normal_exp++;
}
return tmp;
-
}
FLO_type
@@ -743,7 +741,7 @@
fp_number_type a;
fp_number_type b;
fp_number_type tmp;
- fp_number_type *res;
+ const fp_number_type *res;
FLO_union_type au, bu;
au.value = arg_a;
@@ -763,7 +761,7 @@
fp_number_type a;
fp_number_type b;
fp_number_type tmp;
- fp_number_type *res;
+ const fp_number_type *res;
FLO_union_type au, bu;
au.value = arg_a;
@@ -781,7 +779,7 @@
#endif /* L_addsub_sf || L_addsub_df */
#if defined(L_mul_sf) || defined(L_mul_df) || defined(L_mul_tf)
-static inline __attribute__ ((__always_inline__)) fp_number_type *
+static inline __attribute__ ((__always_inline__)) const fp_number_type *
_fpmul_parts ( fp_number_type * a,
fp_number_type * b,
fp_number_type * tmp)
@@ -949,7 +947,7 @@
fp_number_type a;
fp_number_type b;
fp_number_type tmp;
- fp_number_type *res;
+ const fp_number_type *res;
FLO_union_type au, bu;
au.value = arg_a;
@@ -965,7 +963,7 @@
#endif /* L_mul_sf || L_mul_df || L_mul_tf */
#if defined(L_div_sf) || defined(L_div_df) || defined(L_div_tf)
-static inline __attribute__ ((__always_inline__)) fp_number_type *
+static inline __attribute__ ((__always_inline__)) const fp_number_type *
_fpdiv_parts (fp_number_type * a,
fp_number_type * b)
{
@@ -1067,7 +1065,7 @@
{
fp_number_type a;
fp_number_type b;
- fp_number_type *res;
+ const fp_number_type *res;
FLO_union_type au, bu;
au.value = arg_a;