OSDN Git Service

2011-11-09 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 9 Nov 2011 13:25:17 +0000 (13:25 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 9 Nov 2011 13:25:17 +0000 (13:25 +0000)
PR tree-optimization/51039
* gimple-low.c (gimple_check_call_args): Remove.
(gimple_check_call_matching_types): Always return true.
* tree-inline.c (setup_one_parameter): Always perform a
valid gimple type change.
(declare_return_variable): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181204 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/tree-inline.c

index a418265..20307dd 100644 (file)
@@ -1,3 +1,10 @@
+2011-11-09  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/51039
+       * tree-inline.c (setup_one_parameter): Always perform a
+       valid gimple type change.
+       (declare_return_variable): Likewise.
+
 2011-11-09  Jakub Jelinek  <jakub@redhat.com>
 
        * config/rs6000/vector.md (vcondv4sfv4si, vcondv4siv4sf,
index 4ca4fa4..7daa9d2 100644 (file)
@@ -2574,14 +2574,21 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn,
       && value != error_mark_node
       && !useless_type_conversion_p (TREE_TYPE (p), TREE_TYPE (value)))
     {
+      /* If we can match up types by promotion/demotion do so.  */
       if (fold_convertible_p (TREE_TYPE (p), value))
-       rhs = fold_build1 (NOP_EXPR, TREE_TYPE (p), value);
+       rhs = fold_convert (TREE_TYPE (p), value);
       else
-       /* ???  For valid (GIMPLE) programs we should not end up here.
-          Still if something has gone wrong and we end up with truly
-          mismatched types here, fall back to using a VIEW_CONVERT_EXPR
-          to not leak invalid GIMPLE to the following passes.  */
-       rhs = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (p), value);
+       {
+         /* ???  For valid programs we should not end up here.
+            Still if we end up with truly mismatched types here, fall back
+            to using a VIEW_CONVERT_EXPR or a literal zero to not leak invalid
+            GIMPLE to the following passes.  */
+         if (!is_gimple_reg_type (TREE_TYPE (value))
+             || TYPE_SIZE (TREE_TYPE (p)) == TYPE_SIZE (TREE_TYPE (value)))
+           rhs = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (p), value);
+         else
+           rhs = build_zero_cst (TREE_TYPE (p));
+       }
     }
 
   /* Make an equivalent VAR_DECL.  Note that we must NOT remap the type
@@ -2912,7 +2919,27 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest,
      promoted, convert it back to the expected type.  */
   use = var;
   if (!useless_type_conversion_p (caller_type, TREE_TYPE (var)))
-    use = fold_convert (caller_type, var);
+    {
+      /* If we can match up types by promotion/demotion do so.  */
+      if (fold_convertible_p (caller_type, var))
+       use = fold_convert (caller_type, var);
+      else
+       {
+         /* ???  For valid programs we should not end up here.
+            Still if we end up with truly mismatched types here, fall back
+            to using a MEM_REF to not leak invalid GIMPLE to the following
+            passes.  */
+         /* Prevent var from being written into SSA form.  */
+         if (TREE_CODE (TREE_TYPE (var)) == VECTOR_TYPE
+             || TREE_CODE (TREE_TYPE (var)) == COMPLEX_TYPE)
+           DECL_GIMPLE_REG_P (var) = false;
+         else if (is_gimple_reg_type (TREE_TYPE (var)))
+           TREE_ADDRESSABLE (var) = true;
+         use = fold_build2 (MEM_REF, caller_type,
+                            build_fold_addr_expr (var),
+                            build_int_cst (ptr_type_node, 0));
+       }
+    }
 
   STRIP_USELESS_TYPE_CONVERSION (use);