[patch v2] Fix PR middle-end/42224

Richard Guenther rguenther@suse.de
Wed Dec 2 11:34:00 GMT 2009


On Tue, 1 Dec 2009, Ulrich Weigand wrote:

> Richard Guenther wrote:
> 
> > Or remove int_or_pointer_precision alltogether - it seems to be
> > a remanent of named-address-space development and certainly was
> > useful there.
> 
> OK, fine with me.  The following version of the patch eliminates
> the routine.
> 
> Tested on s390x-ibm-linux.
> OK?

Ok.

Thanks,
Richard.

> Bye,
> Ulrich
> 
> ChangeLog:
> 
> gcc/
> 	* tree.h (int_or_pointer_precision): Remove.
> 	* tree.c (int_or_pointer_precision): Remove.
> 	(integer_pow2p): Use TYPE_PRECISION instead.
> 	(tree_log2): Likewise.
> 	(tree_floor_log2): Likewise.
> 	(signed_or_unsigned_type_for): Likewise.
> 	* fold-const.c (fit_double_type): Likewise.
> 	* varasm.c (initializer_constant_valid_p): Likewise.
> 
> gcc/testsuite/
> 	* gcc.target/s390/pr42224.c: New test.
> 
> 
> Index: gcc/tree.c
> ===================================================================
> *** gcc/tree.c	(revision 154204)
> --- gcc/tree.c	(working copy)
> *************** integer_pow2p (const_tree expr)
> *** 1684,1690 ****
>     if (TREE_CODE (expr) != INTEGER_CST)
>       return 0;
>   
> !   prec = int_or_pointer_precision (TREE_TYPE (expr));
>     high = TREE_INT_CST_HIGH (expr);
>     low = TREE_INT_CST_LOW (expr);
>   
> --- 1684,1690 ----
>     if (TREE_CODE (expr) != INTEGER_CST)
>       return 0;
>   
> !   prec = TYPE_PRECISION (TREE_TYPE (expr));
>     high = TREE_INT_CST_HIGH (expr);
>     low = TREE_INT_CST_LOW (expr);
>   
> *************** tree_log2 (const_tree expr)
> *** 1748,1754 ****
>     if (TREE_CODE (expr) == COMPLEX_CST)
>       return tree_log2 (TREE_REALPART (expr));
>   
> !   prec = int_or_pointer_precision (TREE_TYPE (expr));
>     high = TREE_INT_CST_HIGH (expr);
>     low = TREE_INT_CST_LOW (expr);
>   
> --- 1748,1754 ----
>     if (TREE_CODE (expr) == COMPLEX_CST)
>       return tree_log2 (TREE_REALPART (expr));
>   
> !   prec = TYPE_PRECISION (TREE_TYPE (expr));
>     high = TREE_INT_CST_HIGH (expr);
>     low = TREE_INT_CST_LOW (expr);
>   
> *************** tree_floor_log2 (const_tree expr)
> *** 1784,1790 ****
>     if (TREE_CODE (expr) == COMPLEX_CST)
>       return tree_log2 (TREE_REALPART (expr));
>   
> !   prec = int_or_pointer_precision (TREE_TYPE (expr));
>     high = TREE_INT_CST_HIGH (expr);
>     low = TREE_INT_CST_LOW (expr);
>   
> --- 1784,1790 ----
>     if (TREE_CODE (expr) == COMPLEX_CST)
>       return tree_log2 (TREE_REALPART (expr));
>   
> !   prec = TYPE_PRECISION (TREE_TYPE (expr));
>     high = TREE_INT_CST_HIGH (expr);
>     low = TREE_INT_CST_LOW (expr);
>   
> *************** signed_or_unsigned_type_for (int unsigne
> *** 9681,9692 ****
>   	 based on the named address space it points to.  */
>         if (!TYPE_ADDR_SPACE (TREE_TYPE (t)))
>   	t = size_type_node;
> - 
>         else
> ! 	{
> ! 	  int prec = int_or_pointer_precision (t);
> ! 	  return lang_hooks.types.type_for_size (prec, unsignedp);
> ! 	}
>       }
>   
>     if (!INTEGRAL_TYPE_P (t) || TYPE_UNSIGNED (t) == unsignedp)
> --- 9681,9688 ----
>   	 based on the named address space it points to.  */
>         if (!TYPE_ADDR_SPACE (TREE_TYPE (t)))
>   	t = size_type_node;
>         else
> ! 	return lang_hooks.types.type_for_size (TYPE_PRECISION (t), unsignedp);
>       }
>   
>     if (!INTEGRAL_TYPE_P (t) || TYPE_UNSIGNED (t) == unsignedp)
> *************** build_target_option_node (void)
> *** 10561,10601 ****
>     return t;
>   }
>   
> - /* Return the size in bits of an integer or pointer type.  TYPE_PRECISION
> -    contains the bits, but in the past it was not set in some cases and there
> -    was special purpose code that checked for POINTER_TYPE_P or OFFSET_TYPE, so
> -    check that it is consitant when assertion checking is used.  */
> - 
> - unsigned int
> - int_or_pointer_precision (const_tree type)
> - {
> - #if ENABLE_ASSERT_CHECKING
> -   unsigned int prec;
> - 
> -   if (POINTER_TYPE_P (type))
> -     {
> -       addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (type));
> -       prec = GET_MODE_BITSIZE (targetm.addr_space.pointer_mode (as));
> -       gcc_assert (prec == TYPE_PRECISION (type));
> -     }
> -   else if (TREE_CODE (type) == OFFSET_TYPE)
> -     {
> -       prec = POINTER_SIZE;
> -       gcc_assert (prec == TYPE_PRECISION (type));
> -     }
> -   else
> -     {
> -       prec = TYPE_PRECISION (type);
> -       gcc_assert (prec != 0);
> -     }
> - 
> -   return prec;
> - 
> - #else
> -   return TYPE_PRECISION (type);
> - #endif
> - }
> - 
>   /* Determine the "ultimate origin" of a block.  The block may be an inlined
>      instance of an inlined instance of a block which is local to an inline
>      function, so we have to trace all of the way back through the origin chain
> --- 10557,10562 ----
> Index: gcc/tree.h
> ===================================================================
> *** gcc/tree.h	(revision 154204)
> --- gcc/tree.h	(working copy)
> *************** extern const char *get_name (tree);
> *** 4703,4709 ****
>   extern bool stdarg_p (tree);
>   extern bool prototype_p (tree);
>   extern bool auto_var_in_fn_p (const_tree, const_tree);
> - extern unsigned int int_or_pointer_precision (const_tree);
>   extern tree build_low_bits_mask (tree, unsigned);
>   extern tree tree_strip_nop_conversions (tree);
>   extern tree tree_strip_sign_nop_conversions (tree);
> --- 4703,4708 ----
> Index: gcc/fold-const.c
> ===================================================================
> *** gcc/fold-const.c	(revision 154204)
> --- gcc/fold-const.c	(working copy)
> *************** fit_double_type (unsigned HOST_WIDE_INT 
> *** 206,212 ****
>   {
>     unsigned HOST_WIDE_INT low0 = l1;
>     HOST_WIDE_INT high0 = h1;
> !   unsigned int prec = int_or_pointer_precision (type);
>     int sign_extended_type;
>   
>     /* Size types *are* sign extended.  */
> --- 206,212 ----
>   {
>     unsigned HOST_WIDE_INT low0 = l1;
>     HOST_WIDE_INT high0 = h1;
> !   unsigned int prec = TYPE_PRECISION (type);
>     int sign_extended_type;
>   
>     /* Size types *are* sign extended.  */
> Index: gcc/varasm.c
> ===================================================================
> *** gcc/varasm.c	(revision 154204)
> --- gcc/varasm.c	(working copy)
> *************** initializer_constant_valid_p (tree value
> *** 4327,4334 ****
>         if (TREE_CODE (endtype) == REAL_TYPE)
>   	return NULL_TREE;
>         if (! INTEGRAL_TYPE_P (endtype)
> ! 	  || TYPE_PRECISION (endtype)
> ! 	     >= int_or_pointer_precision (TREE_TYPE (value)))
>   	{
>   	  tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0),
>   						      endtype);
> --- 4327,4333 ----
>         if (TREE_CODE (endtype) == REAL_TYPE)
>   	return NULL_TREE;
>         if (! INTEGRAL_TYPE_P (endtype)
> ! 	  || TYPE_PRECISION (endtype) >= TYPE_PRECISION (TREE_TYPE (value)))
>   	{
>   	  tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0),
>   						      endtype);
> *************** initializer_constant_valid_p (tree value
> *** 4352,4359 ****
>         if (TREE_CODE (endtype) == REAL_TYPE)
>   	return NULL_TREE;
>         if (! INTEGRAL_TYPE_P (endtype)
> ! 	  || TYPE_PRECISION (endtype)
> ! 	     >= int_or_pointer_precision (TREE_TYPE (value)))
>   	{
>   	  tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0),
>   						      endtype);
> --- 4351,4357 ----
>         if (TREE_CODE (endtype) == REAL_TYPE)
>   	return NULL_TREE;
>         if (! INTEGRAL_TYPE_P (endtype)
> ! 	  || TYPE_PRECISION (endtype) >= TYPE_PRECISION (TREE_TYPE (value)))
>   	{
>   	  tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0),
>   						      endtype);
> *** /dev/null	Tue Apr 21 17:12:33 2009
> --- gcc/testsuite/gcc.target/s390/pr42224.c	Mon Nov 30 16:21:01 2009
> ***************
> *** 0 ****
> --- 1,36 ----
> + 
> + /* { dg-do compile } */
> + /* { dg-options "-O0" } */
> + 
> + typedef char* __char_ptr32 __attribute__ (( mode (SI) ));
> + typedef __char_ptr32 *__char_ptr_char_ptr32 __attribute__ ((mode (SI)));
> + 
> + void to_ptr32 (int x)
> + {
> +   __char_ptr32 ptr = (__char_ptr32) x;
> + }
> + 
> + void to_int (__char_ptr32 ptr)
> + {
> +   int x = (int) ptr;
> + }
> + 
> + __char_ptr_char_ptr32
> + to_ptr32_ptr32 (char **ptr64)
> + {
> +   int argc;
> +   __char_ptr_char_ptr32 short_argv;
> + 
> +   for (argc=0; ptr64[argc]; argc++);
> + 
> +   short_argv = (__char_ptr_char_ptr32) malloc32
> +     (sizeof (__char_ptr32) * (argc + 1));
> + 
> +   for (argc=0; ptr64[argc]; argc++)
> +     short_argv[argc] = (__char_ptr32) strdup32 (ptr64[argc]);
> + 
> +   short_argv[argc] = (__char_ptr32) 0;
> +   return short_argv;
> + 
> + }
> + 
> 
> 

-- 
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex



More information about the Gcc-patches mailing list