From 56a42add96f40b6dfd8002abfc3e55f5ccf40535 Mon Sep 17 00:00:00 2001 From: Martin Jambor Date: Thu, 22 Jul 2010 14:52:14 +0200 Subject: [PATCH] re PR tree-optimization/44891 (non-trivial conversion ICE from early SRA) 2010-07-22 Martin Jambor 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 | 12 +++++ gcc/Makefile.in | 2 +- gcc/testsuite/ChangeLog | 5 ++ gcc/testsuite/gcc.c-torture/compile/pr44891.c | 26 ++++++++++ gcc/tree-sra.c | 50 ++++++++++++------- 5 files changed, 77 insertions(+), 18 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr44891.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b9725dce307..f4ed6e49890 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2010-07-22 Martin Jambor + + 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 PR tree-optimization/45017 diff --git a/gcc/Makefile.in b/gcc/Makefile.in index e900c7375ef..22e4ee80fe2 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -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) \ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 35ae9948cfb..7bffd78e1dc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-07-22 Martin Jambor + + PR tree-optimization/44891 + * testsuite/gcc.c-torture/compile/pr44891.c: New test. + 2010-07-22 Richard Guenther 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 index 00000000000..145b1446903 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr44891.c @@ -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; +} diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 9fd6d2cc592..c051dd496f7 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -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,