]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/44891 (non-trivial conversion ICE from early SRA)
authorMartin Jambor <mjambor@suse.cz>
Thu, 22 Jul 2010 12:52:14 +0000 (14:52 +0200)
committerMartin Jambor <jamborm@gcc.gnu.org>
Thu, 22 Jul 2010 12:52:14 +0000 (14:52 +0200)
2010-07-22  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/44891
* tree-sra.c: Include gimple-pretty-print.h.
(replace_uses_with_default_def_ssa_name): Renamed to
get_repl_default_def_ssa_name, return the new SSA name instead of
replacing the old one.
(sra_modify_assign): Dump a message when removing a load, if the LHS
is an SSA_NAME, do not do any propagation, just set the RHS to a
default definition SSA NAME, type convert if necessary.
* Makefile.in (tree-sra.o): Add gimple-pretty-print.h to dependencies.

* testsuite/gcc.c-torture/compile/pr44891.c: New test.

From-SVN: r162413

gcc/ChangeLog
gcc/Makefile.in
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr44891.c [new file with mode: 0644]
gcc/tree-sra.c

index b9725dce3073783e23d4663a5ca06e350e22e3bd..f4ed6e49890742c47b7382eef87608383cf564fb 100644 (file)
@@ -1,3 +1,15 @@
+2010-07-22  Martin Jambor  <mjambor@suse.cz>
+
+       PR tree-optimization/44891
+       * tree-sra.c: Include gimple-pretty-print.h.
+       (replace_uses_with_default_def_ssa_name): Renamed to
+       get_repl_default_def_ssa_name, return the new SSA name instead of
+       replacing the old one.
+       (sra_modify_assign): Dump a message when removing a load, if the LHS
+       is an SSA_NAME, do not do any propagation, just set the RHS to a
+       default definition SSA NAME, type convert if necessary.
+       * Makefile.in (tree-sra.o): Add gimple-pretty-print.h to dependencies.
+
 2010-07-22  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/45017
index e900c7375ef8408903756cddd083f2f68bfb24b9..22e4ee80fe24cc7f8c65e2a05b2e50baa8daf317 100644 (file)
@@ -3132,7 +3132,7 @@ tree-sra.o : tree-sra.c $(CONFIG_H) $(SYSTEM_H) coretypes.h alloc-pool.h \
    $(TM_H) $(TREE_H) $(GIMPLE_H) $(CGRAPH_H) $(TREE_FLOW_H) $(IPA_PROP_H) \
    $(DIAGNOSTIC_H) statistics.h $(TREE_DUMP_H) $(TIMEVAR_H) $(PARAMS_H) \
    $(TARGET_H) $(FLAGS_H) $(EXPR_H) tree-pretty-print.h $(DBGCNT_H) \
-   $(TREE_INLINE_H)
+   $(TREE_INLINE_H) gimple-pretty-print.h
 tree-switch-conversion.o : tree-switch-conversion.c $(CONFIG_H) $(SYSTEM_H) \
     $(TREE_H) $(TM_P_H) $(TREE_FLOW_H) $(DIAGNOSTIC_H) $(TREE_INLINE_H) \
     $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) $(GIMPLE_H) \
index 35ae9948cfb1a7efe75e67e9d1f75d91a3bec3e9..7bffd78e1dcbd826e80123932bcade2d77e7a224 100644 (file)
@@ -1,3 +1,8 @@
+2010-07-22  Martin Jambor  <mjambor@suse.cz>
+
+       PR tree-optimization/44891
+       * testsuite/gcc.c-torture/compile/pr44891.c: New test.
+
 2010-07-22  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/45017
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr44891.c b/gcc/testsuite/gcc.c-torture/compile/pr44891.c
new file mode 100644 (file)
index 0000000..145b144
--- /dev/null
@@ -0,0 +1,26 @@
+struct S
+{
+  float f;
+  long l;
+};
+
+extern int gi;
+extern float gf;
+
+long foo (long p)
+{
+  struct S s;
+  float *pf;
+
+  s.l = p;
+
+  pf = &s.f;
+
+  pf++;
+  pf--;
+
+  gf = *pf + 3.3;
+  gi = *((int *)pf) + 2;
+
+  return s.l + 6;
+}
index 9fd6d2cc5922d45f38caee3d5b9b034398b4e57b..c051dd496f7118099149831a7ef8cb437d04cbd2 100644 (file)
@@ -90,6 +90,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "flags.h"
 #include "dbgcnt.h"
 #include "tree-inline.h"
+#include "gimple-pretty-print.h"
 
 /* Enumeration of all aggregate reductions we can do.  */
 enum sra_mode { SRA_MODE_EARLY_IPA,   /* early call regularization */
@@ -2542,12 +2543,12 @@ sra_modify_constructor_assign (gimple *stmt, gimple_stmt_iterator *gsi)
     }
 }
 
-/* Create a new suitable default definition SSA_NAME and replace all uses of
-   SSA with it, RACC is access describing the uninitialized part of an
-   aggregate that is being loaded.  */
+/* Create and return a new suitable default definition SSA_NAME for RACC which
+   is an access describing an uninitialized part of an aggregate that is being
+   loaded.  */
 
-static void
-replace_uses_with_default_def_ssa_name (tree ssa, struct access *racc)
+static tree
+get_repl_default_def_ssa_name (struct access *racc)
 {
   tree repl, decl;
 
@@ -2560,7 +2561,7 @@ replace_uses_with_default_def_ssa_name (tree ssa, struct access *racc)
       set_default_def (decl, repl);
     }
 
-  replace_uses_by (ssa, repl);
+  return repl;
 }
 
 /* Examine both sides of the assignment statement pointed to by STMT, replace
@@ -2737,18 +2738,33 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi)
            {
              if (!racc->grp_to_be_replaced && !racc->grp_unscalarized_data)
                {
-                 if (racc->first_child)
-                   generate_subtree_copies (racc->first_child, lhs,
-                                            racc->offset, 0, 0, gsi,
-                                            false, false);
-                 gcc_assert (*stmt == gsi_stmt (*gsi));
-                 if (TREE_CODE (lhs) == SSA_NAME)
-                   replace_uses_with_default_def_ssa_name (lhs, racc);
+                 if (dump_file)
+                   {
+                     fprintf (dump_file, "Removing load: ");
+                     print_gimple_stmt (dump_file, *stmt, 0, 0);
+                   }
 
-                 unlink_stmt_vdef (*stmt);
-                 gsi_remove (gsi, true);
-                 sra_stats.deleted++;
-                 return SRA_AM_REMOVED;
+                 if (TREE_CODE (lhs) == SSA_NAME)
+                   {
+                     rhs = get_repl_default_def_ssa_name (racc);
+                     if (!useless_type_conversion_p (TREE_TYPE (lhs),
+                                                     TREE_TYPE (rhs)))
+                       rhs = fold_build1_loc (loc, VIEW_CONVERT_EXPR,
+                                              TREE_TYPE (lhs), rhs);
+                   }
+                 else
+                   {
+                     if (racc->first_child)
+                       generate_subtree_copies (racc->first_child, lhs,
+                                                racc->offset, 0, 0, gsi,
+                                                false, false);
+
+                     gcc_assert (*stmt == gsi_stmt (*gsi));
+                     unlink_stmt_vdef (*stmt);
+                     gsi_remove (gsi, true);
+                     sra_stats.deleted++;
+                     return SRA_AM_REMOVED;
+                   }
                }
              else if (racc->first_child)
                generate_subtree_copies (racc->first_child, lhs,