Patchwork Patch: PR40900, extending call patterns

login
register
mail settings
Submitter Eric Botcazou
Date June 16, 2010, 8:34 p.m.
Message ID <201006162234.20410.ebotcazou@adacore.com>
Download mbox | patch
Permalink /patch/55935/
State New
Headers show

Comments

Eric Botcazou - June 16, 2010, 8:34 p.m.
> That would be good.

Very lightly tested.


	* expr.c (expand_expr_real_1) <SSA_NAME>: Fix long line.  Save the
	original expression for later reuse.
	<expand_decl_rtl>: Use promote_function_mode to compute the signedness
	of the promoted RTL for a SSA_NAME on the LHS of a call statement.
Bernd Schmidt - June 18, 2010, 12:05 a.m.
On 06/16/2010 10:34 PM, Eric Botcazou wrote:
> Very lightly tested.
> 
> 
> 	* expr.c (expand_expr_real_1) <SSA_NAME>: Fix long line.  Save the
> 	original expression for later reuse.
> 	<expand_decl_rtl>: Use promote_function_mode to compute the signedness
> 	of the promoted RTL for a SSA_NAME on the LHS of a call statement.

This survived my normal arm-none-linux-gnueabi testing.  Ok, but please
also check in the testcase I included with my patch.


Bernd
Eric Botcazou - June 18, 2010, 4:35 p.m.
> This survived my normal arm-none-linux-gnueabi testing.  Ok, but please
> also check in the testcase I included with my patch.

Thanks, bootstrapped/regtested on x86_64-suse-linux, applied on the mainline.

Patch

Index: expr.c
===================================================================
--- expr.c	(revision 160776)
+++ expr.c	(working copy)
@@ -8284,6 +8284,8 @@  expand_expr_real_1 (tree exp, rtx target
   location_t loc = EXPR_LOCATION (exp);
   struct separate_ops ops;
   tree treeop0, treeop1, treeop2;
+  tree ssa_name = NULL_TREE;
+  gimple g;
 
   type = TREE_TYPE (exp);
   mode = TYPE_MODE (type);
@@ -8396,15 +8398,17 @@  expand_expr_real_1 (tree exp, rtx target
 	 base variable.  This unnecessarily allocates a pseudo, see how we can
 	 reuse it, if partition base vars have it set already.  */
       if (!currently_expanding_to_rtl)
-	return expand_expr_real_1 (SSA_NAME_VAR (exp), target, tmode, modifier, NULL);
-      {
-	gimple g = get_gimple_for_ssa_name (exp);
-	if (g)
-	  return expand_expr_real (gimple_assign_rhs_to_tree (g), target,
-				   tmode, modifier, NULL);
-      }
-      decl_rtl = get_rtx_for_ssa_name (exp);
-      exp = SSA_NAME_VAR (exp);
+	return expand_expr_real_1 (SSA_NAME_VAR (exp), target, tmode, modifier,
+				   NULL);
+
+      g = get_gimple_for_ssa_name (exp);
+      if (g)
+	return expand_expr_real (gimple_assign_rhs_to_tree (g), target, tmode,
+				 modifier, NULL);
+
+      ssa_name = exp;
+      decl_rtl = get_rtx_for_ssa_name (ssa_name);
+      exp = SSA_NAME_VAR (ssa_name);
       goto expand_decl_rtl;
 
     case PARM_DECL:
@@ -8506,15 +8510,21 @@  expand_expr_real_1 (tree exp, rtx target
       /* If the mode of DECL_RTL does not match that of the decl, it
 	 must be a promoted value.  We return a SUBREG of the wanted mode,
 	 but mark it so that we know that it was already extended.  */
-
-      if (REG_P (decl_rtl)
-	  && GET_MODE (decl_rtl) != DECL_MODE (exp))
+      if (REG_P (decl_rtl) && GET_MODE (decl_rtl) != DECL_MODE (exp))
 	{
 	  enum machine_mode pmode;
 
-	  /* Get the signedness used for this variable.  Ensure we get the
-	     same mode we got when the variable was declared.  */
-	  pmode = promote_decl_mode (exp, &unsignedp);
+	  /* Get the signedness to be used for this variable.  Ensure we get
+	     the same mode we got when the variable was declared.  */
+	  if (code == SSA_NAME
+	      && (g = SSA_NAME_DEF_STMT (ssa_name))
+	      && gimple_code (g) == GIMPLE_CALL)
+	    pmode = promote_function_mode (type, mode, &unsignedp,
+					   TREE_TYPE
+					   (TREE_TYPE (gimple_call_fn (g))),
+					   2);
+	  else
+	    pmode = promote_decl_mode (exp, &unsignedp);
 	  gcc_assert (GET_MODE (decl_rtl) == pmode);
 
 	  temp = gen_lowpart_SUBREG (mode, decl_rtl);