diff mbox

Fix PR52314

Message ID alpine.LNX.2.00.1202211505240.4999@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Feb. 21, 2012, 2:06 p.m. UTC
The gimplifier, when forcing a value to a temporary, uses the
type of the value for that temporary variable, making it for
example volatile or const, or puts it in a different address-space
even.  That's odd and not required, we can decay to the main-variant type.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2012-02-21  Richard Guenther  <rguenther@suse.de>

	PR middle-end/52314
	* gimplify.c (create_tmp_from_val): Use the main variant type
	for the type of the temporary we create.

Comments

Jakub Jelinek Feb. 21, 2012, 2:09 p.m. UTC | #1
On Tue, Feb 21, 2012 at 03:06:40PM +0100, Richard Guenther wrote:
> 
> The gimplifier, when forcing a value to a temporary, uses the
> type of the value for that temporary variable, making it for
> example volatile or const, or puts it in a different address-space
> even.  That's odd and not required, we can decay to the main-variant type.

Shouldn't restrict be preserved though?

> 2012-02-21  Richard Guenther  <rguenther@suse.de>
> 
> 	PR middle-end/52314
> 	* gimplify.c (create_tmp_from_val): Use the main variant type
> 	for the type of the temporary we create.
> 
> Index: gcc/gimplify.c
> ===================================================================
> --- gcc/gimplify.c	(revision 184435)
> +++ gcc/gimplify.c	(working copy)
> @@ -504,7 +504,8 @@ create_tmp_reg (tree type, const char *p
>  static inline tree
>  create_tmp_from_val (tree val)
>  {
> -  return create_tmp_var (TREE_TYPE (val), get_name (val));
> +  /* Drop all qualifiers and address-space information from the value type.  */
> +  return create_tmp_var (TYPE_MAIN_VARIANT (TREE_TYPE (val)), get_name (val));
>  }
>  
>  /* Create a temporary to hold the value of VAL.  If IS_FORMAL, try to reuse

	Jakub
Richard Biener Feb. 21, 2012, 2:10 p.m. UTC | #2
On Tue, 21 Feb 2012, Jakub Jelinek wrote:

> On Tue, Feb 21, 2012 at 03:06:40PM +0100, Richard Guenther wrote:
> > 
> > The gimplifier, when forcing a value to a temporary, uses the
> > type of the value for that temporary variable, making it for
> > example volatile or const, or puts it in a different address-space
> > even.  That's odd and not required, we can decay to the main-variant type.
> 
> Shouldn't restrict be preserved though?

No, we don't preserve restrict casts anymore.

Richard.
diff mbox

Patch

Index: gcc/gimplify.c
===================================================================
--- gcc/gimplify.c	(revision 184435)
+++ gcc/gimplify.c	(working copy)
@@ -504,7 +504,8 @@  create_tmp_reg (tree type, const char *p
 static inline tree
 create_tmp_from_val (tree val)
 {
-  return create_tmp_var (TREE_TYPE (val), get_name (val));
+  /* Drop all qualifiers and address-space information from the value type.  */
+  return create_tmp_var (TYPE_MAIN_VARIANT (TREE_TYPE (val)), get_name (val));
 }
 
 /* Create a temporary to hold the value of VAL.  If IS_FORMAL, try to reuse