This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
unsigned_type_for (sizetype)?
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: kenner at vlsi1 dot ultra dot nyu dot edu, ebotcazou at adacore dot com
- Date: Fri, 1 Feb 2008 17:12:28 +0100 (CET)
- Subject: unsigned_type_for (sizetype)?
What should this function return for sizetype? At the moment it
returns a non-sizetype. In fixing PR35043 (we ask for a signed type
for bitsizetype, which the C FE is not happy to hand out) I was
trying to put all TYPE_IS_SIZETYPE type questions into middle-end
control - but ada has a signed sizetype and so asking for an
unsigned type for ssizetype or sizetype ICEs later if the caller
asserts TYPE_UNSIGNED (type)...
I think it is not ok to return a non-sizetype for this question
(but of course we do so now).
The following patch fails bootstrap with
+===========================GNAT BUG DETECTED==============================+
| 4.3.0 20080201 (experimental) (x86_64-unknown-linux-gnu) GCC error:
|
| in n_of_executions_at_most, at tree-ssa-loop-niter.c:2871
|
So... put in a "fallback" like
/* Do not defer to the frontends for middle-end sizetypes. */
if (TREE_CODE (type) == INTEGER_TYPE
&& TYPE_IS_SIZETYPE (type))
{
if (type == bitsizetype
|| type == sbitsizetype)
tem = unsignedp ? bitsizetype : sbitsizetype;
else if (type == sizetype
|| type == ssizetype)
tem = unsignedp ? sizetype : ssizetype;
else
gcc_unreachable ();
if (TYPE_UNSIGNED (tem) == unsignedp)
return tem;
/* fallthrough asking the frontend */
}
return lang_hooks.types.type_for_size (TYPE_PRECISION (t), unsignedp);
? (of course in the end this langhook needs to go for LTO)
Richard.
2008-01-31 Richard Guenther <rguenther@suse.de>
PR middle-end/35043
* tree.c (signed_or_unsigned_type_for): Do not defer to
the frontends for middle-end sizetypes.
* gcc.c-torture/compile/pr35043.c: New testcase.
Index: tree.c
===================================================================
*** tree.c (revision 131977)
--- tree.c (working copy)
*************** signed_or_unsigned_type_for (int unsigne
*** 8082,8088 ****
if (!INTEGRAL_TYPE_P (t) || TYPE_UNSIGNED (t) == unsignedp)
return t;
!
return lang_hooks.types.type_for_size (TYPE_PRECISION (t), unsignedp);
}
--- 8082,8102 ----
if (!INTEGRAL_TYPE_P (t) || TYPE_UNSIGNED (t) == unsignedp)
return t;
!
! /* Do not defer to the frontends for middle-end sizetypes. */
! if (TREE_CODE (type) == INTEGER_TYPE
! && TYPE_IS_SIZETYPE (type))
! {
! if (type == bitsizetype
! || type == sbitsizetype)
! return unsignedp ? bitsizetype : sbitsizetype;
! else if (type == sizetype
! || type == ssizetype)
! return unsignedp ? sizetype : ssizetype;
! else
! gcc_unreachable ();
! }
!
return lang_hooks.types.type_for_size (TYPE_PRECISION (t), unsignedp);
}
Index: testsuite/gcc.c-torture/compile/pr35043.c
===================================================================
*** testsuite/gcc.c-torture/compile/pr35043.c (revision 0)
--- testsuite/gcc.c-torture/compile/pr35043.c (revision 0)
***************
*** 0 ****
--- 1,20 ----
+ typedef long unsigned int size_t;
+ typedef struct {
+ long double dat[2];
+ } gsl_complex_long_double;
+ typedef struct {
+ size_t size;
+ size_t stride;
+ long double *data;
+ } gsl_vector_complex_long_double;
+ void gsl_vector_complex_long_double_set_zero (gsl_vector_complex_long_double * v)
+ {
+ long double * const data = v->data;
+ const size_t n = v->size;
+ const size_t stride = v->stride;
+ const gsl_complex_long_double zero = { { 0.0L,0.0L} } ;
+ size_t i;
+ for (i = 0; i < n; i++)
+ *(gsl_complex_long_double *) (data + 2 * i * stride) = zero;
+ }
+