This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Make IPA-CP work on aggregates


Hi,

On Tue, Nov 06, 2012 at 04:22:41PM +0100, Jan Hubicka wrote:
> > 
> > 2012-11-05  Martin Jambor  <mjambor@suse.cz>
> > 
> > 	PR tree-optimization/53787
> > 	* ipa-cp.c (ipcp_value_source): New field offset.
> > 	(ipcp_agg_lattice): New type.
> > 	(ipcp_param_lattices): Likewise, move virt_call from ipcp_lattice here.
> > 	(ipcp_agg_lattice_pool): New variable.
> > 	(ipa_get_parm_lattices): New function.
> > 	(ipa_get_lattice): Turned into ipa_get_scalar_lat, use the above.
> > 	Adjusted all callers.
> > 	(print_lattice): New function.
> > 	(print_all_lattices): Use the above, also print aggregate lattices.
> > 	(set_agg_lats_to_bottom): New function.
> > 	(set_agg_lats_contain_variable): Likewise.
> > 	(set_all_contains_variable): Likewise.
> > 	(initialize_node_lattices): Also handle aggregate lattices, set
> > 	virt_call in ipcp_param_lattices.
> > 	(add_value_source): Handle offsets.
> > 	(add_value_to_lattice): Likewise.
> > 	(add_scalar_value_to_lattice): New function.
> > 	(propagate_vals_accross_pass_through): Use add_scalar_value_to_lattice.
> > 	(propagate_vals_accross_ancestor): Likewise.
> > 	(propagate_accross_jump_function): Renamed to
> > 	propagate_scalar_accross_jump_function, use
> > 	add_scalar_value_to_lattice.
> > 	(set_check_aggs_by_ref): New function.
> > 	(merge_agg_lats_step): Likewise.
> > 	(set_chain_of_aglats_contains_variable): Likewise.
> > 	(merge_aggregate_lattices): Likewise.
> > 	(propagate_constants_accross_call): Also handle aggregate lattices.
> > 	(hint_time_bonus): New function.
> > 	(context_independent_aggregate_values): Likewise.
> > 	(gather_context_independent_values): Also handle agggregate values.
> > 	(agg_jmp_p_vec_for_t_vec): New function.
> > 	(estimate_local_effects): Also handle agggregate values.
> > 	(add_all_node_vals_to_toposort): Likewise.
> > 	(ipcp_propagate_stage): Use struct ipcp_param_lattices.
> > 	(get_clone_agg_value): New function.
> > 	(cgraph_edge_brings_value_p): Also handle agggregate values.
> > 	(create_specialized_node): Likewise.
> > 	(find_more_values_for_callers_subset): Rename to
> > 	find_more_scalar_values_for_callers_subset.  Modify dump.
> > 	(copy_plats_to_inter): New function.
> > 	(intersect_with_plats): Likewise.
> > 	(agg_replacements_to_vector): Likewise.
> > 	(intersect_with_agg_replacements): Likewise.
> > 	(find_aggregate_values_for_callers_subset): Likewise.
> > 	(known_aggs_to_agg_replacement_list): Likewise.
> > 	(cgraph_edge_brings_all_scalars_for_node): Likewise.
> > 	(cgraph_edge_brings_all_agg_vals_for_node): Likewise.
> > 	(perhaps_add_new_callers): Old functionality moved to
> > 	cgraph_edge_brings_all_scalars_for_node, call it and
> > 	cgraph_edge_brings_all_agg_vals_for_node.
> > 	(ipcp_val_in_agg_replacements_p): New function.
> > 	(decide_about_value): New function.
> > 	(decide_whether_version_node): A lot of functionality moved to
> > 	decide_about_value.  Also handle agggregate values.
> > 	(ipcp_driver): Also allocate ipcp_agg_lattice_pool.
> > 	(pass_ipa_cp): Fill in new entries.
> > 	* ipa-prop.c (ipa_node_agg_replacements): New variable.
> > 	(free_parms_ainfo): New function.
> > 	(ipa_analyze_node): Use free_parms_ainfo to free stuff.
> > 	(ipa_find_agg_cst_for_param): Do not rely on offset ordering.
> > 	(ipa_set_node_agg_value_chain): New function.
> > 	(ipa_node_removal_hook): Also handle ipa_node_agg_replacements.
> > 	(ipa_node_duplication_hook): Likewise.
> > 	(ipa_free_all_structures_after_ipa_cp): Also free ipcp_agg_lattice_pool.
> > 	(ipa_free_all_structures_after_iinln): Likewise.
> > 	(ipa_dump_agg_replacement_values): New function.
> > 	(write_agg_replacement_chain): Likewise.
> > 	(read_agg_replacement_chain): Likewise.
> > 	(ipa_prop_write_all_agg_replacement): Likewise.
> > 	(read_replacements_section): Likewise.
> > 	(ipa_prop_read_all_agg_replacement): Likewise.
> > 	(adjust_agg_replacement_values): Likewise.
> > 	(ipcp_transform_function): Likewise.
> > 	* ipa-prop.h: Also define heap vector of ipa_agg_jf_item_t and of
> > 	ipa_agg_jump_function_t.
> > 	(ipa_node_params): Make lattices an array of ipcp_param_lattices.
> > 	(ipa_agg_replacement_value): New type and its vector.
> > 	(ipa_set_node_agg_value_chain) Declare.
> > 	(ipa_node_agg_replacements): Likewise.
> > 	(ipa_get_agg_replacements_for_node): New function.
> > 	(ipcp_agg_lattice_pool): Declare.
> > 	(ipa_dump_agg_replacement_values): Likewise.
> > 	(ipa_prop_write_all_agg_replacement): Likewise.
> > 	(ipa_prop_read_all_agg_replacement): Likewise.
> > 	(ipcp_transform_function): Likewise.
> > 	* ipa-inline-analysis.c (estimate_ipcp_clone_size_and_time): Pass around
> > 	known aggregates and hints.
> > 	* ipa-inline.h: include ipa-prop.h.
> > 	(estimate_ipcp_clone_size_and_time): Adjust declaration.
> > 	* lto-streamer.h (lto_section_type): New item
> > 	LTO_section_ipcp_transform.
> > 	* lto-section-in.c (lto_section_name): New element ipcp_trans.
> > 	* params.def (PARAM_IPA_CP_LOOP_HINT_BONUS): New parameter.
> > 	* Makefile.in (IPA_INLINE_H): New.  Use everywhee instead of
> > 	ipa-inline.h.
> > 
> > 	* testsuite/gcc.dg/ipa/ipa-5.c: Adjust.
> > 	* testsuite/gcc.dg/ipa/ipcp-agg-1.c: New test.
> > 	* testsuite/gcc.dg/ipa/ipcp-agg-2.c: Likewise.
> > 	* testsuite/gcc.dg/ipa/ipcp-agg-3.c: Likewise.
> > 	* testsuite/gcc.dg/ipa/ipcp-agg-4.c: Likewise.
> > 	* testsuite/gcc.dg/ipa/ipcp-agg-5.c: Likewise.
> > 	* testsuite/gcc.dg/ipa/ipcp-agg-6.c: Likewise.
> > 	* testsuite/gfortran.dg/pr48636.f90: Add -fno-ipa-cp.
> > 	* testsuite/gfortran.dg/pr48636-2.f90: New test.
> > 	* testsuite/gfortran.dg/pr53787.f90: Likewise.
> > 
> > 
> > Index: src/gcc/ipa-cp.c
> > ===================================================================
> > *** src.orig/gcc/ipa-cp.c
> > --- src/gcc/ipa-cp.c
> > + /* The current interface in ipa-inline-analysis requires a pointer vector.
> > +    Create it.
> > + 
> > +    FIXME: That interface should be re-worked, this is slightly silly.  Still,
> > +    I'd like to discuss how to change it first and this demonstrates the
> > +    issue.  */
> 
> Hmm, any proposals?

known_aggs vector that we care about might be a vector of pointers
(pointing into parts of aggregate functions) or a vector of structures
that IPA-CP has gathered and that live independently.

So we might want to make known_aggs a structure of a union of these
two with a flag and make the lookup function handle both cases or, we
might handle this by a callback, which should really be two virtual
methods in our new brave C++ world...

...but I did not want to include virtual functions in such a huge
patch :-) and certainly wanted to have a discussion about their merit
in this case separate from its review :-).  However, since the review
went rather well, I'm certainly interested in all opinions.

> 
> I read the propagation part. It seems a lot of work and did not find anything that seems
> wrong. You know the code better than anyone else :)
> 
> > + /* Function body transformation phase.  */
> > + 
> > + unsigned int
> > + ipcp_transform_function (struct cgraph_node *node)
> > + {
> > +   VEC (ipa_param_descriptor_t, heap) *descriptors = NULL;
> > +   struct param_analysis_info *parms_ainfo;
> > +   struct ipa_agg_replacement_value *aggval;
> > +   gimple_stmt_iterator gsi;
> > +   basic_block bb;
> > +   int param_count;
> > +   bool cfg_changed = false, something_changed = false;
> > + 
> > +   gcc_checking_assert (cfun);
> > +   gcc_checking_assert (current_function_decl);
> > + 
> > +   if (dump_file)
> > +     fprintf (dump_file, "Modification phase of node %s/%i\n",
> > + 	     cgraph_node_name (node), node->uid);
> > + 
> > +   aggval = ipa_get_agg_replacements_for_node (node);
> > +   if (!aggval)
> > +       return 0;
> > +   param_count = count_formal_params (node->symbol.decl);
> > +   if (param_count == 0)
> > +     return 0;
> > +   adjust_agg_replacement_values (node, aggval);
> > +   if (dump_file)
> > +     ipa_dump_agg_replacement_values (dump_file, aggval);
> > +   parms_ainfo = XALLOCAVEC (struct param_analysis_info, param_count);
> > +   memset (parms_ainfo, 0, sizeof (struct param_analysis_info) * param_count);
> > +   VEC_safe_grow_cleared (ipa_param_descriptor_t, heap,
> > + 			 descriptors, param_count);
> > +   ipa_populate_param_decls (node, descriptors);
> > + 
> > +   FOR_EACH_BB (bb)
> > +     for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
> > +       {
> > + 	struct ipa_agg_replacement_value *v;
> > + 	gimple stmt = gsi_stmt (gsi);
> > + 	tree rhs, val;
> > + 	HOST_WIDE_INT offset;
> > + 	int index;
> > + 	bool by_ref;
> > + 
> > + 	if (is_gimple_debug (stmt)
> > + 	    || !gimple_assign_single_p (stmt)
> > + 	    || !gimple_vuse (stmt))
> 
> I think you can check the new gimple_load_p predicate.

Oh, that's very handy, thanks.

> The calls/asm statements and friends don't need updating because we
> always go through an temporary when handling gimple register and you
> do not propagate anything else?

Yes.

> 
> > + 	  continue;
> > + 	rhs = gimple_assign_rhs1 (stmt);
> > + 	if (!is_gimple_reg_type (TREE_TYPE (rhs))
> > + 	    /* V_C_E can do things like convert an array of integers to one
> > +                bigger integer and similar things we do not handle below.  */
> > +             || TREE_CODE (rhs) == VIEW_CONVERT_EXPR)
> > + 	  continue;
> 
> Hmm, shouldn't you look for the inner references (i.e. skip the handled components)?

You're right, fixed.

> > + 	if (!ipa_load_from_parm_agg_1 (descriptors, parms_ainfo, stmt,
> > + 				       rhs, &index, &offset, &by_ref))
> > + 	  continue;
> > + 	for (v = aggval; v; v = v->next)
> > + 	  if (v->index == index
> > + 	      && v->offset == offset)
> > + 	    break;
> > + 	if (!v)
> > + 	  continue;
> > + 
> > + 	gcc_checking_assert (is_gimple_ip_invariant (v->value));
> > + 	if (!useless_type_conversion_p (TREE_TYPE (rhs), TREE_TYPE (v->value)))
> > + 	  {
> > + 	    if (fold_convertible_p (TREE_TYPE (rhs), v->value))
> > + 	      val = fold_build1 (NOP_EXPR, TREE_TYPE (rhs), v->value);
> > + 	    else if (TYPE_SIZE (TREE_TYPE (rhs))
> > + 		     == TYPE_SIZE (TREE_TYPE (v->value)))
> > + 	      val = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (rhs), v->value);
> > + 	    else
> > + 	      {
> > + 		if (dump_file)
> > + 		  {
> > + 		    fprintf (dump_file, "    const ");
> > + 		    print_generic_expr (dump_file, v->value, 0);
> > + 		    fprintf (dump_file, "  can't be converted to type of ");
> > + 		    print_generic_expr (dump_file, rhs, 0);
> > + 		    fprintf (dump_file, "\n");
> > + 		  }
> > + 		continue;
> > + 	      }
> > + 	  }
> > + 	else
> > + 	  val = v->value;
> > + 
> > + 	if (dump_file && (dump_flags & TDF_DETAILS))
> > + 	  {
> > + 	    fprintf (dump_file, "Modifying stmt:\n  ");
> > + 	    print_gimple_stmt (dump_file, stmt, 0, 0);
> > + 	  }
> > + 	gimple_assign_set_rhs_from_tree (&gsi, val);
> > + 	update_stmt (stmt);
> > + 
> > + 	if (dump_file && (dump_flags & TDF_DETAILS))
> > + 	  {
> > + 	    fprintf (dump_file, "into:\n  ");
> > + 	    print_gimple_stmt (dump_file, stmt, 0, 0);
> > + 	    fprintf (dump_file, "\n");
> > + 	  }
> > + 
> > + 	something_changed = true;
> > + 	if (maybe_clean_eh_stmt (stmt)
> > + 	    && gimple_purge_dead_eh_edges (gimple_bb (stmt)))
> > + 	  cfg_changed = true;
> > +       }
> > + 
> > +   VEC_replace (ipa_agg_replacement_value_p, ipa_node_agg_replacements,
> > + 	       node->uid, NULL);
> > +   free_parms_ainfo (parms_ainfo, param_count);
> > +   VEC_free (ipa_param_descriptor_t, heap, descriptors);
> > + 
> > +   if (!something_changed)
> > +     return 0;
> > +   else if (cfg_changed)
> > +     return TODO_update_ssa | TODO_cleanup_cfg;
> > +   else
> > +     return TODO_update_ssa;
> 
> Hmm, perhaps only virtuals needs to be updated?

OK, changed.  I must say I'm not 100% sure about the state of the
function the transform phase operates on.  For example, it seems the
declarations in calls are still the old ones.  More to the point, I
cannot run TODO_verify_ssa because of a testcase failure which seemed
totally unrelated to IPA-CP actions (and got fixed later on somehow,
because all subsequent SSA verifications apparently went well).

> > + }
> > Index: src/gcc/testsuite/gcc.dg/ipa/ipcp-agg-1.c
> > ===================================================================
> > *** /dev/null
> > --- src/gcc/testsuite/gcc.dg/ipa/ipcp-agg-1.c
> > ***************
> > *** 0 ****
> > --- 1,35 ----
> > + /* { dg-do compile } */
> > + /* { dg-options "-O3 -fno-ipa-sra -fdump-ipa-cp-details"  } */
> > + /* { dg-add-options bind_pic_locally } */
> > + 
> > + struct S
> > + {
> > +   int a, b, c;
> > + };
> > + 
> > + void *blah(int, void *);
> > + 
> > + static void __attribute__ ((noinline))
> > + foo (struct S *p)
> > + {
> > +   int i, c = p->c;
> > +   int b = p->b;
> > +   void *v = (void *) p;
> > + 
> > +   for (i= 0; i< c; i++)
> > +     v = blah(b + i, v);
> > + }
> > + 
> > + void
> > + entry (void)
> > + {
> > +   struct S s;
> > +   s.a = 1;
> > +   s.b = 64;
> > +   s.c = 32;
> > +   foo (&s);
> > + }
> > + 
> > + /* { dg-final { scan-ipa-dump "Creating a specialized node of foo.*for all known contexts" "cp" } } */
> > + /* { dg-final { scan-ipa-dump-times "Aggregate replacements:" 2 "cp" } } */
> > + /* { dg-final { cleanup-ipa-dump "cp" } } */
> 
> I think it would be nice to update at least some of the testcases to verify that .optimized dump has propagated
> code in it.  (you can perhaps make some constant folding to happen).
> I think it would be likely bug that the transform pass will miss its job.

OK, I added optimize dump scans to all the ipcp-agg-?.c testcases.

> > + 
> > + /*
> > + Local variables:
> > + mode:c++
> > + End:
> > + */
> Probably remove this?

Well, OK, though I hoped it could stay so that emacs opens the file in
C++ mode, despite its suffix.

> Why the transform part lives in ipa-prop instead of ipa-cp.c?

It uses quite a lot of the jump-function building machinery and I did
not want to be exporting the stuff, especially not
ipa_load_from_parm_agg_1.  No other reason.

> 
> The patch looks OK, thanks for the hard work!

Thanks a lot, this is what I'm currently bootstrapping and will commit
if everything goes fine:

Martin


2012-11-07  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/53787
	* ipa-cp.c (ipcp_value_source): New field offset.
	(ipcp_agg_lattice): New type.
	(ipcp_param_lattices): Likewise, move virt_call from ipcp_lattice here.
	(ipcp_agg_lattice_pool): New variable.
	(ipa_get_parm_lattices): New function.
	(ipa_get_lattice): Turned into ipa_get_scalar_lat, use the above.
	Adjusted all callers.
	(print_lattice): New function.
	(print_all_lattices): Use the above, also print aggregate lattices.
	(set_agg_lats_to_bottom): New function.
	(set_agg_lats_contain_variable): Likewise.
	(set_all_contains_variable): Likewise.
	(initialize_node_lattices): Also handle aggregate lattices, set
	virt_call in ipcp_param_lattices.
	(add_value_source): Handle offsets.
	(add_value_to_lattice): Likewise.
	(add_scalar_value_to_lattice): New function.
	(propagate_vals_accross_pass_through): Use add_scalar_value_to_lattice.
	(propagate_vals_accross_ancestor): Likewise.
	(propagate_accross_jump_function): Renamed to
	propagate_scalar_accross_jump_function, use
	add_scalar_value_to_lattice.
	(set_check_aggs_by_ref): New function.
	(merge_agg_lats_step): Likewise.
	(set_chain_of_aglats_contains_variable): Likewise.
	(merge_aggregate_lattices): Likewise.
	(propagate_constants_accross_call): Also handle aggregate lattices.
	(hint_time_bonus): New function.
	(context_independent_aggregate_values): Likewise.
	(gather_context_independent_values): Also handle agggregate values.
	(agg_jmp_p_vec_for_t_vec): New function.
	(estimate_local_effects): Also handle agggregate values.
	(add_all_node_vals_to_toposort): Likewise.
	(ipcp_propagate_stage): Use struct ipcp_param_lattices.
	(get_clone_agg_value): New function.
	(cgraph_edge_brings_value_p): Also handle agggregate values.
	(create_specialized_node): Likewise.
	(find_more_values_for_callers_subset): Rename to
	find_more_scalar_values_for_callers_subset.  Modify dump.
	(copy_plats_to_inter): New function.
	(intersect_with_plats): Likewise.
	(agg_replacements_to_vector): Likewise.
	(intersect_with_agg_replacements): Likewise.
	(find_aggregate_values_for_callers_subset): Likewise.
	(known_aggs_to_agg_replacement_list): Likewise.
	(cgraph_edge_brings_all_scalars_for_node): Likewise.
	(cgraph_edge_brings_all_agg_vals_for_node): Likewise.
	(perhaps_add_new_callers): Old functionality moved to
	cgraph_edge_brings_all_scalars_for_node, call it and
	cgraph_edge_brings_all_agg_vals_for_node.
	(ipcp_val_in_agg_replacements_p): New function.
	(decide_about_value): New function.
	(decide_whether_version_node): A lot of functionality moved to
	decide_about_value.  Also handle agggregate values.
	(ipcp_driver): Also allocate ipcp_agg_lattice_pool.
	(pass_ipa_cp): Fill in new entries.
	* ipa-prop.c (ipa_node_agg_replacements): New variable.
	(free_parms_ainfo): New function.
	(ipa_analyze_node): Use free_parms_ainfo to free stuff.
	(ipa_find_agg_cst_for_param): Do not rely on offset ordering.
	(ipa_set_node_agg_value_chain): New function.
	(ipa_node_removal_hook): Also handle ipa_node_agg_replacements.
	(ipa_node_duplication_hook): Likewise.
	(ipa_free_all_structures_after_ipa_cp): Also free ipcp_agg_lattice_pool.
	(ipa_free_all_structures_after_iinln): Likewise.
	(ipa_dump_agg_replacement_values): New function.
	(write_agg_replacement_chain): Likewise.
	(read_agg_replacement_chain): Likewise.
	(ipa_prop_write_all_agg_replacement): Likewise.
	(read_replacements_section): Likewise.
	(ipa_prop_read_all_agg_replacement): Likewise.
	(adjust_agg_replacement_values): Likewise.
	(ipcp_transform_function): Likewise.
	* ipa-prop.h: Also define heap vector of ipa_agg_jf_item_t and of
	ipa_agg_jump_function_t.
	(ipa_node_params): Make lattices an array of ipcp_param_lattices.
	(ipa_agg_replacement_value): New type and its vector.
	(ipa_set_node_agg_value_chain) Declare.
	(ipa_node_agg_replacements): Likewise.
	(ipa_get_agg_replacements_for_node): New function.
	(ipcp_agg_lattice_pool): Declare.
	(ipa_dump_agg_replacement_values): Likewise.
	(ipa_prop_write_all_agg_replacement): Likewise.
	(ipa_prop_read_all_agg_replacement): Likewise.
	(ipcp_transform_function): Likewise.
	* ipa-inline-analysis.c (estimate_ipcp_clone_size_and_time): Pass around
	known aggregates and hints.
	* ipa-inline.h: include ipa-prop.h.
	(estimate_ipcp_clone_size_and_time): Adjust declaration.
	* lto-streamer.h (lto_section_type): New item
	LTO_section_ipcp_transform.
	* lto-section-in.c (lto_section_name): New element ipcp_trans.
	* params.def (PARAM_IPA_CP_LOOP_HINT_BONUS): New parameter.
	* Makefile.in (IPA_INLINE_H): New.  Use everywhee instead of
	ipa-inline.h.

	* testsuite/gcc.dg/ipa/ipa-5.c: Adjust.
	* testsuite/gcc.dg/ipa/ipcp-agg-1.c: New test.
	* testsuite/gcc.dg/ipa/ipcp-agg-2.c: Likewise.
	* testsuite/gcc.dg/ipa/ipcp-agg-3.c: Likewise.
	* testsuite/gcc.dg/ipa/ipcp-agg-4.c: Likewise.
	* testsuite/gcc.dg/ipa/ipcp-agg-5.c: Likewise.
	* testsuite/gcc.dg/ipa/ipcp-agg-6.c: Likewise.
	* testsuite/gfortran.dg/pr48636.f90: Add -fno-ipa-cp.
	* testsuite/gfortran.dg/pr48636-2.f90: New test.
	* testsuite/gfortran.dg/pr53787.f90: Likewise.

Index: src/gcc/ipa-cp.c
===================================================================
*** src.orig/gcc/ipa-cp.c
--- src/gcc/ipa-cp.c
*************** struct ipcp_value;
*** 125,130 ****
--- 125,133 ----
  
  struct ipcp_value_source
  {
+   /* Aggregate offset of the source, negative if the source is scalar value of
+      the argument itself.  */
+   HOST_WIDE_INT offset;
    /* The incoming edge that brought the value.  */
    struct cgraph_edge *cs;
    /* If the jump function that resulted into his value was a pass-through or an
*************** struct ipcp_value
*** 173,187 ****
    bool on_stack;
  };
  
! /* Allocation pools for values and their sources in ipa-cp.  */
! 
! alloc_pool ipcp_values_pool;
! alloc_pool ipcp_sources_pool;
! 
! /* Lattice describing potential values of a formal parameter of a function and
!    some of their other properties.  TOP is represented by a lattice with zero
!    values and with contains_variable and bottom flags cleared.  BOTTOM is
!    represented by a lattice with the bottom flag set.  In that case, values and
     contains_variable flag should be disregarded.  */
  
  struct ipcp_lattice
--- 176,185 ----
    bool on_stack;
  };
  
! /* Lattice describing potential values of a formal parameter of a function, or
!    a part of an aggreagate.  TOP is represented by a lattice with zero values
!    and with contains_variable and bottom flags cleared.  BOTTOM is represented
!    by a lattice with the bottom flag set.  In that case, values and
     contains_variable flag should be disregarded.  */
  
  struct ipcp_lattice
*************** struct ipcp_lattice
*** 192,206 ****
    struct ipcp_value *values;
    /* Number of known values and types in this lattice.  */
    int values_count;
!   /* The lattice contains a variable component  (in addition to values).  */
    bool contains_variable;
    /* The value of the lattice is bottom (i.e. variable and unusable for any
       propagation).  */
    bool bottom;
    /* There is a virtual call based on this parameter.  */
    bool virt_call;
  };
  
  /* Maximal count found in program.  */
  
  static gcov_type max_count;
--- 190,247 ----
    struct ipcp_value *values;
    /* Number of known values and types in this lattice.  */
    int values_count;
!   /* The lattice contains a variable component (in addition to values).  */
    bool contains_variable;
    /* The value of the lattice is bottom (i.e. variable and unusable for any
       propagation).  */
    bool bottom;
+ };
+ 
+ /* Lattice with an offset to describe a part of an aggregate.  */
+ 
+ struct ipcp_agg_lattice : public ipcp_lattice
+ {
+   /* Offset that is being described by this lattice. */
+   HOST_WIDE_INT offset;
+   /* Size so that we don't have to re-compute it every time we traverse the
+      list.  Must correspond to TYPE_SIZE of all lat values.  */
+   HOST_WIDE_INT size;
+   /* Next element of the linked list.  */
+   struct ipcp_agg_lattice *next;
+ };
+ 
+ /* Structure containing lattices for a parameter itself and for pieces of
+    aggregates that are passed in the parameter or by a reference in a parameter
+    plus some other useful flags.  */
+ 
+ struct ipcp_param_lattices
+ {
+   /* Lattice describing the value of the parameter itself.  */
+   struct ipcp_lattice itself;
+   /* Lattices describing aggregate parts.  */
+   struct ipcp_agg_lattice *aggs;
+   /* Number of aggregate lattices */
+   int aggs_count;
+   /* True if aggregate data were passed by reference (as opposed to by
+      value).  */
+   bool aggs_by_ref;
+   /* All aggregate lattices contain a variable component (in addition to
+      values).  */
+   bool aggs_contain_variable;
+   /* The value of all aggregate lattices is bottom (i.e. variable and unusable
+      for any propagation).  */
+   bool aggs_bottom;
+ 
    /* There is a virtual call based on this parameter.  */
    bool virt_call;
  };
  
+ /* Allocation pools for values and their sources in ipa-cp.  */
+ 
+ alloc_pool ipcp_values_pool;
+ alloc_pool ipcp_sources_pool;
+ alloc_pool ipcp_agg_lattice_pool;
+ 
  /* Maximal count found in program.  */
  
  static gcov_type max_count;
*************** static long overall_size, max_new_size;
*** 213,222 ****
  
  static struct ipcp_value *values_topo;
  
! /* Return the lattice corresponding to the Ith formal parameter of the function
!    described by INFO.  */
! static inline struct ipcp_lattice *
! ipa_get_lattice (struct ipa_node_params *info, int i)
  {
    gcc_assert (i >= 0 && i < ipa_get_param_count (info));
    gcc_checking_assert (!info->ipcp_orig_node);
--- 254,263 ----
  
  static struct ipcp_value *values_topo;
  
! /* Return the param lattices structure corresponding to the Ith formal
!    parameter of the function described by INFO.  */
! static inline struct ipcp_param_lattices *
! ipa_get_parm_lattices (struct ipa_node_params *info, int i)
  {
    gcc_assert (i >= 0 && i < ipa_get_param_count (info));
    gcc_checking_assert (!info->ipcp_orig_node);
*************** ipa_get_lattice (struct ipa_node_params
*** 224,229 ****
--- 265,279 ----
    return &(info->lattices[i]);
  }
  
+ /* Return the lattice corresponding to the scalar value of the Ith formal
+    parameter of the function described by INFO.  */
+ static inline struct ipcp_lattice *
+ ipa_get_scalar_lat (struct ipa_node_params *info, int i)
+ {
+   struct ipcp_param_lattices *plats = ipa_get_parm_lattices (info, i);
+   return &plats->itself;
+ }
+ 
  /* Return whether LAT is a lattice with a single constant and without an
     undefined value.  */
  
*************** print_ipcp_constant_value (FILE * f, tre
*** 274,279 ****
--- 324,389 ----
      print_generic_expr (f, v, 0);
  }
  
+ /* Print a lattice LAT to F.  */
+ 
+ static void
+ print_lattice (FILE * f, struct ipcp_lattice *lat,
+ 	       bool dump_sources, bool dump_benefits)
+ {
+   struct ipcp_value *val;
+   bool prev = false;
+ 
+   if (lat->bottom)
+     {
+       fprintf (f, "BOTTOM\n");
+       return;
+     }
+ 
+   if (!lat->values_count && !lat->contains_variable)
+     {
+       fprintf (f, "TOP\n");
+       return;
+     }
+ 
+   if (lat->contains_variable)
+     {
+       fprintf (f, "VARIABLE");
+       prev = true;
+       if (dump_benefits)
+ 	fprintf (f, "\n");
+     }
+ 
+   for (val = lat->values; val; val = val->next)
+     {
+       if (dump_benefits && prev)
+ 	fprintf (f, "               ");
+       else if (!dump_benefits && prev)
+ 	fprintf (f, ", ");
+       else
+ 	prev = true;
+ 
+       print_ipcp_constant_value (f, val->value);
+ 
+       if (dump_sources)
+ 	{
+ 	  struct ipcp_value_source *s;
+ 
+ 	  fprintf (f, " [from:");
+ 	  for (s = val->sources; s; s = s->next)
+ 	    fprintf (f, " %i(%i)", s->cs->caller->uid,s->cs->frequency);
+ 	  fprintf (f, "]");
+ 	}
+ 
+       if (dump_benefits)
+ 	fprintf (f, " [loc_time: %i, loc_size: %i, "
+ 		 "prop_time: %i, prop_size: %i]\n",
+ 		 val->local_time_benefit, val->local_size_cost,
+ 		 val->prop_time_benefit, val->prop_size_cost);
+     }
+   if (!dump_benefits)
+     fprintf (f, "\n");
+ }
+ 
  /* Print all ipcp_lattices of all functions to F.  */
  
  static void
*************** print_all_lattices (FILE * f, bool dump_
*** 292,351 ****
        count = ipa_get_param_count (info);
        for (i = 0; i < count; i++)
  	{
! 	  struct ipcp_lattice *lat = ipa_get_lattice (info, i);
! 	  struct ipcp_value *val;
! 	  bool prev = false;
! 
  	  fprintf (f, "    param [%d]: ", i);
! 	  if (lat->bottom)
! 	    {
! 	      fprintf (f, "BOTTOM\n");
! 	      continue;
! 	    }
  
! 	  if (!lat->values_count && !lat->contains_variable)
! 	    {
! 	      fprintf (f, "TOP\n");
! 	      continue;
! 	    }
  
! 	  if (lat->contains_variable)
  	    {
! 	      fprintf (f, "VARIABLE");
! 	      prev = true;
! 	      if (dump_benefits)
! 		fprintf (f, "\n");
  	    }
! 
! 	  for (val = lat->values; val; val = val->next)
! 	    {
! 	      if (dump_benefits && prev)
! 		fprintf (f, "               ");
! 	      else if (!dump_benefits && prev)
! 		fprintf (f, ", ");
! 	      else
! 		prev = true;
! 
! 	      print_ipcp_constant_value (f, val->value);
! 
! 	      if (dump_sources)
! 		{
! 		  struct ipcp_value_source *s;
! 
! 		  fprintf (f, " [from:");
! 		  for (s = val->sources; s; s = s->next)
! 		    fprintf (f, " %i(%i)", s->cs->caller->uid,s->cs->frequency);
! 		  fprintf (f, "]");
! 		}
! 
! 	      if (dump_benefits)
! 		fprintf (f, " [loc_time: %i, loc_size: %i, "
! 			 "prop_time: %i, prop_size: %i]\n",
! 			 val->local_time_benefit, val->local_size_cost,
! 			 val->prop_time_benefit, val->prop_size_cost);
  	    }
- 	  if (!dump_benefits)
- 	    fprintf (f, "\n");
  	}
      }
  }
--- 402,428 ----
        count = ipa_get_param_count (info);
        for (i = 0; i < count; i++)
  	{
! 	  struct ipcp_agg_lattice *aglat;
! 	  struct ipcp_param_lattices *plats = ipa_get_parm_lattices (info, i);
  	  fprintf (f, "    param [%d]: ", i);
! 	  print_lattice (f, &plats->itself, dump_sources, dump_benefits);
  
! 	  if (plats->virt_call)
! 	    fprintf (f, "        virt_call flag set\n");
  
! 	  if (plats->aggs_bottom)
  	    {
! 	      fprintf (f, "        AGGS BOTTOM\n");
! 	      continue;
  	    }
! 	  if (plats->aggs_contain_variable)
! 	    fprintf (f, "        AGGS VARIABLE\n");
! 	  for (aglat = plats->aggs; aglat; aglat = aglat->next)
! 	    {
! 	      fprintf (f, "        %soffset " HOST_WIDE_INT_PRINT_DEC ": ",
! 		       plats->aggs_by_ref ? "ref " : "", aglat->offset);
! 	      print_lattice (f, aglat, dump_sources, dump_benefits);
  	    }
  	}
      }
  }
*************** set_lattice_contains_variable (struct ip
*** 578,583 ****
--- 655,694 ----
    return ret;
  }
  
+ /* Set all aggegate lattices in PLATS to bottom and return true if they were
+    not previously set as such.  */
+ 
+ static inline bool
+ set_agg_lats_to_bottom (struct ipcp_param_lattices *plats)
+ {
+   bool ret = !plats->aggs_bottom;
+   plats->aggs_bottom = true;
+   return ret;
+ }
+ 
+ /* Mark all aggegate lattices in PLATS as containing an unknown value and
+    return true if they were not previously marked as such.  */
+ 
+ static inline bool
+ set_agg_lats_contain_variable (struct ipcp_param_lattices *plats)
+ {
+   bool ret = !plats->aggs_contain_variable;
+   plats->aggs_contain_variable = true;
+   return ret;
+ }
+ 
+ /* Mark bot aggregate and scalar lattices as containing an unknown variable,
+    return true is any of them has not been marked as such so far.  */
+ 
+ static inline bool
+ set_all_contains_variable (struct ipcp_param_lattices *plats)
+ {
+   bool ret = !plats->itself.contains_variable || !plats->aggs_contain_variable;
+   plats->itself.contains_variable = true;
+   plats->aggs_contain_variable = true;
+   return ret;
+ }
+ 
  /* Initialize ipcp_lattices.  */
  
  static void
*************** initialize_node_lattices (struct cgraph_
*** 605,615 ****
      {
        for (i = 0; i < ipa_get_param_count (info) ; i++)
  	{
! 	  struct ipcp_lattice *lat = ipa_get_lattice (info, i);
  	  if (disable)
! 	    set_lattice_to_bottom (lat);
  	  else
! 	    set_lattice_contains_variable (lat);
  	}
        if (dump_file && (dump_flags & TDF_DETAILS)
  	  && node->alias && node->thunk.thunk_p)
--- 716,729 ----
      {
        for (i = 0; i < ipa_get_param_count (info) ; i++)
  	{
! 	  struct ipcp_param_lattices *plats = ipa_get_parm_lattices (info, i);
  	  if (disable)
! 	    {
! 	      set_lattice_to_bottom (&plats->itself);
! 	      set_agg_lats_to_bottom (plats);
! 	    }
  	  else
! 	    set_all_contains_variable (plats);
  	}
        if (dump_file && (dump_flags & TDF_DETAILS)
  	  && node->alias && node->thunk.thunk_p)
*************** initialize_node_lattices (struct cgraph_
*** 622,628 ****
      if (ie->indirect_info->polymorphic)
        {
  	gcc_checking_assert (ie->indirect_info->param_index >= 0);
! 	ipa_get_lattice (info, ie->indirect_info->param_index)->virt_call = 1;
        }
  }
  
--- 736,743 ----
      if (ie->indirect_info->polymorphic)
        {
  	gcc_checking_assert (ie->indirect_info->param_index >= 0);
! 	ipa_get_parm_lattices (info,
! 			       ie->indirect_info->param_index)->virt_call = 1;
        }
  }
  
*************** ipa_value_from_jfunc (struct ipa_node_pa
*** 725,731 ****
  	      gcc_checking_assert (!flag_ipa_cp);
  	      return NULL_TREE;
  	    }
! 	  lat = ipa_get_lattice (info, idx);
  	  if (!ipa_lat_is_single_const (lat))
  	    return NULL_TREE;
  	  input = lat->values->value;
--- 840,846 ----
  	      gcc_checking_assert (!flag_ipa_cp);
  	      return NULL_TREE;
  	    }
! 	  lat = ipa_get_scalar_lat (info, idx);
  	  if (!ipa_lat_is_single_const (lat))
  	    return NULL_TREE;
  	  input = lat->values->value;
*************** ipcp_verify_propagated_values (void)
*** 760,766 ****
  
        for (i = 0; i < count; i++)
  	{
! 	  struct ipcp_lattice *lat = ipa_get_lattice (info, i);
  
  	  if (!lat->bottom
  	      && !lat->contains_variable
--- 875,881 ----
  
        for (i = 0; i < count; i++)
  	{
! 	  struct ipcp_lattice *lat = ipa_get_scalar_lat (info, i);
  
  	  if (!lat->bottom
  	      && !lat->contains_variable
*************** values_equal_for_ipcp_p (tree x, tree y)
*** 804,818 ****
  
  /* Add a new value source to VAL, marking that a value comes from edge CS and
     (if the underlying jump function is a pass-through or an ancestor one) from
!    a caller value SRC_VAL of a caller parameter described by SRC_INDEX.  */
  
  static void
  add_value_source (struct ipcp_value *val, struct cgraph_edge *cs,
! 		  struct ipcp_value *src_val, int src_idx)
  {
    struct ipcp_value_source *src;
  
    src = (struct ipcp_value_source *) pool_alloc (ipcp_sources_pool);
    src->cs = cs;
    src->val = src_val;
    src->index = src_idx;
--- 919,936 ----
  
  /* Add a new value source to VAL, marking that a value comes from edge CS and
     (if the underlying jump function is a pass-through or an ancestor one) from
!    a caller value SRC_VAL of a caller parameter described by SRC_INDEX.  OFFSET
!    is negative if the source was the scalar value of the parameter itself or
!    the offset within an aggregate.  */
  
  static void
  add_value_source (struct ipcp_value *val, struct cgraph_edge *cs,
! 		  struct ipcp_value *src_val, int src_idx, HOST_WIDE_INT offset)
  {
    struct ipcp_value_source *src;
  
    src = (struct ipcp_value_source *) pool_alloc (ipcp_sources_pool);
+   src->offset = offset;
    src->cs = cs;
    src->val = src_val;
    src->index = src_idx;
*************** add_value_source (struct ipcp_value *val
*** 821,842 ****
    val->sources = src;
  }
  
- 
  /* Try to add NEWVAL to LAT, potentially creating a new struct ipcp_value for
!    it.  CS, SRC_VAL and SRC_INDEX are meant for add_value_source and have the
!    same meaning.  */
  
  static bool
  add_value_to_lattice (struct ipcp_lattice *lat, tree newval,
  		      struct cgraph_edge *cs, struct ipcp_value *src_val,
! 		      int src_idx)
  {
    struct ipcp_value *val;
  
    if (lat->bottom)
      return false;
  
- 
    for (val = lat->values; val; val = val->next)
      if (values_equal_for_ipcp_p (val->value, newval))
        {
--- 939,958 ----
    val->sources = src;
  }
  
  /* Try to add NEWVAL to LAT, potentially creating a new struct ipcp_value for
!    it.  CS, SRC_VAL SRC_INDEX and OFFSET are meant for add_value_source and
!    have the same meaning.  */
  
  static bool
  add_value_to_lattice (struct ipcp_lattice *lat, tree newval,
  		      struct cgraph_edge *cs, struct ipcp_value *src_val,
! 		      int src_idx, HOST_WIDE_INT offset)
  {
    struct ipcp_value *val;
  
    if (lat->bottom)
      return false;
  
    for (val = lat->values; val; val = val->next)
      if (values_equal_for_ipcp_p (val->value, newval))
        {
*************** add_value_to_lattice (struct ipcp_lattic
*** 850,856 ****
  	      return false;
  	  }
  
! 	add_value_source (val, cs, src_val, src_idx);
  	return false;
        }
  
--- 966,972 ----
  	      return false;
  	  }
  
! 	add_value_source (val, cs, src_val, src_idx, offset);
  	return false;
        }
  
*************** add_value_to_lattice (struct ipcp_lattic
*** 876,888 ****
    val = (struct ipcp_value *) pool_alloc (ipcp_values_pool);
    memset (val, 0, sizeof (*val));
  
!   add_value_source (val, cs, src_val, src_idx);
    val->value = newval;
    val->next = lat->values;
    lat->values = val;
    return true;
  }
  
  /* Propagate values through a pass-through jump function JFUNC associated with
     edge CS, taking values from SRC_LAT and putting them into DEST_LAT.  SRC_IDX
     is the index of the source parameter.  */
--- 992,1016 ----
    val = (struct ipcp_value *) pool_alloc (ipcp_values_pool);
    memset (val, 0, sizeof (*val));
  
!   add_value_source (val, cs, src_val, src_idx, offset);
    val->value = newval;
    val->next = lat->values;
    lat->values = val;
    return true;
  }
  
+ /* Like above but passes a special value of offset to distinguish that the
+    origin is the scalar value of the parameter rather than a part of an
+    aggregate.  */
+ 
+ static inline bool
+ add_scalar_value_to_lattice (struct ipcp_lattice *lat, tree newval,
+ 			     struct cgraph_edge *cs,
+ 			     struct ipcp_value *src_val, int src_idx)
+ {
+   return add_value_to_lattice (lat, newval, cs, src_val, src_idx, -1);
+ }
+ 
  /* Propagate values through a pass-through jump function JFUNC associated with
     edge CS, taking values from SRC_LAT and putting them into DEST_LAT.  SRC_IDX
     is the index of the source parameter.  */
*************** propagate_vals_accross_pass_through (str
*** 899,906 ****
  
    if (ipa_get_jf_pass_through_operation (jfunc) == NOP_EXPR)
      for (src_val = src_lat->values; src_val; src_val = src_val->next)
!       ret |= add_value_to_lattice (dest_lat, src_val->value, cs,
! 				   src_val, src_idx);
    /* Do not create new values when propagating within an SCC because if there
       are arithmetic functions with circular dependencies, there is infinite
       number of them and we would just make lattices bottom.  */
--- 1027,1034 ----
  
    if (ipa_get_jf_pass_through_operation (jfunc) == NOP_EXPR)
      for (src_val = src_lat->values; src_val; src_val = src_val->next)
!       ret |= add_scalar_value_to_lattice (dest_lat, src_val->value, cs,
! 					  src_val, src_idx);
    /* Do not create new values when propagating within an SCC because if there
       are arithmetic functions with circular dependencies, there is infinite
       number of them and we would just make lattices bottom.  */
*************** propagate_vals_accross_pass_through (str
*** 919,925 ****
  	cstval = ipa_get_jf_pass_through_result (jfunc, cstval);
  
  	if (cstval)
! 	  ret |= add_value_to_lattice (dest_lat, cstval, cs, src_val, src_idx);
  	else
  	  ret |= set_lattice_contains_variable (dest_lat);
        }
--- 1047,1054 ----
  	cstval = ipa_get_jf_pass_through_result (jfunc, cstval);
  
  	if (cstval)
! 	  ret |= add_scalar_value_to_lattice (dest_lat, cstval, cs, src_val,
! 					      src_idx);
  	else
  	  ret |= set_lattice_contains_variable (dest_lat);
        }
*************** propagate_vals_accross_ancestor (struct
*** 949,955 ****
        tree t = ipa_get_jf_ancestor_result (jfunc, src_val->value);
  
        if (t)
! 	ret |= add_value_to_lattice (dest_lat, t, cs, src_val, src_idx);
        else
  	ret |= set_lattice_contains_variable (dest_lat);
      }
--- 1078,1084 ----
        tree t = ipa_get_jf_ancestor_result (jfunc, src_val->value);
  
        if (t)
! 	ret |= add_scalar_value_to_lattice (dest_lat, t, cs, src_val, src_idx);
        else
  	ret |= set_lattice_contains_variable (dest_lat);
      }
*************** propagate_vals_accross_ancestor (struct
*** 957,969 ****
    return ret;
  }
  
! /* Propagate values across jump function JFUNC that is associated with edge CS
!    and put the values into DEST_LAT.  */
  
  static bool
! propagate_accross_jump_function (struct cgraph_edge *cs,
! 				 struct ipa_jump_func *jfunc,
! 				 struct ipcp_lattice *dest_lat)
  {
    if (dest_lat->bottom)
      return false;
--- 1086,1098 ----
    return ret;
  }
  
! /* Propagate scalar values across jump function JFUNC that is associated with
!    edge CS and put the values into DEST_LAT.  */
  
  static bool
! propagate_scalar_accross_jump_function (struct cgraph_edge *cs,
! 					struct ipa_jump_func *jfunc,
! 					struct ipcp_lattice *dest_lat)
  {
    if (dest_lat->bottom)
      return false;
*************** propagate_accross_jump_function (struct
*** 981,987 ****
  	}
        else
  	val = ipa_get_jf_constant (jfunc);
!       return add_value_to_lattice (dest_lat, val, cs, NULL, 0);
      }
    else if (jfunc->type == IPA_JF_PASS_THROUGH
  	   || jfunc->type == IPA_JF_ANCESTOR)
--- 1110,1116 ----
  	}
        else
  	val = ipa_get_jf_constant (jfunc);
!       return add_scalar_value_to_lattice (dest_lat, val, cs, NULL, 0);
      }
    else if (jfunc->type == IPA_JF_PASS_THROUGH
  	   || jfunc->type == IPA_JF_ANCESTOR)
*************** propagate_accross_jump_function (struct
*** 996,1002 ****
        else
  	src_idx = ipa_get_jf_ancestor_formal_id (jfunc);
  
!       src_lat = ipa_get_lattice (caller_info, src_idx);
        if (src_lat->bottom)
  	return set_lattice_contains_variable (dest_lat);
  
--- 1125,1131 ----
        else
  	src_idx = ipa_get_jf_ancestor_formal_id (jfunc);
  
!       src_lat = ipa_get_scalar_lat (caller_info, src_idx);
        if (src_lat->bottom)
  	return set_lattice_contains_variable (dest_lat);
  
*************** propagate_accross_jump_function (struct
*** 1024,1029 ****
--- 1153,1409 ----
    return set_lattice_contains_variable (dest_lat);
  }
  
+ /* If DEST_PLATS already has aggregate items, check that aggs_by_ref matches
+    NEW_AGGS_BY_REF and if not, mark all aggs as bottoms and return true (in all
+    other cases, return false).  If there are no aggregate items, set
+    aggs_by_ref to NEW_AGGS_BY_REF.  */
+ 
+ static bool
+ set_check_aggs_by_ref (struct ipcp_param_lattices *dest_plats,
+ 		       bool new_aggs_by_ref)
+ {
+   if (dest_plats->aggs)
+     {
+       if (dest_plats->aggs_by_ref != new_aggs_by_ref)
+ 	{
+ 	  set_agg_lats_to_bottom (dest_plats);
+ 	  return true;
+ 	}
+     }
+   else
+     dest_plats->aggs_by_ref = new_aggs_by_ref;
+   return false;
+ }
+ 
+ /* Walk aggregate lattices in DEST_PLATS from ***AGLAT on, until ***aglat is an
+    already existing lattice for the given OFFSET and SIZE, marking all skipped
+    lattices as containing variable and checking for overlaps.  If there is no
+    already existing lattice for the OFFSET and VAL_SIZE, create one, initialize
+    it with offset, size and contains_variable to PRE_EXISTING, and return true,
+    unless there are too many already.  If there are two many, return false.  If
+    there are overlaps turn whole DEST_PLATS to bottom and return false.  If any
+    skipped lattices were newly marked as containing variable, set *CHANGE to
+    true.  */
+ 
+ static bool
+ merge_agg_lats_step (struct ipcp_param_lattices *dest_plats,
+ 		     HOST_WIDE_INT offset, HOST_WIDE_INT val_size,
+ 		     struct ipcp_agg_lattice ***aglat,
+ 		     bool pre_existing, bool *change)
+ {
+   gcc_checking_assert (offset >= 0);
+ 
+   while (**aglat && (**aglat)->offset < offset)
+     {
+       if ((**aglat)->offset + (**aglat)->size > offset)
+ 	{
+ 	  set_agg_lats_to_bottom (dest_plats);
+ 	  return false;
+ 	}
+       *change |= set_lattice_contains_variable (**aglat);
+       *aglat = &(**aglat)->next;
+     }
+ 
+   if (**aglat && (**aglat)->offset == offset)
+     {
+       if ((**aglat)->size != val_size
+           || ((**aglat)->next
+               && (**aglat)->next->offset < offset + val_size))
+ 	{
+ 	  set_agg_lats_to_bottom (dest_plats);
+ 	  return false;
+ 	}
+       gcc_checking_assert (!(**aglat)->next
+ 			   || (**aglat)->next->offset >= offset + val_size);
+       return true;
+     }
+   else
+     {
+       struct ipcp_agg_lattice *new_al;
+ 
+       if (**aglat && (**aglat)->offset < offset + val_size)
+ 	{
+ 	  set_agg_lats_to_bottom (dest_plats);
+ 	  return false;
+ 	}
+       if (dest_plats->aggs_count == PARAM_VALUE (PARAM_IPA_MAX_AGG_ITEMS))
+ 	return false;
+       dest_plats->aggs_count++;
+       new_al = (struct ipcp_agg_lattice *) pool_alloc (ipcp_agg_lattice_pool);
+       memset (new_al, 0, sizeof (*new_al));
+ 
+       new_al->offset = offset;
+       new_al->size = val_size;
+       new_al->contains_variable = pre_existing;
+ 
+       new_al->next = **aglat;
+       **aglat = new_al;
+       return true;
+     }
+ }
+ 
+ /* Set all AGLAT and all other aggregate lattices reachable by next pointers as
+    containing an unknown value.  */
+ 
+ static bool
+ set_chain_of_aglats_contains_variable (struct ipcp_agg_lattice *aglat)
+ {
+   bool ret = false;
+   while (aglat)
+     {
+       ret |= set_lattice_contains_variable (aglat);
+       aglat = aglat->next;
+     }
+   return ret;
+ }
+ 
+ /* Merge existing aggregate lattices in SRC_PLATS to DEST_PLATS, subtracting
+    DELTA_OFFSET.  CS is the call graph edge and SRC_IDX the index of the source
+    parameter used for lattice value sources.  Return true if DEST_PLATS changed
+    in any way.  */
+ 
+ static bool
+ merge_aggregate_lattices (struct cgraph_edge *cs,
+ 			  struct ipcp_param_lattices *dest_plats,
+ 			  struct ipcp_param_lattices *src_plats,
+ 			  int src_idx, HOST_WIDE_INT offset_delta)
+ {
+   bool pre_existing = dest_plats->aggs != NULL;
+   struct ipcp_agg_lattice **dst_aglat;
+   bool ret = false;
+ 
+   if (set_check_aggs_by_ref (dest_plats, src_plats->aggs_by_ref))
+     return true;
+   if (src_plats->aggs_bottom)
+     return set_agg_lats_contain_variable (dest_plats);
+   dst_aglat = &dest_plats->aggs;
+ 
+   for (struct ipcp_agg_lattice *src_aglat = src_plats->aggs;
+        src_aglat;
+        src_aglat = src_aglat->next)
+     {
+       HOST_WIDE_INT new_offset = src_aglat->offset - offset_delta;
+ 
+       if (new_offset < 0)
+ 	continue;
+       if (merge_agg_lats_step (dest_plats, new_offset, src_aglat->size,
+ 			       &dst_aglat, pre_existing, &ret))
+ 	{
+ 	  struct ipcp_agg_lattice *new_al = *dst_aglat;
+ 
+ 	  dst_aglat = &(*dst_aglat)->next;
+ 	  if (src_aglat->bottom)
+ 	    {
+ 	      ret |= set_lattice_contains_variable (new_al);
+ 	      continue;
+ 	    }
+ 	  if (src_aglat->contains_variable)
+ 	    ret |= set_lattice_contains_variable (new_al);
+ 	  for (struct ipcp_value *val = src_aglat->values;
+ 	       val;
+ 	       val = val->next)
+ 	    ret |= add_value_to_lattice (new_al, val->value, cs, val, src_idx,
+ 					 src_aglat->offset);
+ 	}
+       else if (dest_plats->aggs_bottom)
+ 	return true;
+     }
+   ret |= set_chain_of_aglats_contains_variable (*dst_aglat);
+   return ret;
+ }
+ 
+ /* Propagate scalar values across jump function JFUNC that is associated with
+    edge CS and put the values into DEST_LAT.  */
+ 
+ static bool
+ propagate_aggs_accross_jump_function (struct cgraph_edge *cs,
+ 				      struct ipa_jump_func *jfunc,
+ 				      struct ipcp_param_lattices *dest_plats)
+ {
+   bool ret = false;
+ 
+   if (dest_plats->aggs_bottom)
+     return false;
+ 
+   if (jfunc->type == IPA_JF_PASS_THROUGH
+       && ipa_get_jf_pass_through_operation (jfunc) == NOP_EXPR)
+     {
+       struct ipa_node_params *caller_info = IPA_NODE_REF (cs->caller);
+       int src_idx = ipa_get_jf_pass_through_formal_id (jfunc);
+       struct ipcp_param_lattices *src_plats;
+ 
+       src_plats = ipa_get_parm_lattices (caller_info, src_idx);
+       if (src_plats->aggs
+ 	  && (!src_plats->aggs_by_ref
+ 	      || ipa_get_jf_pass_through_agg_preserved (jfunc)))
+ 	{
+ 	  /* Currently we do not produce clobber aggregate jump
+ 	     functions, replace with merging when we do.  */
+ 	  gcc_assert (!jfunc->agg.items);
+ 	  ret |= merge_aggregate_lattices (cs, dest_plats, src_plats,
+ 					   src_idx, 0);
+ 	}
+       else
+ 	ret |= set_agg_lats_contain_variable (dest_plats);
+     }
+   else if (jfunc->type == IPA_JF_ANCESTOR
+ 	   && ipa_get_jf_ancestor_agg_preserved (jfunc))
+     {
+       struct ipa_node_params *caller_info = IPA_NODE_REF (cs->caller);
+       int src_idx = ipa_get_jf_ancestor_formal_id (jfunc);
+       struct ipcp_param_lattices *src_plats;
+ 
+       src_plats = ipa_get_parm_lattices (caller_info, src_idx);
+       if (src_plats->aggs && src_plats->aggs_by_ref)
+ 	{
+ 	  /* Currently we do not produce clobber aggregate jump
+ 	     functions, replace with merging when we do.  */
+ 	  gcc_assert (!jfunc->agg.items);
+ 	  ret |= merge_aggregate_lattices (cs, dest_plats, src_plats, src_idx,
+ 					   ipa_get_jf_ancestor_offset (jfunc));
+ 	}
+       else if (!src_plats->aggs_by_ref)
+ 	ret |= set_agg_lats_to_bottom (dest_plats);
+       else
+ 	ret |= set_agg_lats_contain_variable (dest_plats);
+     }
+   else if (jfunc->agg.items)
+     {
+       bool pre_existing = dest_plats->aggs != NULL;
+       struct ipcp_agg_lattice **aglat = &dest_plats->aggs;
+       struct ipa_agg_jf_item *item;
+       int i;
+ 
+       if (set_check_aggs_by_ref (dest_plats, jfunc->agg.by_ref))
+ 	return true;
+ 
+       FOR_EACH_VEC_ELT (ipa_agg_jf_item_t, jfunc->agg.items, i, item)
+ 	{
+ 	  HOST_WIDE_INT val_size;
+ 
+ 	  if (item->offset < 0)
+ 	    continue;
+ 	  gcc_checking_assert (is_gimple_ip_invariant (item->value));
+ 	  val_size = tree_low_cst (TYPE_SIZE (TREE_TYPE (item->value)), 1);
+ 
+ 	  if (merge_agg_lats_step (dest_plats, item->offset, val_size,
+ 				   &aglat, pre_existing, &ret))
+ 	    {
+ 	      ret |= add_value_to_lattice (*aglat, item->value, cs, NULL, 0, 0);
+ 	      aglat = &(*aglat)->next;
+ 	    }
+ 	  else if (dest_plats->aggs_bottom)
+ 	    return true;
+ 	}
+ 
+       ret |= set_chain_of_aglats_contains_variable (*aglat);
+     }
+   else
+     ret |= set_agg_lats_contain_variable (dest_plats);
+ 
+   return ret;
+ }
+ 
  /* Propagate constants from the caller to the callee of CS.  INFO describes the
     caller.  */
  
*************** propagate_constants_accross_call (struct
*** 1055,1061 ****
      alias_or_thunk = cgraph_alias_aliased_node (alias_or_thunk);
    if (alias_or_thunk->thunk.thunk_p)
      {
!       ret |= set_lattice_contains_variable (ipa_get_lattice (callee_info, 0));
        i = 1;
      }
    else
--- 1435,1442 ----
      alias_or_thunk = cgraph_alias_aliased_node (alias_or_thunk);
    if (alias_or_thunk->thunk.thunk_p)
      {
!       ret |= set_all_contains_variable (ipa_get_parm_lattices (callee_info,
! 							       0));
        i = 1;
      }
    else
*************** propagate_constants_accross_call (struct
*** 1064,1078 ****
    for (; (i < args_count) && (i < parms_count); i++)
      {
        struct ipa_jump_func *jump_func = ipa_get_ith_jump_func (args, i);
!       struct ipcp_lattice *dest_lat = ipa_get_lattice (callee_info, i);
  
        if (availability == AVAIL_OVERWRITABLE)
! 	ret |= set_lattice_contains_variable (dest_lat);
        else
! 	ret |= propagate_accross_jump_function (cs, jump_func, dest_lat);
      }
    for (; i < parms_count; i++)
!     ret |= set_lattice_contains_variable (ipa_get_lattice (callee_info, i));
  
    return ret;
  }
--- 1445,1465 ----
    for (; (i < args_count) && (i < parms_count); i++)
      {
        struct ipa_jump_func *jump_func = ipa_get_ith_jump_func (args, i);
!       struct ipcp_param_lattices *dest_plats;
  
+       dest_plats = ipa_get_parm_lattices (callee_info, i);
        if (availability == AVAIL_OVERWRITABLE)
! 	ret |= set_all_contains_variable (dest_plats);
        else
! 	{
! 	  ret |= propagate_scalar_accross_jump_function (cs, jump_func,
! 							 &dest_plats->itself);
! 	  ret |= propagate_aggs_accross_jump_function (cs, jump_func,
! 						       dest_plats);
! 	}
      }
    for (; i < parms_count; i++)
!     ret |= set_all_contains_variable (ipa_get_parm_lattices (callee_info, i));
  
    return ret;
  }
*************** devirtualization_time_bonus (struct cgra
*** 1204,1209 ****
--- 1591,1606 ----
    return res;
  }
  
+ /* Return time bonus incurred because of HINTS.  */
+ 
+ static int
+ hint_time_bonus (inline_hints hints)
+ {
+   if (hints & (INLINE_HINT_loop_iterations | INLINE_HINT_loop_stride))
+     return PARAM_VALUE (PARAM_IPA_CP_LOOP_HINT_BONUS);
+   return 0;
+ }
+ 
  /* Return true if cloning NODE is a good idea, given the estimated TIME_BENEFIT
     and SIZE_COST and with the sum of frequencies of incoming edges to the
     potential new clone in FREQUENCIES.  */
*************** good_cloning_opportunity_p (struct cgrap
*** 1251,1267 ****
      }
  }
  
  
! /* Allocate KNOWN_CSTS and KNOWN_BINFOS and populate them with values of
!    parameters that are known independent of the context.  INFO describes the
!    function.  If REMOVABLE_PARAMS_COST is non-NULL, the movement cost of all
!    removable parameters will be stored in it.  */
  
  static bool
  gather_context_independent_values (struct ipa_node_params *info,
! 				   VEC (tree, heap) **known_csts,
! 				   VEC (tree, heap) **known_binfos,
! 				   int *removable_params_cost)
  {
    int i, count = ipa_get_param_count (info);
    bool ret = false;
--- 1648,1690 ----
      }
  }
  
+ /* Return all context independent values from aggregate lattices in PLATS in a
+    vector.  Return NULL if there are none.  */
  
! static VEC (ipa_agg_jf_item_t, gc) *
! context_independent_aggregate_values (struct ipcp_param_lattices *plats)
! {
!   VEC (ipa_agg_jf_item_t, gc) *res = NULL;
! 
!   if (plats->aggs_bottom
!       || plats->aggs_contain_variable
!       || plats->aggs_count == 0)
!     return NULL;
! 
!   for (struct ipcp_agg_lattice *aglat = plats->aggs;
!        aglat;
!        aglat = aglat->next)
!     if (ipa_lat_is_single_const (aglat))
!       {
! 	struct ipa_agg_jf_item item;
! 	item.offset = aglat->offset;
! 	item.value = aglat->values->value;
! 	VEC_safe_push (ipa_agg_jf_item_t, gc, res, item);
!       }
!   return res;
! }
! 
! /* Allocate KNOWN_CSTS, KNOWN_BINFOS and, if non-NULL, KNOWN_AGGS and populate
!    them with values of parameters that are known independent of the context.
!    INFO describes the function.  If REMOVABLE_PARAMS_COST is non-NULL, the
!    movement cost of all removable parameters will be stored in it.  */
  
  static bool
  gather_context_independent_values (struct ipa_node_params *info,
! 			       VEC (tree, heap) **known_csts,
! 			       VEC (tree, heap) **known_binfos,
! 			       VEC (ipa_agg_jump_function_t, heap) **known_aggs,
! 			       int *removable_params_cost)
  {
    int i, count = ipa_get_param_count (info);
    bool ret = false;
*************** gather_context_independent_values (struc
*** 1270,1282 ****
    *known_binfos = NULL;
    VEC_safe_grow_cleared (tree, heap, *known_csts, count);
    VEC_safe_grow_cleared (tree, heap, *known_binfos, count);
  
    if (removable_params_cost)
      *removable_params_cost = 0;
  
    for (i = 0; i < count ; i++)
      {
!       struct ipcp_lattice *lat = ipa_get_lattice (info, i);
  
        if (ipa_lat_is_single_const (lat))
  	{
--- 1693,1711 ----
    *known_binfos = NULL;
    VEC_safe_grow_cleared (tree, heap, *known_csts, count);
    VEC_safe_grow_cleared (tree, heap, *known_binfos, count);
+   if (known_aggs)
+     {
+       *known_aggs = NULL;
+       VEC_safe_grow_cleared (ipa_agg_jump_function_t, heap, *known_aggs, count);
+     }
  
    if (removable_params_cost)
      *removable_params_cost = 0;
  
    for (i = 0; i < count ; i++)
      {
!       struct ipcp_param_lattices *plats = ipa_get_parm_lattices (info, i);
!       struct ipcp_lattice *lat = &plats->itself;
  
        if (ipa_lat_is_single_const (lat))
  	{
*************** gather_context_independent_values (struc
*** 1289,1295 ****
  		  += estimate_move_cost (TREE_TYPE (val->value));
  	      ret = true;
  	    }
! 	  else if (lat->virt_call)
  	    {
  	      VEC_replace (tree, *known_binfos, i, val->value);
  	      ret = true;
--- 1718,1724 ----
  		  += estimate_move_cost (TREE_TYPE (val->value));
  	      ret = true;
  	    }
! 	  else if (plats->virt_call)
  	    {
  	      VEC_replace (tree, *known_binfos, i, val->value);
  	      ret = true;
*************** gather_context_independent_values (struc
*** 1302,1313 ****
        else if (removable_params_cost
  	       && !ipa_is_param_used (info, i))
  	*removable_params_cost
! 	  +=  estimate_move_cost (TREE_TYPE (ipa_get_param (info, i)));
      }
  
    return ret;
  }
  
  /* Iterate over known values of parameters of NODE and estimate the local
     effects in terms of time and size they have.  */
  
--- 1731,1775 ----
        else if (removable_params_cost
  	       && !ipa_is_param_used (info, i))
  	*removable_params_cost
! 	  += estimate_move_cost (TREE_TYPE (ipa_get_param (info, i)));
! 
!       if (known_aggs)
! 	{
! 	  VEC (ipa_agg_jf_item_t, gc) *agg_items;
! 	  struct ipa_agg_jump_function *ajf;
! 
! 	  agg_items = context_independent_aggregate_values (plats);
! 	  ajf = &VEC_index (ipa_agg_jump_function_t, *known_aggs, i);
! 	  ajf->items = agg_items;
! 	  ajf->by_ref = plats->aggs_by_ref;
! 	  ret |= agg_items != NULL;
! 	}
      }
  
    return ret;
  }
  
+ /* The current interface in ipa-inline-analysis requires a pointer vector.
+    Create it.
+ 
+    FIXME: That interface should be re-worked, this is slightly silly.  Still,
+    I'd like to discuss how to change it first and this demonstrates the
+    issue.  */
+ 
+ static VEC (ipa_agg_jump_function_p, heap) *
+ agg_jmp_p_vec_for_t_vec (VEC (ipa_agg_jump_function_t, heap) *known_aggs)
+ {
+   VEC (ipa_agg_jump_function_p, heap) *ret;
+   struct ipa_agg_jump_function *ajf;
+   int i;
+ 
+   ret = VEC_alloc (ipa_agg_jump_function_p, heap,
+ 		   VEC_length (ipa_agg_jump_function_t, known_aggs));
+   FOR_EACH_VEC_ELT (ipa_agg_jump_function_t, known_aggs, i, ajf)
+     VEC_quick_push (ipa_agg_jump_function_p, ret, ajf);
+   return ret;
+ }
+ 
  /* Iterate over known values of parameters of NODE and estimate the local
     effects in terms of time and size they have.  */
  
*************** estimate_local_effects (struct cgraph_no
*** 1317,1322 ****
--- 1779,1786 ----
    struct ipa_node_params *info = IPA_NODE_REF (node);
    int i, count = ipa_get_param_count (info);
    VEC (tree, heap) *known_csts, *known_binfos;
+   VEC (ipa_agg_jump_function_t, heap) *known_aggs;
+   VEC (ipa_agg_jump_function_p, heap) *known_aggs_ptrs;
    bool always_const;
    int base_time = inline_summary (node)->time;
    int removable_params_cost;
*************** estimate_local_effects (struct cgraph_no
*** 1329,1346 ****
  	     cgraph_node_name (node), node->uid, base_time);
  
    always_const = gather_context_independent_values (info, &known_csts,
! 						    &known_binfos,
  						    &removable_params_cost);
    if (always_const)
      {
        struct caller_statistics stats;
        int time, size;
  
        init_caller_stats (&stats);
        cgraph_for_node_and_aliases (node, gather_caller_stats, &stats, false);
        estimate_ipcp_clone_size_and_time (node, known_csts, known_binfos,
! 					 &size, &time);
        time -= devirtualization_time_bonus (node, known_csts, known_binfos);
        time -= removable_params_cost;
        size -= stats.n_calls * removable_params_cost;
  
--- 1793,1813 ----
  	     cgraph_node_name (node), node->uid, base_time);
  
    always_const = gather_context_independent_values (info, &known_csts,
! 						    &known_binfos, &known_aggs,
  						    &removable_params_cost);
+   known_aggs_ptrs = agg_jmp_p_vec_for_t_vec (known_aggs);
    if (always_const)
      {
        struct caller_statistics stats;
+       inline_hints hints;
        int time, size;
  
        init_caller_stats (&stats);
        cgraph_for_node_and_aliases (node, gather_caller_stats, &stats, false);
        estimate_ipcp_clone_size_and_time (node, known_csts, known_binfos,
! 					 known_aggs_ptrs, &size, &time, &hints);
        time -= devirtualization_time_bonus (node, known_csts, known_binfos);
+       time -= hint_time_bonus (hints);
        time -= removable_params_cost;
        size -= stats.n_calls * removable_params_cost;
  
*************** estimate_local_effects (struct cgraph_no
*** 1381,1387 ****
  
    for (i = 0; i < count ; i++)
      {
!       struct ipcp_lattice *lat = ipa_get_lattice (info, i);
        struct ipcp_value *val;
        int emc;
  
--- 1848,1855 ----
  
    for (i = 0; i < count ; i++)
      {
!       struct ipcp_param_lattices *plats = ipa_get_parm_lattices (info, i);
!       struct ipcp_lattice *lat = &plats->itself;
        struct ipcp_value *val;
        int emc;
  
*************** estimate_local_effects (struct cgraph_no
*** 1394,1399 ****
--- 1862,1868 ----
        for (val = lat->values; val; val = val->next)
  	{
  	  int time, size, time_benefit;
+ 	  inline_hints hints;
  
  	  if (TREE_CODE (val->value) != TREE_BINFO)
  	    {
*************** estimate_local_effects (struct cgraph_no
*** 1401,1407 ****
  	      VEC_replace (tree, known_binfos, i, NULL_TREE);
  	      emc = estimate_move_cost (TREE_TYPE (val->value));
  	    }
! 	  else if (lat->virt_call)
  	    {
  	      VEC_replace (tree, known_csts, i, NULL_TREE);
  	      VEC_replace (tree, known_binfos, i, val->value);
--- 1870,1876 ----
  	      VEC_replace (tree, known_binfos, i, NULL_TREE);
  	      emc = estimate_move_cost (TREE_TYPE (val->value));
  	    }
! 	  else if (plats->virt_call)
  	    {
  	      VEC_replace (tree, known_csts, i, NULL_TREE);
  	      VEC_replace (tree, known_binfos, i, val->value);
*************** estimate_local_effects (struct cgraph_no
*** 1411,1419 ****
  	    continue;
  
  	  estimate_ipcp_clone_size_and_time (node, known_csts, known_binfos,
! 					     &size, &time);
  	  time_benefit = base_time - time
  	    + devirtualization_time_bonus (node, known_csts, known_binfos)
  	    + removable_params_cost + emc;
  
  	  gcc_checking_assert (size >=0);
--- 1880,1890 ----
  	    continue;
  
  	  estimate_ipcp_clone_size_and_time (node, known_csts, known_binfos,
! 					     known_aggs_ptrs, &size, &time,
! 					     &hints);
  	  time_benefit = base_time - time
  	    + devirtualization_time_bonus (node, known_csts, known_binfos)
+ 	    + hint_time_bonus (hints)
  	    + removable_params_cost + emc;
  
  	  gcc_checking_assert (size >=0);
*************** estimate_local_effects (struct cgraph_no
*** 1437,1446 ****
--- 1908,1986 ----
  	  val->local_time_benefit = time_benefit;
  	  val->local_size_cost = size;
  	}
+       VEC_replace (tree, known_binfos, i, NULL_TREE);
+       VEC_replace (tree, known_csts, i, NULL_TREE);
+     }
+ 
+   for (i = 0; i < count ; i++)
+     {
+       struct ipcp_param_lattices *plats = ipa_get_parm_lattices (info, i);
+       struct ipa_agg_jump_function *ajf;
+       struct ipcp_agg_lattice *aglat;
+ 
+       if (plats->aggs_bottom || !plats->aggs)
+ 	continue;
+ 
+       ajf = &VEC_index (ipa_agg_jump_function_t, known_aggs, i);
+       for (aglat = plats->aggs; aglat; aglat = aglat->next)
+ 	{
+ 	  struct ipcp_value *val;
+ 	  if (aglat->bottom || !aglat->values
+ 	      /* If the following is true, the one value is in known_aggs.  */
+ 	      || (!plats->aggs_contain_variable
+ 		  && ipa_lat_is_single_const (aglat)))
+ 	    continue;
+ 
+ 	  for (val = aglat->values; val; val = val->next)
+ 	    {
+ 	      int time, size, time_benefit;
+ 	      struct ipa_agg_jf_item item;
+ 	      inline_hints hints;
+ 
+ 	      item.offset = aglat->offset;
+ 	      item.value = val->value;
+ 	      VEC_safe_push (ipa_agg_jf_item_t, gc, ajf->items, item);
+ 
+ 	      estimate_ipcp_clone_size_and_time (node, known_csts, known_binfos,
+ 						 known_aggs_ptrs, &size, &time,
+ 						 &hints);
+ 	      time_benefit = base_time - time
+ 		+ devirtualization_time_bonus (node, known_csts, known_binfos)
+ 		+ hint_time_bonus (hints);
+ 	      gcc_checking_assert (size >=0);
+ 	      if (size == 0)
+ 		size = 1;
+ 
+ 	      if (dump_file && (dump_flags & TDF_DETAILS))
+ 		{
+ 		  fprintf (dump_file, " - estimates for value ");
+ 		  print_ipcp_constant_value (dump_file, val->value);
+ 		  fprintf (dump_file, " for parameter ");
+ 		  print_generic_expr (dump_file, ipa_get_param (info, i), 0);
+ 		  fprintf (dump_file, "[%soffset: " HOST_WIDE_INT_PRINT_DEC
+ 				       "]: time_benefit: %i, size: %i\n",
+ 				       plats->aggs_by_ref ? "ref " : "",
+ 				       aglat->offset, time_benefit, size);
+ 		}
+ 
+ 	      val->local_time_benefit = time_benefit;
+ 	      val->local_size_cost = size;
+ 	      VEC_pop (ipa_agg_jf_item_t, ajf->items);
+ 	    }
+ 	}
+     }
+ 
+   for (i = 0; i < count ; i++)
+     {
+       VEC_free (ipa_agg_jf_item_t, gc,
+                 VEC_index (ipa_agg_jump_function_t, known_aggs, i).items);
+       VEC_index (ipa_agg_jump_function_t, known_aggs, i).items = NULL;
      }
  
    VEC_free (tree, heap, known_csts);
    VEC_free (tree, heap, known_binfos);
+   VEC_free (ipa_agg_jump_function_t, heap, known_aggs);
+   VEC_free (ipa_agg_jump_function_p, heap, known_aggs_ptrs);
  }
  
  
*************** add_all_node_vals_to_toposort (struct cg
*** 1510,1522 ****
  
    for (i = 0; i < count ; i++)
      {
!       struct ipcp_lattice *lat = ipa_get_lattice (info, i);
        struct ipcp_value *val;
  
!       if (lat->bottom || !lat->values)
! 	continue;
!       for (val = lat->values; val; val = val->next)
! 	add_val_to_toposort (val);
      }
  }
  
--- 2050,2069 ----
  
    for (i = 0; i < count ; i++)
      {
!       struct ipcp_param_lattices *plats = ipa_get_parm_lattices (info, i);
!       struct ipcp_lattice *lat = &plats->itself;
!       struct ipcp_agg_lattice *aglat;
        struct ipcp_value *val;
  
!       if (!lat->bottom)
! 	for (val = lat->values; val; val = val->next)
! 	  add_val_to_toposort (val);
! 
!       if (!plats->aggs_bottom)
! 	for (aglat = plats->aggs; aglat; aglat = aglat->next)
! 	  if (!aglat->bottom)
! 	    for (val = aglat->values; val; val = val->next)
! 	      add_val_to_toposort (val);
      }
  }
  
*************** ipcp_propagate_stage (struct topo_info *
*** 1649,1655 ****
      determine_versionability (node);
      if (cgraph_function_with_gimple_body_p (node))
        {
! 	info->lattices = XCNEWVEC (struct ipcp_lattice,
  				   ipa_get_param_count (info));
  	initialize_node_lattices (node);
        }
--- 2196,2202 ----
      determine_versionability (node);
      if (cgraph_function_with_gimple_body_p (node))
        {
! 	info->lattices = XCNEWVEC (struct ipcp_param_lattices,
  				   ipa_get_param_count (info));
  	initialize_node_lattices (node);
        }
*************** ipcp_edge_duplication_hook (struct cgrap
*** 1734,1745 ****
    VEC_replace (cgraph_edge_p, next_edge_clone, src->uid, dst);
  }
  
! /* Get the next clone in the linked list of clones of an edge.  */
  
! static inline struct cgraph_edge *
! get_next_cgraph_edge_clone (struct cgraph_edge *cs)
  {
!   return VEC_index (cgraph_edge_p, next_edge_clone, cs->uid);
  }
  
  /* Return true if edge CS does bring about the value described by SRC.  */
--- 2281,2304 ----
    VEC_replace (cgraph_edge_p, next_edge_clone, src->uid, dst);
  }
  
! /* See if NODE is a clone with a known aggregate value at a given OFFSET of a
!    parameter with the given INDEX.  */
  
! static tree
! get_clone_agg_value (struct cgraph_node *node, HOST_WIDEST_INT offset,
! 		     int index)
  {
!   struct ipa_agg_replacement_value *aggval;
! 
!   aggval = ipa_get_agg_replacements_for_node (node);
!   while (aggval)
!     {
!       if (aggval->offset == offset
! 	  && aggval->index == index)
! 	return aggval->value;
!       aggval = aggval->next;
!     }
!   return NULL_TREE;
  }
  
  /* Return true if edge CS does bring about the value described by SRC.  */
*************** cgraph_edge_brings_value_p (struct cgrap
*** 1758,1778 ****
  
    if (caller_info->ipcp_orig_node)
      {
!       tree t = VEC_index (tree, caller_info->known_vals, src->index);
        return (t != NULL_TREE
  	      && values_equal_for_ipcp_p (src->val->value, t));
      }
    else
      {
!       struct ipcp_lattice *lat = ipa_get_lattice (caller_info, src->index);
!       if (ipa_lat_is_single_const (lat)
! 	  && values_equal_for_ipcp_p (src->val->value, lat->values->value))
! 	return true;
        else
! 	return false;
      }
  }
  
  /* Given VAL, iterate over all its sources and if they still hold, add their
     edge frequency and their number into *FREQUENCY and *CALLER_COUNT
     respectively.  */
--- 2317,2361 ----
  
    if (caller_info->ipcp_orig_node)
      {
!       tree t;
!       if (src->offset == -1)
! 	t = VEC_index (tree, caller_info->known_vals, src->index);
!       else
! 	t = get_clone_agg_value (cs->caller, src->offset, src->index);
        return (t != NULL_TREE
  	      && values_equal_for_ipcp_p (src->val->value, t));
      }
    else
      {
!       struct ipcp_agg_lattice *aglat;
!       struct ipcp_param_lattices *plats = ipa_get_parm_lattices (caller_info,
! 								 src->index);
!       if (src->offset == -1)
! 	return (ipa_lat_is_single_const (&plats->itself)
! 		&& values_equal_for_ipcp_p (src->val->value,
! 					    plats->itself.values->value));
        else
! 	{
! 	  if (plats->aggs_bottom || plats->aggs_contain_variable)
! 	    return false;
! 	  for (aglat = plats->aggs; aglat; aglat = aglat->next)
! 	    if (aglat->offset == src->offset)
! 	      return  (ipa_lat_is_single_const (aglat)
! 		       && values_equal_for_ipcp_p (src->val->value,
! 						   aglat->values->value));
! 	}
!       return false;
      }
  }
  
+ /* Get the next clone in the linked list of clones of an edge.  */
+ 
+ static inline struct cgraph_edge *
+ get_next_cgraph_edge_clone (struct cgraph_edge *cs)
+ {
+   return VEC_index (cgraph_edge_p, next_edge_clone, cs->uid);
+ }
+ 
  /* Given VAL, iterate over all its sources and if they still hold, add their
     edge frequency and their number into *FREQUENCY and *CALLER_COUNT
     respectively.  */
*************** update_specialized_profile (struct cgrap
*** 2009,2014 ****
--- 2592,2598 ----
  static struct cgraph_node *
  create_specialized_node (struct cgraph_node *node,
  			 VEC (tree, heap) *known_vals,
+ 			 struct ipa_agg_replacement_value *aggvals,
  			 VEC (cgraph_edge_p,heap) *callers)
  {
    struct ipa_node_params *new_info, *info = IPA_NODE_REF (node);
*************** create_specialized_node (struct cgraph_n
*** 2053,2061 ****
  
    new_node = cgraph_create_virtual_clone (node, callers, replace_trees,
  					  args_to_skip, "constprop");
    if (dump_file && (dump_flags & TDF_DETAILS))
!     fprintf (dump_file, "     the new node is %s/%i.\n",
! 	     cgraph_node_name (new_node), new_node->uid);
    gcc_checking_assert (ipa_node_params_vector
  		       && (VEC_length (ipa_node_params_t,
  				       ipa_node_params_vector)
--- 2637,2650 ----
  
    new_node = cgraph_create_virtual_clone (node, callers, replace_trees,
  					  args_to_skip, "constprop");
+   ipa_set_node_agg_value_chain (new_node, aggvals);
    if (dump_file && (dump_flags & TDF_DETAILS))
!     {
!       fprintf (dump_file, "     the new node is %s/%i.\n",
! 	       cgraph_node_name (new_node), new_node->uid);
!       if (aggvals)
! 	ipa_dump_agg_replacement_values (dump_file, aggvals);
!     }
    gcc_checking_assert (ipa_node_params_vector
  		       && (VEC_length (ipa_node_params_t,
  				       ipa_node_params_vector)
*************** create_specialized_node (struct cgraph_n
*** 2076,2084 ****
     CALLERS.  */
  
  static void
! find_more_values_for_callers_subset (struct cgraph_node *node,
! 				     VEC (tree, heap) *known_vals,
! 				     VEC (cgraph_edge_p,heap) *callers)
  {
    struct ipa_node_params *info = IPA_NODE_REF (node);
    int i, count = ipa_get_param_count (info);
--- 2665,2673 ----
     CALLERS.  */
  
  static void
! find_more_scalar_values_for_callers_subset (struct cgraph_node *node,
! 					    VEC (tree, heap) *known_vals,
! 					    VEC (cgraph_edge_p,heap) *callers)
  {
    struct ipa_node_params *info = IPA_NODE_REF (node);
    int i, count = ipa_get_param_count (info);
*************** find_more_values_for_callers_subset (str
*** 2089,2095 ****
        tree newval = NULL_TREE;
        int j;
  
!       if (ipa_get_lattice (info, i)->bottom
  	  || VEC_index (tree, known_vals, i))
  	continue;
  
--- 2678,2684 ----
        tree newval = NULL_TREE;
        int j;
  
!       if (ipa_get_scalar_lat (info, i)->bottom
  	  || VEC_index (tree, known_vals, i))
  	continue;
  
*************** find_more_values_for_callers_subset (str
*** 2120,2126 ****
  	{
  	  if (dump_file && (dump_flags & TDF_DETAILS))
  	    {
! 	      fprintf (dump_file, "    adding an extra known value ");
  	      print_ipcp_constant_value (dump_file, newval);
  	      fprintf (dump_file, " for parameter ");
  	      print_generic_expr (dump_file, ipa_get_param (info, i), 0);
--- 2709,2715 ----
  	{
  	  if (dump_file && (dump_flags & TDF_DETAILS))
  	    {
! 	      fprintf (dump_file, "    adding an extra known scalar value ");
  	      print_ipcp_constant_value (dump_file, newval);
  	      fprintf (dump_file, " for parameter ");
  	      print_generic_expr (dump_file, ipa_get_param (info, i), 0);
*************** find_more_values_for_callers_subset (str
*** 2132,2137 ****
--- 2721,3111 ----
      }
  }
  
+ /* Go through PLATS and create a vector of values consisting of values and
+    offsets (minus OFFSET) of lattices that contain only a single value.  */
+ 
+ static VEC (ipa_agg_jf_item_t, heap) *
+ copy_plats_to_inter (struct ipcp_param_lattices *plats, HOST_WIDE_INT offset)
+ {
+   VEC (ipa_agg_jf_item_t, heap) *res = NULL;
+ 
+   if (!plats->aggs || plats->aggs_contain_variable || plats->aggs_bottom)
+     return NULL;
+ 
+   for (struct ipcp_agg_lattice *aglat = plats->aggs; aglat; aglat = aglat->next)
+     if (ipa_lat_is_single_const (aglat))
+       {
+ 	struct ipa_agg_jf_item ti;
+ 	ti.offset = aglat->offset - offset;
+ 	ti.value = aglat->values->value;
+ 	VEC_safe_push (ipa_agg_jf_item_t, heap, res, ti);
+       }
+   return res;
+ }
+ 
+ /* Intersect all values in INTER with single value lattices in PLATS (while
+    subtracting OFFSET).  */
+ 
+ static void
+ intersect_with_plats (struct ipcp_param_lattices *plats,
+ 		      VEC (ipa_agg_jf_item_t, heap) **inter,
+ 		      HOST_WIDE_INT offset)
+ {
+   struct ipcp_agg_lattice *aglat;
+   struct ipa_agg_jf_item *item;
+   int k;
+ 
+   if (!plats->aggs || plats->aggs_contain_variable || plats->aggs_bottom)
+     {
+       VEC_free (ipa_agg_jf_item_t, heap, *inter);
+       *inter = NULL;
+       return;
+     }
+ 
+   aglat = plats->aggs;
+   FOR_EACH_VEC_ELT (ipa_agg_jf_item_t, *inter, k, item)
+     {
+       bool found = false;
+       if (!item->value)
+ 	continue;
+       while (aglat)
+ 	{
+ 	  if (aglat->offset - offset > item->offset)
+ 	    break;
+ 	  if (aglat->offset - offset == item->offset)
+ 	    {
+ 	      gcc_checking_assert (item->value);
+ 	      if (values_equal_for_ipcp_p (item->value, aglat->values->value))
+ 		found = true;
+ 	      break;
+ 	    }
+ 	  aglat = aglat->next;
+ 	}
+       if (!found)
+ 	item->value = NULL_TREE;
+     }
+ }
+ 
+ /* Copy agggregate replacement values of NODE (which is an IPA-CP clone) to the
+    vector result while subtracting OFFSET from the individual value offsets.  */
+ 
+ static VEC (ipa_agg_jf_item_t, heap) *
+ agg_replacements_to_vector (struct cgraph_node *node, HOST_WIDE_INT offset)
+ {
+   struct ipa_agg_replacement_value *av;
+   VEC (ipa_agg_jf_item_t, heap) *res = NULL;
+ 
+   for (av = ipa_get_agg_replacements_for_node (node); av; av = av->next)
+     {
+       struct ipa_agg_jf_item item;
+       gcc_checking_assert (av->value);
+       item.offset = av->offset - offset;
+       item.value = av->value;
+       VEC_safe_push (ipa_agg_jf_item_t, heap, res, item);
+     }
+ 
+   return res;
+ }
+ 
+ /* Intersect all values in INTER with those that we have already scheduled to
+    be replaced in parameter number INDEX of NODE, which is an IPA-CP clone
+    (while subtracting OFFSET).  */
+ 
+ static void
+ intersect_with_agg_replacements (struct cgraph_node *node, int index,
+ 				 VEC (ipa_agg_jf_item_t, heap) **inter,
+ 				 HOST_WIDE_INT offset)
+ {
+   struct ipa_agg_replacement_value *srcvals;
+   struct ipa_agg_jf_item *item;
+   int i;
+ 
+   srcvals = ipa_get_agg_replacements_for_node (node);
+   if (!srcvals)
+     {
+       VEC_free (ipa_agg_jf_item_t, heap, *inter);
+       *inter = NULL;
+       return;
+     }
+ 
+   FOR_EACH_VEC_ELT (ipa_agg_jf_item_t, *inter, i, item)
+     {
+       struct ipa_agg_replacement_value *av;
+       bool found = false;
+       if (!item->value)
+ 	continue;
+       for (av = srcvals; av; av = av->next)
+ 	{
+ 	  gcc_checking_assert (av->value);
+ 	  if (av->index == index
+ 	      && av->offset - offset == item->offset)
+ 	    {
+ 	      if (values_equal_for_ipcp_p (item->value, av->value))
+ 		found = true;
+ 	      break;
+ 	    }
+ 	}
+       if (!found)
+ 	item->value = NULL_TREE;
+     }
+ }
+ 
+ /* Look at edges in CALLERS and collect all known aggregate values that arrive
+    from all of them.  */
+ 
+ static struct ipa_agg_replacement_value *
+ find_aggregate_values_for_callers_subset (struct cgraph_node *node,
+ 					  VEC (cgraph_edge_p,heap) *callers)
+ {
+   struct ipa_node_params *info = IPA_NODE_REF (node);
+   struct ipa_agg_replacement_value *res = NULL;
+   struct cgraph_edge *cs;
+   int i, j, count = ipa_get_param_count (info);
+ 
+   FOR_EACH_VEC_ELT (cgraph_edge_p, callers, j, cs)
+     {
+       int c = ipa_get_cs_argument_count (IPA_EDGE_REF (cs));
+       if (c < count)
+ 	count = c;
+     }
+ 
+   for (i = 0; i < count ; i++)
+     {
+       struct cgraph_edge *cs;
+       VEC (ipa_agg_jf_item_t, heap) *inter = NULL;
+       struct ipa_agg_jf_item *item;
+       int j;
+ 
+       /* Among other things, the following check should deal with all by_ref
+ 	 mismatches.  */
+       if (ipa_get_parm_lattices (info, i)->aggs_bottom)
+ 	continue;
+ 
+       FOR_EACH_VEC_ELT (cgraph_edge_p, callers, j, cs)
+ 	{
+ 	  struct ipa_jump_func *jfunc;
+ 	  jfunc = ipa_get_ith_jump_func (IPA_EDGE_REF (cs), i);
+ 	  if (jfunc->type == IPA_JF_PASS_THROUGH
+ 	      && ipa_get_jf_pass_through_operation (jfunc) == NOP_EXPR)
+ 	    {
+ 	      struct ipa_node_params *caller_info = IPA_NODE_REF (cs->caller);
+ 	      int src_idx = ipa_get_jf_pass_through_formal_id (jfunc);
+ 
+ 	      if (caller_info->ipcp_orig_node)
+ 		{
+ 		  if (!inter)
+ 		    inter = agg_replacements_to_vector (cs->caller, 0);
+ 		  else
+ 		    intersect_with_agg_replacements (cs->caller, src_idx,
+ 						     &inter, 0);
+ 		}
+ 	      else
+ 		{
+ 		  struct ipcp_param_lattices *src_plats;
+ 		  src_plats = ipa_get_parm_lattices (caller_info, src_idx);
+ 		  /* Currently we do not produce clobber aggregate jump
+ 		     functions, adjust when we do.  */
+ 		  gcc_checking_assert (!jfunc->agg.items);
+ 		  if (!inter)
+ 		    inter = copy_plats_to_inter (src_plats, 0);
+ 		  else
+ 		    intersect_with_plats (src_plats, &inter, 0);
+ 		}
+ 	    }
+ 	  else if (jfunc->type == IPA_JF_ANCESTOR
+ 		   && ipa_get_jf_ancestor_agg_preserved (jfunc))
+ 	    {
+ 	      struct ipa_node_params *caller_info = IPA_NODE_REF (cs->caller);
+ 	      int src_idx = ipa_get_jf_ancestor_formal_id (jfunc);
+ 	      struct ipcp_param_lattices *src_plats;
+ 	      HOST_WIDE_INT delta = ipa_get_jf_ancestor_offset (jfunc);
+ 
+ 	      if (info->ipcp_orig_node)
+ 		{
+ 		  if (!inter)
+ 		    inter = agg_replacements_to_vector (cs->caller, delta);
+ 		  else
+ 		    intersect_with_agg_replacements (cs->caller, i, &inter,
+ 						     delta);
+ 		}
+ 	      else
+ 		{
+ 		  src_plats = ipa_get_parm_lattices (caller_info, src_idx);;
+ 		  /* Currently we do not produce clobber aggregate jump
+ 		     functions, adjust when we do.  */
+ 		  gcc_checking_assert (!jfunc->agg.items);
+ 		  if (!inter)
+ 		    inter = copy_plats_to_inter (src_plats, delta);
+ 		  else
+ 		    intersect_with_plats (src_plats, &inter, delta);
+ 		}
+ 	    }
+ 	  else if (jfunc->agg.items)
+ 	    {
+ 	      int k;
+ 
+ 	      if (!inter)
+ 		inter = VEC_copy (ipa_agg_jf_item, heap, jfunc->agg.items);
+ 	      else
+ 		FOR_EACH_VEC_ELT (ipa_agg_jf_item_t, inter, k, item)
+ 		  {
+ 		    int l = 0;
+ 		    bool found = false;;
+ 
+ 		    if (!item->value)
+ 		      continue;
+ 
+ 		    while ((unsigned) l < VEC_length (ipa_agg_jf_item_t,
+ 						      jfunc->agg.items))
+ 		      {
+ 			struct ipa_agg_jf_item *ti;
+ 		        ti = &VEC_index (ipa_agg_jf_item_t,
+ 					 jfunc->agg.items, l);
+ 			if (ti->offset > item->offset)
+ 			  break;
+ 			if (ti->offset == item->offset)
+ 			  {
+ 			    gcc_checking_assert (ti->value);
+ 			    if (values_equal_for_ipcp_p (item->value,
+ 							  ti->value))
+ 			      found = true;
+ 			    break;
+ 			  }
+ 			l++;
+ 		      }
+ 		    if (!found)
+ 		      item->value = NULL;
+ 		  }
+ 	    }
+ 	  else
+ 	    goto next_param;
+ 
+ 	  if (!inter)
+ 	    goto next_param;
+ 	}
+ 
+       FOR_EACH_VEC_ELT (ipa_agg_jf_item_t, inter, j, item)
+ 	{
+ 	  struct ipa_agg_replacement_value *v;
+ 
+ 	  if (!item->value)
+ 	    continue;
+ 
+ 	  v = ggc_alloc_ipa_agg_replacement_value ();
+ 	  v->index = i;
+ 	  v->offset = item->offset;
+ 	  v->value = item->value;
+ 	  v->next = res;
+ 	  res = v;
+ 	}
+ 
+     next_param:
+       if (inter)
+ 	VEC_free (ipa_agg_jf_item, heap, inter);
+     }
+   return res;
+ }
+ 
+ /* Turn KNOWN_AGGS into a list of aggreate replacement values.  */
+ 
+ static struct ipa_agg_replacement_value *
+ known_aggs_to_agg_replacement_list (VEC (ipa_agg_jump_function_t,
+ 					 heap) *known_aggs)
+ {
+   struct ipa_agg_replacement_value *res = NULL;
+   struct ipa_agg_jump_function *aggjf;
+   struct ipa_agg_jf_item *item;
+   int i, j;
+ 
+   FOR_EACH_VEC_ELT (ipa_agg_jump_function_t, known_aggs, i, aggjf)
+     FOR_EACH_VEC_ELT (ipa_agg_jf_item_t, aggjf->items, j, item)
+       {
+ 	struct ipa_agg_replacement_value *v;
+ 	v = ggc_alloc_ipa_agg_replacement_value ();
+ 	v->index = i;
+ 	v->offset = item->offset;
+ 	v->value = item->value;
+ 	v->next = res;
+ 	res = v;
+       }
+   return res;
+ }
+ 
+ /* Determine whether CS also brings all scalar values that the NODE is
+    specialized for.  */
+ 
+ static bool
+ cgraph_edge_brings_all_scalars_for_node (struct cgraph_edge *cs,
+ 					 struct cgraph_node *node)
+ {
+   struct ipa_node_params *dest_info = IPA_NODE_REF (node);
+   int count = ipa_get_param_count (dest_info);
+   struct ipa_node_params *caller_info;
+   struct ipa_edge_args *args;
+   int i;
+ 
+   caller_info = IPA_NODE_REF (cs->caller);
+   args = IPA_EDGE_REF (cs);
+   for (i = 0; i < count; i++)
+     {
+       struct ipa_jump_func *jump_func;
+       tree val, t;
+ 
+       val = VEC_index (tree, dest_info->known_vals, i);
+       if (!val)
+ 	continue;
+ 
+       if (i >= ipa_get_cs_argument_count (args))
+ 	return false;
+       jump_func = ipa_get_ith_jump_func (args, i);
+       t = ipa_value_from_jfunc (caller_info, jump_func);
+       if (!t || !values_equal_for_ipcp_p (val, t))
+ 	return false;
+     }
+   return true;
+ }
+ 
+ /* Determine whether CS also brings all aggregate values that NODE is
+    specialized for.  */
+ static bool
+ cgraph_edge_brings_all_agg_vals_for_node (struct cgraph_edge *cs,
+ 					  struct cgraph_node *node)
+ {
+   struct ipa_node_params *caller_info = IPA_NODE_REF (cs->caller);
+   struct ipa_agg_replacement_value *aggval;
+ 
+   aggval = ipa_get_agg_replacements_for_node (node);
+   while (aggval)
+     {
+       bool found = false;
+       struct ipcp_param_lattices *plats;
+       plats = ipa_get_parm_lattices (caller_info, aggval->index);
+       if (plats->aggs_bottom || plats->aggs_contain_variable)
+ 	return false;
+       for (struct ipcp_agg_lattice *aglat = plats->aggs;
+ 	   aglat;
+ 	   aglat = aglat->next)
+ 	  if (aglat->offset == aggval->offset)
+ 	    {
+ 	      if (ipa_lat_is_single_const (aglat)
+ 		  && values_equal_for_ipcp_p (aggval->value,
+ 					      aglat->values->value))
+ 		{
+ 		  found = true;
+ 		  break;
+ 		}
+ 	      else
+ 		return false;
+ 	    }
+ 
+       if (!found)
+ 	return false;
+ 
+       aggval = aggval->next;
+     }
+   return true;
+ }
+ 
  /* Given an original NODE and a VAL for which we have already created a
     specialized clone, look whether there are incoming edges that still lead
     into the old node but now also bring the requested value and also conform to
*************** find_more_values_for_callers_subset (str
*** 2141,2149 ****
  static void
  perhaps_add_new_callers (struct cgraph_node *node, struct ipcp_value *val)
  {
-   struct ipa_node_params *dest_info = IPA_NODE_REF (val->spec_node);
    struct ipcp_value_source *src;
-   int count = ipa_get_param_count (dest_info);
    gcov_type redirected_sum = 0;
  
    for (src = val->sources; src; src = src->next)
--- 3115,3121 ----
*************** perhaps_add_new_callers (struct cgraph_n
*** 2152,2193 ****
        while (cs)
  	{
  	  enum availability availability;
- 	  bool insufficient = false;
  
  	  if (cgraph_function_node (cs->callee, &availability) == node
  	      && availability > AVAIL_OVERWRITABLE
  	      && cgraph_edge_brings_value_p (cs, src))
  	    {
! 	      struct ipa_node_params *caller_info;
! 	      struct ipa_edge_args *args;
! 	      int i;
! 
! 	      caller_info = IPA_NODE_REF (cs->caller);
! 	      args = IPA_EDGE_REF (cs);
! 	      for (i = 0; i < count; i++)
! 		{
! 		  struct ipa_jump_func *jump_func;
! 		  tree val, t;
! 
! 		  val = VEC_index (tree, dest_info->known_vals, i);
! 		  if (!val)
! 		    continue;
! 
! 		  if (i >= ipa_get_cs_argument_count (args))
! 		    {
! 		      insufficient = true;
! 		      break;
! 		    }
! 		  jump_func = ipa_get_ith_jump_func (args, i);
! 		  t = ipa_value_from_jfunc (caller_info, jump_func);
! 		  if (!t || !values_equal_for_ipcp_p (val, t))
! 		    {
! 		      insufficient = true;
! 		      break;
! 		    }
! 		}
! 
! 	      if (!insufficient)
  		{
  		  if (dump_file)
  		    fprintf (dump_file, " - adding an extra caller %s/%i"
--- 3124,3137 ----
        while (cs)
  	{
  	  enum availability availability;
  
  	  if (cgraph_function_node (cs->callee, &availability) == node
  	      && availability > AVAIL_OVERWRITABLE
  	      && cgraph_edge_brings_value_p (cs, src))
  	    {
! 	      if (cgraph_edge_brings_all_scalars_for_node (cs, val->spec_node)
! 		  && cgraph_edge_brings_all_agg_vals_for_node (cs,
! 							       val->spec_node))
  		{
  		  if (dump_file)
  		    fprintf (dump_file, " - adding an extra caller %s/%i"
*************** move_binfos_to_values (VEC (tree, heap)
*** 2224,2229 ****
--- 3168,3269 ----
        VEC_replace (tree, known_vals, i, t);
  }
  
+ /* Return true if there is a replacement equivalent to VALUE, INDEX and OFFSET
+    among those in the AGGVALS list.  */
+ 
+ DEBUG_FUNCTION bool
+ ipcp_val_in_agg_replacements_p (struct ipa_agg_replacement_value *aggvals,
+ 				int index, HOST_WIDE_INT offset, tree value)
+ {
+   while (aggvals)
+     {
+       if (aggvals->index == index
+ 	  && aggvals->offset == offset
+ 	  && values_equal_for_ipcp_p (aggvals->value, value))
+ 	return true;
+       aggvals = aggvals->next;
+     }
+   return false;
+ }
+ 
+ /* Decide wheter to create a special version of NODE for value VAL of parameter
+    at the given INDEX.  If OFFSET is -1, the value is for the parameter itself,
+    otherwise it is stored at the given OFFSET of the parameter.  KNOWN_CSTS,
+    KNOWN_BINFOS and KNOWN_AGGS describe the other already known values.  */
+ 
+ static bool
+ decide_about_value (struct cgraph_node *node, int index, HOST_WIDE_INT offset,
+ 		    struct ipcp_value *val, VEC (tree, heap) *known_csts,
+ 		    VEC (tree, heap) *known_binfos)
+ {
+   struct ipa_agg_replacement_value *aggvals;
+   int freq_sum, caller_count;
+   gcov_type count_sum;
+   VEC (cgraph_edge_p, heap) *callers;
+   VEC (tree, heap) *kv;
+ 
+   if (val->spec_node)
+     {
+       perhaps_add_new_callers (node, val);
+       return false;
+     }
+   else if (val->local_size_cost + overall_size > max_new_size)
+     {
+       if (dump_file && (dump_flags & TDF_DETAILS))
+ 	fprintf (dump_file, "   Ignoring candidate value because "
+ 		 "max_new_size would be reached with %li.\n",
+ 		 val->local_size_cost + overall_size);
+       return false;
+     }
+   else if (!get_info_about_necessary_edges (val, &freq_sum, &count_sum,
+ 					    &caller_count))
+     return false;
+ 
+   if (dump_file && (dump_flags & TDF_DETAILS))
+     {
+       fprintf (dump_file, " - considering value ");
+       print_ipcp_constant_value (dump_file, val->value);
+       fprintf (dump_file, " for parameter ");
+       print_generic_expr (dump_file, ipa_get_param (IPA_NODE_REF (node),
+ 						    index), 0);
+       if (offset != -1)
+ 	fprintf (dump_file, ", offset: " HOST_WIDE_INT_PRINT_DEC, offset);
+       fprintf (dump_file, " (caller_count: %i)\n", caller_count);
+     }
+ 
+   if (!good_cloning_opportunity_p (node, val->local_time_benefit,
+ 				   freq_sum, count_sum,
+ 				   val->local_size_cost)
+       && !good_cloning_opportunity_p (node,
+ 				      val->local_time_benefit
+ 				      + val->prop_time_benefit,
+ 				      freq_sum, count_sum,
+ 				      val->local_size_cost
+ 				      + val->prop_size_cost))
+     return false;
+ 
+   if (dump_file)
+     fprintf (dump_file, "  Creating a specialized node of %s/%i.\n",
+ 	     cgraph_node_name (node), node->uid);
+ 
+   callers = gather_edges_for_value (val, caller_count);
+   kv = VEC_copy (tree, heap, known_csts);
+   move_binfos_to_values (kv, known_binfos);
+   if (offset == -1)
+     VEC_replace (tree, kv, index, val->value);
+   find_more_scalar_values_for_callers_subset (node, kv, callers);
+   aggvals = find_aggregate_values_for_callers_subset (node, callers);
+   gcc_checking_assert (offset == -1
+ 		       || ipcp_val_in_agg_replacements_p (aggvals, index,
+ 							  offset, val->value));
+   val->spec_node = create_specialized_node (node, kv, aggvals, callers);
+   overall_size += val->local_size_cost;
+ 
+   /* TODO: If for some lattice there is only one other known value
+      left, make a special node for it too. */
+ 
+   return true;
+ }
  
  /* Decide whether and what specialized clones of NODE should be created.  */
  
*************** decide_whether_version_node (struct cgra
*** 2233,2238 ****
--- 3273,3279 ----
    struct ipa_node_params *info = IPA_NODE_REF (node);
    int i, count = ipa_get_param_count (info);
    VEC (tree, heap) *known_csts, *known_binfos;
+   VEC (ipa_agg_jump_function_t, heap) *known_aggs = NULL;
    bool ret = false;
  
    if (count == 0)
*************** decide_whether_version_node (struct cgra
*** 2243,2324 ****
  	     cgraph_node_name (node), node->uid);
  
    gather_context_independent_values (info, &known_csts, &known_binfos,
! 				     NULL);
  
!   for (i = 0; i < count ; i++)
      {
!       struct ipcp_lattice *lat = ipa_get_lattice (info, i);
        struct ipcp_value *val;
  
!       if (lat->bottom
! 	  || VEC_index (tree, known_csts, i)
! 	  || VEC_index (tree, known_binfos, i))
! 	continue;
  
!       for (val = lat->values; val; val = val->next)
  	{
! 	  int freq_sum, caller_count;
! 	  gcov_type count_sum;
! 	  VEC (cgraph_edge_p, heap) *callers;
! 	  VEC (tree, heap) *kv;
! 
! 	  if (val->spec_node)
! 	    {
! 	      perhaps_add_new_callers (node, val);
! 	      continue;
! 	    }
! 	  else if (val->local_size_cost + overall_size > max_new_size)
! 	    {
! 	      if (dump_file && (dump_flags & TDF_DETAILS))
! 		fprintf (dump_file, "   Ignoring candidate value because "
! 			 "max_new_size would be reached with %li.\n",
! 			 val->local_size_cost + overall_size);
! 	      continue;
! 	    }
! 	  else if (!get_info_about_necessary_edges (val, &freq_sum, &count_sum,
! 						    &caller_count))
! 	    continue;
! 
! 	  if (dump_file && (dump_flags & TDF_DETAILS))
! 	    {
! 	      fprintf (dump_file, " - considering value ");
! 	      print_ipcp_constant_value (dump_file, val->value);
! 	      fprintf (dump_file, " for parameter ");
! 	      print_generic_expr (dump_file, ipa_get_param (info, i), 0);
! 	      fprintf (dump_file, " (caller_count: %i)\n", caller_count);
! 	    }
! 
! 
! 	  if (!good_cloning_opportunity_p (node, val->local_time_benefit,
! 					   freq_sum, count_sum,
! 					   val->local_size_cost)
! 	      && !good_cloning_opportunity_p (node,
! 					      val->local_time_benefit
! 					      + val->prop_time_benefit,
! 					      freq_sum, count_sum,
! 					      val->local_size_cost
! 					      + val->prop_size_cost))
! 	    continue;
! 
! 	  if (dump_file)
! 	    fprintf (dump_file, "  Creating a specialized node of %s/%i.\n",
! 		     cgraph_node_name (node), node->uid);
! 
! 	  callers = gather_edges_for_value (val, caller_count);
! 	  kv = VEC_copy (tree, heap, known_csts);
! 	  move_binfos_to_values (kv, known_binfos);
! 	  VEC_replace (tree, kv, i, val->value);
! 	  find_more_values_for_callers_subset (node, kv, callers);
! 	  val->spec_node = create_specialized_node (node, kv, callers);
! 	  overall_size += val->local_size_cost;
! 	  info = IPA_NODE_REF (node);
! 
! 	  /* TODO: If for some lattice there is only one other known value
! 	     left, make a special node for it too. */
! 	  ret = true;
! 
! 	  VEC_replace (tree, kv, i, val->value);
  	}
      }
  
    if (info->clone_for_all_contexts)
--- 3284,3320 ----
  	     cgraph_node_name (node), node->uid);
  
    gather_context_independent_values (info, &known_csts, &known_binfos,
! 				     info->clone_for_all_contexts ? &known_aggs
! 				     : NULL, NULL);
  
!   for (i = 0; i < count ;i++)
      {
!       struct ipcp_param_lattices *plats = ipa_get_parm_lattices (info, i);
!       struct ipcp_lattice *lat = &plats->itself;
        struct ipcp_value *val;
  
!       if (!lat->bottom
! 	  && !VEC_index (tree, known_csts, i)
! 	  && !VEC_index (tree, known_binfos, i))
! 	for (val = lat->values; val; val = val->next)
! 	  ret |= decide_about_value (node, i, -1, val, known_csts,
! 				     known_binfos);
  
!       if (!plats->aggs_bottom || !plats->aggs)
  	{
! 	  struct ipcp_agg_lattice *aglat;
! 	  struct ipcp_value *val;
! 	  for (aglat = plats->aggs; aglat; aglat = aglat->next)
! 	    if (!aglat->bottom && aglat->values
! 		/* If the following is false, the one value is in
! 		   known_aggs.  */
! 		&& (plats->aggs_contain_variable
! 		    || !ipa_lat_is_single_const (aglat)))
! 	      for (val = aglat->values; val; val = val->next)
! 		ret |= decide_about_value (node, i, aglat->offset, val,
! 					   known_csts, known_binfos);
  	}
+         info = IPA_NODE_REF (node);
      }
  
    if (info->clone_for_all_contexts)
*************** decide_whether_version_node (struct cgra
*** 2332,2338 ****
  
        callers = collect_callers_of_node (node);
        move_binfos_to_values (known_csts, known_binfos);
!       create_specialized_node (node, known_csts, callers);
        info = IPA_NODE_REF (node);
        info->clone_for_all_contexts = false;
        ret = true;
--- 3328,3336 ----
  
        callers = collect_callers_of_node (node);
        move_binfos_to_values (known_csts, known_binfos);
!       create_specialized_node (node, known_csts,
! 			       known_aggs_to_agg_replacement_list (known_aggs),
! 			       callers);
        info = IPA_NODE_REF (node);
        info->clone_for_all_contexts = false;
        ret = true;
*************** ipcp_driver (void)
*** 2466,2471 ****
--- 3464,3472 ----
  					sizeof (struct ipcp_value), 32);
    ipcp_sources_pool = create_alloc_pool ("IPA-CP value sources",
  					 sizeof (struct ipcp_value_source), 64);
+   ipcp_agg_lattice_pool = create_alloc_pool ("IPA_CP aggregate lattices",
+ 					     sizeof (struct ipcp_agg_lattice),
+ 					     32);
    if (dump_file)
      {
        fprintf (dump_file, "\nIPA structures before propagation:\n");
*************** struct ipa_opt_pass_d pass_ipa_cp =
*** 2560,2569 ****
   ipcp_generate_summary,			/* generate_summary */
   ipcp_write_summary,			/* write_summary */
   ipcp_read_summary,			/* read_summary */
!  NULL,					/* write_optimization_summary */
!  NULL,					/* read_optimization_summary */
   NULL,			 		/* stmt_fixup */
   0,					/* TODOs */
!  NULL,					/* function_transform */
   NULL,					/* variable_transform */
  };
--- 3561,3570 ----
   ipcp_generate_summary,			/* generate_summary */
   ipcp_write_summary,			/* write_summary */
   ipcp_read_summary,			/* read_summary */
!  ipa_prop_write_all_agg_replacement,	/* write_optimization_summary */
!  ipa_prop_read_all_agg_replacement,	/* read_optimization_summary */
   NULL,			 		/* stmt_fixup */
   0,					/* TODOs */
!  ipcp_transform_function,		/* function_transform */
   NULL,					/* variable_transform */
  };
Index: src/gcc/ipa-prop.c
===================================================================
*** src.orig/gcc/ipa-prop.c
--- src/gcc/ipa-prop.c
*************** along with GCC; see the file COPYING3.
*** 40,46 ****
  #include "tree-streamer.h"
  #include "params.h"
  
- 
  /* Intermediate information about a parameter that is only useful during the
     run of ipa_analyze_node and is not kept afterwards.  */
  
--- 40,45 ----
*************** struct param_analysis_info
*** 52,57 ****
--- 51,58 ----
  
  /* Vector where the parameter infos are actually stored. */
  VEC (ipa_node_params_t, heap) *ipa_node_params_vector;
+ /* Vector of known aggregate values in cloned nodes.  */
+ VEC (ipa_agg_replacement_value_p, gc) *ipa_node_agg_replacements;
  /* Vector where the parameter infos are actually stored. */
  VEC (ipa_edge_args_t, gc) *ipa_edge_args_vector;
  
*************** ipa_analyze_params_uses (struct cgraph_n
*** 1936,1941 ****
--- 1937,1958 ----
    info->uses_analysis_done = 1;
  }
  
+ /* Free stuff in PARMS_AINFO, assume there are PARAM_COUNT parameters.  */
+ 
+ static void
+ free_parms_ainfo (struct param_analysis_info *parms_ainfo, int param_count)
+ {
+   int i;
+ 
+   for (i = 0; i < param_count; i++)
+     {
+       if (parms_ainfo[i].parm_visited_statements)
+ 	BITMAP_FREE (parms_ainfo[i].parm_visited_statements);
+       if (parms_ainfo[i].pt_visited_statements)
+ 	BITMAP_FREE (parms_ainfo[i].pt_visited_statements);
+     }
+ }
+ 
  /* Initialize the array describing properties of of formal parameters
     of NODE, analyze their uses and compute jump functions associated
     with actual arguments of calls from within NODE.  */
*************** ipa_analyze_node (struct cgraph_node *no
*** 1945,1951 ****
  {
    struct ipa_node_params *info;
    struct param_analysis_info *parms_ainfo;
!   int i, param_count;
  
    ipa_check_create_node_params ();
    ipa_check_create_edge_args ();
--- 1962,1968 ----
  {
    struct ipa_node_params *info;
    struct param_analysis_info *parms_ainfo;
!   int param_count;
  
    ipa_check_create_node_params ();
    ipa_check_create_edge_args ();
*************** ipa_analyze_node (struct cgraph_node *no
*** 1960,1973 ****
    ipa_analyze_params_uses (node, parms_ainfo);
    ipa_compute_jump_functions (node, parms_ainfo);
  
!   for (i = 0; i < param_count; i++)
!     {
!       if (parms_ainfo[i].parm_visited_statements)
! 	BITMAP_FREE (parms_ainfo[i].parm_visited_statements);
!       if (parms_ainfo[i].pt_visited_statements)
! 	BITMAP_FREE (parms_ainfo[i].pt_visited_statements);
!     }
! 
    pop_cfun ();
  }
  
--- 1977,1983 ----
    ipa_analyze_params_uses (node, parms_ainfo);
    ipa_compute_jump_functions (node, parms_ainfo);
  
!   free_parms_ainfo (parms_ainfo, param_count);
    pop_cfun ();
  }
  
*************** ipa_find_agg_cst_for_param (struct ipa_a
*** 2163,2179 ****
      return NULL;
  
    FOR_EACH_VEC_ELT (ipa_agg_jf_item_t, agg->items, i, item)
!     {
!       if (item->offset == offset)
! 	{
! 	  /* Currently we do not have clobber values, return NULL for them once
! 	     we do.  */
! 	  gcc_checking_assert (is_gimple_ip_invariant (item->value));
! 	  return item->value;
! 	}
!       else if (item->offset > offset)
! 	return NULL;
!     }
    return NULL;
  }
  
--- 2173,2185 ----
      return NULL;
  
    FOR_EACH_VEC_ELT (ipa_agg_jf_item_t, agg->items, i, item)
!     if (item->offset == offset)
!       {
! 	/* Currently we do not have clobber values, return NULL for them once
! 	   we do.  */
! 	gcc_checking_assert (is_gimple_ip_invariant (item->value));
! 	return item->value;
!       }
    return NULL;
  }
  
*************** ipa_free_all_node_params (void)
*** 2436,2441 ****
--- 2442,2462 ----
    ipa_node_params_vector = NULL;
  }
  
+ /* Set the aggregate replacements of NODE to be AGGVALS.  */
+ 
+ void
+ ipa_set_node_agg_value_chain (struct cgraph_node *node,
+ 			      struct ipa_agg_replacement_value *aggvals)
+ {
+   if (VEC_length (ipa_agg_replacement_value_p, ipa_node_agg_replacements)
+       <= (unsigned) cgraph_max_uid)
+     VEC_safe_grow_cleared (ipa_agg_replacement_value_p, gc,
+ 			   ipa_node_agg_replacements, cgraph_max_uid + 1);
+ 
+   VEC_replace (ipa_agg_replacement_value_p, ipa_node_agg_replacements,
+ 	       node->uid, aggvals);
+ }
+ 
  /* Hook that is called by cgraph.c when an edge is removed.  */
  
  static void
*************** ipa_node_removal_hook (struct cgraph_nod
*** 2455,2463 ****
  {
    /* During IPA-CP updating we can be called on not-yet analyze clones.  */
    if (VEC_length (ipa_node_params_t, ipa_node_params_vector)
!       <= (unsigned)node->uid)
!     return;
!   ipa_free_node_params_substructures (IPA_NODE_REF (node));
  }
  
  /* Hook that is called by cgraph.c when an edge is duplicated.  */
--- 2476,2487 ----
  {
    /* During IPA-CP updating we can be called on not-yet analyze clones.  */
    if (VEC_length (ipa_node_params_t, ipa_node_params_vector)
!       > (unsigned)node->uid)
!     ipa_free_node_params_substructures (IPA_NODE_REF (node));
!   if (VEC_length (ipa_agg_replacement_value_p, ipa_node_agg_replacements)
!       > (unsigned)node->uid)
!     VEC_replace (ipa_agg_replacement_value_p, ipa_node_agg_replacements,
! 		 (unsigned)node->uid, NULL);
  }
  
  /* Hook that is called by cgraph.c when an edge is duplicated.  */
*************** ipa_node_duplication_hook (struct cgraph
*** 2491,2496 ****
--- 2515,2521 ----
  			   ATTRIBUTE_UNUSED void *data)
  {
    struct ipa_node_params *old_info, *new_info;
+   struct ipa_agg_replacement_value *old_av, *new_av;
  
    ipa_check_create_node_params ();
    old_info = IPA_NODE_REF (src);
*************** ipa_node_duplication_hook (struct cgraph
*** 2503,2508 ****
--- 2528,2550 ----
  
    new_info->uses_analysis_done = old_info->uses_analysis_done;
    new_info->node_enqueued = old_info->node_enqueued;
+ 
+   old_av = ipa_get_agg_replacements_for_node (src);
+   if (!old_av)
+     return;
+ 
+   new_av = NULL;
+   while (old_av)
+     {
+       struct ipa_agg_replacement_value *v;
+ 
+       v = ggc_alloc_ipa_agg_replacement_value ();
+       memcpy (v, old_av, sizeof (*v));
+       v->next = new_av;
+       new_av = v;
+       old_av = old_av->next;
+     }
+   ipa_set_node_agg_value_chain (dst, new_av);
  }
  
  
*************** ipa_free_all_structures_after_ipa_cp (vo
*** 2564,2569 ****
--- 2606,2612 ----
        ipa_free_all_node_params ();
        free_alloc_pool (ipcp_sources_pool);
        free_alloc_pool (ipcp_values_pool);
+       free_alloc_pool (ipcp_agg_lattice_pool);
        ipa_unregister_cgraph_hooks ();
      }
  }
*************** ipa_free_all_structures_after_iinln (voi
*** 2581,2593 ****
      free_alloc_pool (ipcp_sources_pool);
    if (ipcp_values_pool)
      free_alloc_pool (ipcp_values_pool);
  }
  
  /* Print ipa_tree_map data structures of all functions in the
     callgraph to F.  */
  
  void
! ipa_print_node_params (FILE * f, struct cgraph_node *node)
  {
    int i, count;
    tree temp;
--- 2624,2638 ----
      free_alloc_pool (ipcp_sources_pool);
    if (ipcp_values_pool)
      free_alloc_pool (ipcp_values_pool);
+   if (ipcp_agg_lattice_pool)
+     free_alloc_pool (ipcp_agg_lattice_pool);
  }
  
  /* Print ipa_tree_map data structures of all functions in the
     callgraph to F.  */
  
  void
! ipa_print_node_params (FILE *f, struct cgraph_node *node)
  {
    int i, count;
    tree temp;
*************** ipa_dump_param_adjustments (FILE *file,
*** 3171,3176 ****
--- 3216,3238 ----
    VEC_free (tree, heap, parms);
  }
  
+ /* Dump the AV linked list.  */
+ 
+ void
+ ipa_dump_agg_replacement_values (FILE *f, struct ipa_agg_replacement_value *av)
+ {
+   bool comma = false;
+   fprintf (f, "     Aggregate replacements:");
+   for (; av; av = av->next)
+     {
+       fprintf (f, "%s %i[" HOST_WIDE_INT_PRINT_DEC "]=", comma ? "," : "",
+ 	       av->index, av->offset);
+       print_generic_expr (f, av->value, 0);
+       comma = true;
+     }
+   fprintf (f, "\n");
+ }
+ 
  /* Stream out jump function JUMP_FUNC to OB.  */
  
  static void
*************** ipa_update_after_lto_read (void)
*** 3550,3552 ****
--- 3612,3938 ----
      if (node->analyzed)
        ipa_initialize_node_params (node);
  }
+ 
+ void
+ write_agg_replacement_chain (struct output_block *ob, struct cgraph_node *node)
+ {
+   int node_ref;
+   unsigned int count = 0;
+   lto_symtab_encoder_t encoder;
+   struct ipa_agg_replacement_value *aggvals, *av;
+ 
+   aggvals = ipa_get_agg_replacements_for_node (node);
+   encoder = ob->decl_state->symtab_node_encoder;
+   node_ref = lto_symtab_encoder_encode (encoder, (symtab_node) node);
+   streamer_write_uhwi (ob, node_ref);
+ 
+   for (av = aggvals; av; av = av->next)
+     count++;
+   streamer_write_uhwi (ob, count);
+ 
+   for (av = aggvals; av; av = av->next)
+     {
+       streamer_write_uhwi (ob, av->offset);
+       streamer_write_uhwi (ob, av->index);
+       stream_write_tree (ob, av->value, true);
+     }
+ }
+ 
+ /* Stream in the aggregate value replacement chain for NODE from IB.  */
+ 
+ static void
+ read_agg_replacement_chain (struct lto_input_block *ib,
+ 			    struct cgraph_node *node,
+ 			    struct data_in *data_in)
+ {
+   struct ipa_agg_replacement_value *aggvals = NULL;
+   unsigned int count, i;
+ 
+   count = streamer_read_uhwi (ib);
+   for (i = 0; i <count; i++)
+     {
+       struct ipa_agg_replacement_value *av;
+ 
+       av = ggc_alloc_ipa_agg_replacement_value ();
+       av->offset = streamer_read_uhwi (ib);
+       av->index = streamer_read_uhwi (ib);
+       av->value = stream_read_tree (ib, data_in);
+       av->next = aggvals;
+       aggvals = av;
+     }
+   ipa_set_node_agg_value_chain (node, aggvals);
+ }
+ 
+ /* Write all aggregate replacement for nodes in set.  */
+ 
+ void
+ ipa_prop_write_all_agg_replacement (void)
+ {
+   struct cgraph_node *node;
+   struct output_block *ob;
+   unsigned int count = 0;
+   lto_symtab_encoder_iterator lsei;
+   lto_symtab_encoder_t encoder;
+ 
+   if (!ipa_node_agg_replacements)
+     return;
+ 
+   ob = create_output_block (LTO_section_ipcp_transform);
+   encoder = ob->decl_state->symtab_node_encoder;
+   ob->cgraph_node = NULL;
+   for (lsei = lsei_start_function_in_partition (encoder); !lsei_end_p (lsei);
+        lsei_next_function_in_partition (&lsei))
+     {
+       node = lsei_cgraph_node (lsei);
+       if (cgraph_function_with_gimple_body_p (node)
+ 	  && ipa_get_agg_replacements_for_node (node) != NULL)
+ 	count++;
+     }
+ 
+   streamer_write_uhwi (ob, count);
+ 
+   for (lsei = lsei_start_function_in_partition (encoder); !lsei_end_p (lsei);
+        lsei_next_function_in_partition (&lsei))
+     {
+       node = lsei_cgraph_node (lsei);
+       if (cgraph_function_with_gimple_body_p (node)
+ 	  && ipa_get_agg_replacements_for_node (node) != NULL)
+ 	write_agg_replacement_chain (ob, node);
+     }
+   streamer_write_char_stream (ob->main_stream, 0);
+   produce_asm (ob, NULL);
+   destroy_output_block (ob);
+ }
+ 
+ /* Read replacements section in file FILE_DATA of length LEN with data
+    DATA.  */
+ 
+ static void
+ read_replacements_section (struct lto_file_decl_data *file_data,
+ 			   const char *data,
+ 			   size_t len)
+ {
+   const struct lto_function_header *header =
+     (const struct lto_function_header *) data;
+   const int cfg_offset = sizeof (struct lto_function_header);
+   const int main_offset = cfg_offset + header->cfg_size;
+   const int string_offset = main_offset + header->main_size;
+   struct data_in *data_in;
+   struct lto_input_block ib_main;
+   unsigned int i;
+   unsigned int count;
+ 
+   LTO_INIT_INPUT_BLOCK (ib_main, (const char *) data + main_offset, 0,
+ 			header->main_size);
+ 
+   data_in = lto_data_in_create (file_data, (const char *) data + string_offset,
+ 				header->string_size, NULL);
+   count = streamer_read_uhwi (&ib_main);
+ 
+   for (i = 0; i < count; i++)
+     {
+       unsigned int index;
+       struct cgraph_node *node;
+       lto_symtab_encoder_t encoder;
+ 
+       index = streamer_read_uhwi (&ib_main);
+       encoder = file_data->symtab_node_encoder;
+       node = cgraph (lto_symtab_encoder_deref (encoder, index));
+       gcc_assert (node->analyzed);
+       read_agg_replacement_chain (&ib_main, node, data_in);
+     }
+   lto_free_section_data (file_data, LTO_section_jump_functions, NULL, data,
+ 			 len);
+   lto_data_in_delete (data_in);
+ }
+ 
+ /* Read IPA-CP aggregate replacements.  */
+ 
+ void
+ ipa_prop_read_all_agg_replacement (void)
+ {
+   struct lto_file_decl_data **file_data_vec = lto_get_file_decl_data ();
+   struct lto_file_decl_data *file_data;
+   unsigned int j = 0;
+ 
+   while ((file_data = file_data_vec[j++]))
+     {
+       size_t len;
+       const char *data = lto_get_section_data (file_data,
+ 					       LTO_section_ipcp_transform,
+ 					       NULL, &len);
+       if (data)
+         read_replacements_section (file_data, data, len);
+     }
+ }
+ 
+ /* Adjust the aggregate replacements in AGGVAL to reflect parameters skipped in
+    NODE.  */
+ 
+ static void
+ adjust_agg_replacement_values (struct cgraph_node *node,
+ 			       struct ipa_agg_replacement_value *aggval)
+ {
+   struct ipa_agg_replacement_value *v;
+   int i, c = 0, d = 0, *adj;
+ 
+   if (!node->clone.combined_args_to_skip)
+     return;
+ 
+   for (v = aggval; v; v = v->next)
+     {
+       gcc_assert (v->index >= 0);
+       if (c < v->index)
+ 	c = v->index;
+     }
+   c++;
+ 
+   adj = XALLOCAVEC (int, c);
+   for (i = 0; i < c; i++)
+     if (bitmap_bit_p (node->clone.combined_args_to_skip, i))
+       {
+ 	adj[i] = -1;
+ 	d++;
+       }
+     else
+       adj[i] = i - d;
+ 
+   for (v = aggval; v; v = v->next)
+     v->index = adj[v->index];
+ }
+ 
+ 
+ /* Function body transformation phase.  */
+ 
+ unsigned int
+ ipcp_transform_function (struct cgraph_node *node)
+ {
+   VEC (ipa_param_descriptor_t, heap) *descriptors = NULL;
+   struct param_analysis_info *parms_ainfo;
+   struct ipa_agg_replacement_value *aggval;
+   gimple_stmt_iterator gsi;
+   basic_block bb;
+   int param_count;
+   bool cfg_changed = false, something_changed = false;
+ 
+   gcc_checking_assert (cfun);
+   gcc_checking_assert (current_function_decl);
+ 
+   if (dump_file)
+     fprintf (dump_file, "Modification phase of node %s/%i\n",
+ 	     cgraph_node_name (node), node->uid);
+ 
+   aggval = ipa_get_agg_replacements_for_node (node);
+   if (!aggval)
+       return 0;
+   param_count = count_formal_params (node->symbol.decl);
+   if (param_count == 0)
+     return 0;
+   adjust_agg_replacement_values (node, aggval);
+   if (dump_file)
+     ipa_dump_agg_replacement_values (dump_file, aggval);
+   parms_ainfo = XALLOCAVEC (struct param_analysis_info, param_count);
+   memset (parms_ainfo, 0, sizeof (struct param_analysis_info) * param_count);
+   VEC_safe_grow_cleared (ipa_param_descriptor_t, heap,
+ 			 descriptors, param_count);
+   ipa_populate_param_decls (node, descriptors);
+ 
+   FOR_EACH_BB (bb)
+     for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+       {
+ 	struct ipa_agg_replacement_value *v;
+ 	gimple stmt = gsi_stmt (gsi);
+ 	tree rhs, val, t;
+ 	HOST_WIDE_INT offset;
+ 	int index;
+ 	bool by_ref, vce;
+ 
+ 	if (!gimple_assign_load_p (stmt))
+ 	  continue;
+ 	rhs = gimple_assign_rhs1 (stmt);
+ 	if (!is_gimple_reg_type (TREE_TYPE (rhs)))
+ 	  continue;
+ 
+ 	vce = false;
+ 	t = rhs;
+ 	while (handled_component_p (t))
+ 	  {
+ 	    /* V_C_E can do things like convert an array of integers to one
+                bigger integer and similar things we do not handle below.  */
+             if (TREE_CODE (rhs) == VIEW_CONVERT_EXPR)
+ 	      {
+ 		vce = true;
+ 		break;
+ 	      }
+ 	    t = TREE_OPERAND (t, 0);
+ 	  }
+ 	if (vce)
+ 	  continue;
+ 
+ 	if (!ipa_load_from_parm_agg_1 (descriptors, parms_ainfo, stmt,
+ 				       rhs, &index, &offset, &by_ref))
+ 	  continue;
+ 	for (v = aggval; v; v = v->next)
+ 	  if (v->index == index
+ 	      && v->offset == offset)
+ 	    break;
+ 	if (!v)
+ 	  continue;
+ 
+ 	gcc_checking_assert (is_gimple_ip_invariant (v->value));
+ 	if (!useless_type_conversion_p (TREE_TYPE (rhs), TREE_TYPE (v->value)))
+ 	  {
+ 	    if (fold_convertible_p (TREE_TYPE (rhs), v->value))
+ 	      val = fold_build1 (NOP_EXPR, TREE_TYPE (rhs), v->value);
+ 	    else if (TYPE_SIZE (TREE_TYPE (rhs))
+ 		     == TYPE_SIZE (TREE_TYPE (v->value)))
+ 	      val = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (rhs), v->value);
+ 	    else
+ 	      {
+ 		if (dump_file)
+ 		  {
+ 		    fprintf (dump_file, "    const ");
+ 		    print_generic_expr (dump_file, v->value, 0);
+ 		    fprintf (dump_file, "  can't be converted to type of ");
+ 		    print_generic_expr (dump_file, rhs, 0);
+ 		    fprintf (dump_file, "\n");
+ 		  }
+ 		continue;
+ 	      }
+ 	  }
+ 	else
+ 	  val = v->value;
+ 
+ 	if (dump_file && (dump_flags & TDF_DETAILS))
+ 	  {
+ 	    fprintf (dump_file, "Modifying stmt:\n  ");
+ 	    print_gimple_stmt (dump_file, stmt, 0, 0);
+ 	  }
+ 	gimple_assign_set_rhs_from_tree (&gsi, val);
+ 	update_stmt (stmt);
+ 
+ 	if (dump_file && (dump_flags & TDF_DETAILS))
+ 	  {
+ 	    fprintf (dump_file, "into:\n  ");
+ 	    print_gimple_stmt (dump_file, stmt, 0, 0);
+ 	    fprintf (dump_file, "\n");
+ 	  }
+ 
+ 	something_changed = true;
+ 	if (maybe_clean_eh_stmt (stmt)
+ 	    && gimple_purge_dead_eh_edges (gimple_bb (stmt)))
+ 	  cfg_changed = true;
+       }
+ 
+   VEC_replace (ipa_agg_replacement_value_p, ipa_node_agg_replacements,
+ 	       node->uid, NULL);
+   free_parms_ainfo (parms_ainfo, param_count);
+   VEC_free (ipa_param_descriptor_t, heap, descriptors);
+ 
+   if (!something_changed)
+     return 0;
+   else if (cfg_changed)
+     return TODO_update_ssa_only_virtuals | TODO_cleanup_cfg;
+   else
+     return TODO_update_ssa_only_virtuals;
+ }
Index: src/gcc/ipa-prop.h
===================================================================
*** src.orig/gcc/ipa-prop.h
--- src/gcc/ipa-prop.h
*************** typedef struct GTY(()) ipa_agg_jf_item
*** 144,149 ****
--- 144,150 ----
  
  DEF_VEC_O (ipa_agg_jf_item_t);
  DEF_VEC_ALLOC_O (ipa_agg_jf_item_t, gc);
+ DEF_VEC_ALLOC_O (ipa_agg_jf_item_t, heap);
  
  /* Aggregate jump function - i.e. description of contents of aggregates passed
     either by reference or value.  */
*************** struct GTY(()) ipa_agg_jump_function
*** 159,164 ****
--- 160,168 ----
  typedef struct ipa_agg_jump_function *ipa_agg_jump_function_p;
  DEF_VEC_P (ipa_agg_jump_function_p);
  DEF_VEC_ALLOC_P (ipa_agg_jump_function_p, heap);
+ typedef struct ipa_agg_jump_function ipa_agg_jump_function_t;
+ DEF_VEC_P (ipa_agg_jump_function_t);
+ DEF_VEC_ALLOC_P (ipa_agg_jump_function_t, heap);
  
  /* A jump function for a callsite represents the values passed as actual
     arguments of the callsite. See enum jump_func_type for the various
*************** struct ipa_node_params
*** 322,328 ****
    VEC (ipa_param_descriptor_t, heap) *descriptors;
    /* Pointer to an array of structures describing individual formal
       parameters.  */
!   struct ipcp_lattice *lattices;
    /* Only for versioned nodes this field would not be NULL,
       it points to the node that IPA cp cloned from.  */
    struct cgraph_node *ipcp_orig_node;
--- 326,332 ----
    VEC (ipa_param_descriptor_t, heap) *descriptors;
    /* Pointer to an array of structures describing individual formal
       parameters.  */
!   struct ipcp_param_lattices *lattices;
    /* Only for versioned nodes this field would not be NULL,
       it points to the node that IPA cp cloned from.  */
    struct cgraph_node *ipcp_orig_node;
*************** ipa_is_param_used (struct ipa_node_param
*** 380,385 ****
--- 384,410 ----
    return VEC_index (ipa_param_descriptor_t, info->descriptors, i).used;
  }
  
+ /* Information about replacements done in aggregates for a given node (each
+    node has its linked list).  */
+ struct GTY(()) ipa_agg_replacement_value
+ {
+   /* Next item in the linked list.  */
+   struct ipa_agg_replacement_value *next;
+   /* Offset within the aggregate.  */
+   HOST_WIDE_INT offset;
+   /* The constant value.  */
+   tree value;
+   /* The paramter index.  */
+   int index;
+ };
+ 
+ typedef struct ipa_agg_replacement_value *ipa_agg_replacement_value_p;
+ DEF_VEC_P (ipa_agg_replacement_value_p);
+ DEF_VEC_ALLOC_P (ipa_agg_replacement_value_p, gc);
+ 
+ void ipa_set_node_agg_value_chain (struct cgraph_node *node,
+ 				   struct ipa_agg_replacement_value *aggvals);
+ 
  /* ipa_edge_args stores information related to a callsite and particularly its
     arguments.  It can be accessed by the IPA_EDGE_REF macro.  */
  typedef struct GTY(()) ipa_edge_args
*************** DEF_VEC_ALLOC_O (ipa_edge_args_t, gc);
*** 420,425 ****
--- 445,452 ----
  
  /* Vector where the parameter infos are actually stored. */
  extern VEC (ipa_node_params_t, heap) *ipa_node_params_vector;
+ /* Vector of known aggregate values in cloned nodes.  */
+ extern GTY(()) VEC (ipa_agg_replacement_value_p, gc) *ipa_node_agg_replacements;
  /* Vector where the parameter infos are actually stored. */
  extern GTY(()) VEC (ipa_edge_args_t, gc) *ipa_edge_args_vector;
  
*************** ipa_edge_args_info_available_for_edge_p
*** 487,492 ****
--- 514,531 ----
  					     ipa_edge_args_vector));
  }
  
+ /* Return the aggregate replacements for NODE, if there are any.  */
+ 
+ static inline struct ipa_agg_replacement_value *
+ ipa_get_agg_replacements_for_node (struct cgraph_node *node)
+ {
+   if ((unsigned) node->uid >= VEC_length (ipa_agg_replacement_value_p,
+ 					  ipa_node_agg_replacements))
+     return NULL;
+   return VEC_index (ipa_agg_replacement_value_p, ipa_node_agg_replacements,
+ 		    node->uid);
+ }
+ 
  /* Function formal parameters related computations.  */
  void ipa_initialize_node_params (struct cgraph_node *node);
  bool ipa_propagate_indirect_call_infos (struct cgraph_edge *cs,
*************** void ipcp_verify_propagated_values (void
*** 517,522 ****
--- 556,562 ----
  
  extern alloc_pool ipcp_values_pool;
  extern alloc_pool ipcp_sources_pool;
+ extern alloc_pool ipcp_agg_lattice_pool;
  
  /* Structure to describe transformations of formal parameters and actual
     arguments.  Each instance describes one new parameter and they are meant to
*************** void ipa_modify_call_arguments (struct c
*** 589,601 ****
  ipa_parm_adjustment_vec ipa_combine_adjustments (ipa_parm_adjustment_vec,
  						 ipa_parm_adjustment_vec);
  void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree);
! 
  void ipa_prop_write_jump_functions (void);
  void ipa_prop_read_jump_functions (void);
  void ipa_update_after_lto_read (void);
  int ipa_get_param_decl_index (struct ipa_node_params *, tree);
  tree ipa_value_from_jfunc (struct ipa_node_params *info,
  			   struct ipa_jump_func *jfunc);
  
  
  /* From tree-sra.c:  */
--- 629,645 ----
  ipa_parm_adjustment_vec ipa_combine_adjustments (ipa_parm_adjustment_vec,
  						 ipa_parm_adjustment_vec);
  void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree);
! void ipa_dump_agg_replacement_values (FILE *f,
! 				      struct ipa_agg_replacement_value *av);
  void ipa_prop_write_jump_functions (void);
  void ipa_prop_read_jump_functions (void);
+ void ipa_prop_write_all_agg_replacement (void);
+ void ipa_prop_read_all_agg_replacement (void);
  void ipa_update_after_lto_read (void);
  int ipa_get_param_decl_index (struct ipa_node_params *, tree);
  tree ipa_value_from_jfunc (struct ipa_node_params *info,
  			   struct ipa_jump_func *jfunc);
+ unsigned int ipcp_transform_function (struct cgraph_node *node);
  
  
  /* From tree-sra.c:  */
Index: src/gcc/ipa-inline-analysis.c
===================================================================
*** src.orig/gcc/ipa-inline-analysis.c
--- src/gcc/ipa-inline-analysis.c
*************** estimate_node_size_and_time (struct cgra
*** 2902,2917 ****
  
  void
  estimate_ipcp_clone_size_and_time (struct cgraph_node *node,
! 				   VEC (tree, heap) *known_vals,
! 				   VEC (tree, heap) *known_binfos,
! 		                   int *ret_size, int *ret_time)
  {
    clause_t clause;
  
!   clause = evaluate_conditions_for_known_args (node, false, known_vals, NULL);
!   estimate_node_size_and_time (node, clause, known_vals, known_binfos, NULL,
! 			       ret_size, ret_time, NULL,
! 			       NULL);
  }
  
  /* Translate all conditions from callee representation into caller
--- 2902,2919 ----
  
  void
  estimate_ipcp_clone_size_and_time (struct cgraph_node *node,
! 				VEC (tree, heap) *known_vals,
! 				VEC (tree, heap) *known_binfos,
! 				VEC (ipa_agg_jump_function_p, heap) *known_aggs,
! 				int *ret_size, int *ret_time,
! 				inline_hints *hints)
  {
    clause_t clause;
  
!   clause = evaluate_conditions_for_known_args (node, false, known_vals,
! 					       known_aggs);
!   estimate_node_size_and_time (node, clause, known_vals, known_binfos,
! 			       known_aggs, ret_size, ret_time, hints, NULL);
  }
  
  /* Translate all conditions from callee representation into caller
Index: src/gcc/ipa-inline.h
===================================================================
*** src.orig/gcc/ipa-inline.h
--- src/gcc/ipa-inline.h
*************** You should have received a copy of the G
*** 19,24 ****
--- 19,26 ----
  along with GCC; see the file COPYING3.  If not see
  <http://www.gnu.org/licenses/>.  */
  
+ #include "ipa-prop.h"
+ 
  /* Representation of inline parameters that do depend on context function is
     inlined into (i.e. known constant values of function parameters.
  
*************** void initialize_inline_failed (struct cg
*** 207,215 ****
  int estimate_time_after_inlining (struct cgraph_node *, struct cgraph_edge *);
  int estimate_size_after_inlining (struct cgraph_node *, struct cgraph_edge *);
  void estimate_ipcp_clone_size_and_time (struct cgraph_node *,
! 					VEC (tree, heap) *known_vals,
! 					VEC (tree, heap) *known_binfos,
! 					int *, int *);
  int do_estimate_growth (struct cgraph_node *);
  void inline_merge_summary (struct cgraph_edge *edge);
  void inline_update_overall_summary (struct cgraph_node *node);
--- 209,217 ----
  int estimate_time_after_inlining (struct cgraph_node *, struct cgraph_edge *);
  int estimate_size_after_inlining (struct cgraph_node *, struct cgraph_edge *);
  void estimate_ipcp_clone_size_and_time (struct cgraph_node *,
! 					VEC (tree, heap) *, VEC (tree, heap) *,
! 					VEC (ipa_agg_jump_function_p, heap) *,
! 					int *, int *, inline_hints *);
  int do_estimate_growth (struct cgraph_node *);
  void inline_merge_summary (struct cgraph_edge *edge);
  void inline_update_overall_summary (struct cgraph_node *node);
Index: src/gcc/lto-streamer.h
===================================================================
*** src.orig/gcc/lto-streamer.h
--- src/gcc/lto-streamer.h
*************** enum lto_section_type
*** 248,253 ****
--- 248,254 ----
    LTO_section_opts,
    LTO_section_cgraph_opt_sum,
    LTO_section_inline_summary,
+   LTO_section_ipcp_transform,
    LTO_N_SECTION_TYPES		/* Must be last.  */
  };
  
Index: src/gcc/lto-section-in.c
===================================================================
*** src.orig/gcc/lto-section-in.c
--- src/gcc/lto-section-in.c
*************** const char *lto_section_name[LTO_N_SECTI
*** 58,64 ****
    "symbol_nodes",
    "opts",
    "cgraphopt",
!   "inline"
  };
  
  
--- 58,65 ----
    "symbol_nodes",
    "opts",
    "cgraphopt",
!   "inline",
!   "ipcp_trans"
  };
  
  
Index: src/gcc/testsuite/gcc.dg/ipa/ipa-5.c
===================================================================
*** src.orig/gcc/testsuite/gcc.dg/ipa/ipa-5.c
--- src/gcc/testsuite/gcc.dg/ipa/ipa-5.c
***************
*** 5,11 ****
  /* Float & short constants.  */
  
  #include <stdio.h>
! void t(void);
  int g (float b, short c)
  {
    t();
--- 5,11 ----
  /* Float & short constants.  */
  
  #include <stdio.h>
! int t(void);
  int g (float b, short c)
  {
    t();
*************** int g (float b, short c)
*** 13,22 ****
  }
  int f (float a)
  {
!   t();
    /* a is modified.  */
    if (a++ > 0)
!     g (a, 3);
  }
  int main ()
  {
--- 13,23 ----
  }
  int f (float a)
  {
!   int i, j = t();
    /* a is modified.  */
    if (a++ > 0)
!     for (i = 0; i < j; i++)
!       g (a, 3);
  }
  int main ()
  {
*************** int main ()
*** 26,32 ****
    return 0;
  }
  
! /* { dg-final { scan-ipa-dump-times "Creating a specialized node" 2 "cp"  } } */
  /* { dg-final { scan-ipa-dump "replacing param c with const 3" "cp"  } } */
  /* { dg-final { scan-ipa-dump "replacing param a with const 7" "cp"  } } */
  /* { dg-final { cleanup-ipa-dump "cp" } } */
--- 27,33 ----
    return 0;
  }
  
! /* { dg-final { scan-ipa-dump-times "Creating a specialized node" 3 "cp"  } } */
  /* { dg-final { scan-ipa-dump "replacing param c with const 3" "cp"  } } */
  /* { dg-final { scan-ipa-dump "replacing param a with const 7" "cp"  } } */
  /* { dg-final { cleanup-ipa-dump "cp" } } */
Index: src/gcc/params.def
===================================================================
*** src.orig/gcc/params.def
--- src/gcc/params.def
*************** DEFPARAM (PARAM_IPA_MAX_AGG_ITEMS,
*** 896,901 ****
--- 896,907 ----
  	  "jump functions and lattices",
  	  16, 0, 0)
  
+ DEFPARAM (PARAM_IPA_CP_LOOP_HINT_BONUS,
+ 	  "ipa-cp-loop-hint-bonus",
+ 	  "Compile-time bonus IPA-CP assigns to candidates which make loop "
+ 	  "bounds or strides known.",
+ 	  64, 0, 0)
+ 
  /* WHOPR partitioning configuration.  */
  
  DEFPARAM (PARAM_LTO_PARTITIONS,
Index: src/gcc/Makefile.in
===================================================================
*** src.orig/gcc/Makefile.in
--- src/gcc/Makefile.in
*************** TREE_STREAMER_H = tree-streamer.h $(TREE
*** 953,958 ****
--- 953,959 ----
  STREAMER_HOOKS_H = streamer-hooks.h $(TREE_H)
  TREE_VECTORIZER_H = tree-vectorizer.h $(TREE_DATA_REF_H) $(TARGET_H)
  IPA_PROP_H = ipa-prop.h $(TREE_H) $(VEC_H) $(CGRAPH_H) $(GIMPLE_H) alloc-pool.h
+ IPA_INLINE_H = ipa-inline.h $(IPA_PROP_H)
  GSTAB_H = gstab.h stab.def
  BITMAP_H = bitmap.h $(HASHTAB_H) statistics.h
  GCC_PLUGIN_H = gcc-plugin.h highlev-plugin-common.h plugin.def \
*************** cgraph.o : cgraph.c $(CONFIG_H) $(SYSTEM
*** 2834,2847 ****
     gt-cgraph.h intl.h $(BASIC_BLOCK_H) debug.h $(HASHTAB_H) \
     $(TREE_INLINE_H) $(TREE_FLOW_H) cif-code.def \
     value-prof.h $(EXCEPT_H) $(IPA_UTILS_H) $(DIAGNOSTIC_CORE_H) \
!    ipa-inline.h $(LTO_STREAMER_H) $(CFGLOOP_H) $(GIMPLE_PRETTY_PRINT_H)
  cgraphunit.o : cgraphunit.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(TREE_H) langhooks.h $(TREE_INLINE_H) toplev.h $(DIAGNOSTIC_CORE_H) $(FLAGS_H) $(GGC_H) \
     $(TARGET_H) $(CGRAPH_H) intl.h pointer-set.h $(FUNCTION_H) $(GIMPLE_H) \
     $(TREE_FLOW_H) $(TREE_PASS_H) debug.h $(DIAGNOSTIC_H) \
     $(FIBHEAP_H) output.h $(PARAMS_H) $(RTL_H) $(IPA_PROP_H) \
     gt-cgraphunit.h tree-iterator.h $(COVERAGE_H) $(TREE_DUMP_H) \
!    $(GIMPLE_PRETTY_PRINT_H) ipa-inline.h $(IPA_UTILS_H) \
     $(LTO_STREAMER_H) output.h $(REGSET_H) $(EXCEPT_H) $(GCC_PLUGIN_H) plugin.h
  cgraphclones.o : cgraphclones.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(TREE_H) langhooks.h $(TREE_INLINE_H) toplev.h $(DIAGNOSTIC_CORE_H) $(FLAGS_H) $(GGC_H) \
--- 2835,2848 ----
     gt-cgraph.h intl.h $(BASIC_BLOCK_H) debug.h $(HASHTAB_H) \
     $(TREE_INLINE_H) $(TREE_FLOW_H) cif-code.def \
     value-prof.h $(EXCEPT_H) $(IPA_UTILS_H) $(DIAGNOSTIC_CORE_H) \
!    $(IPA_INLINE_H) $(LTO_STREAMER_H) $(CFGLOOP_H) $(GIMPLE_PRETTY_PRINT_H)
  cgraphunit.o : cgraphunit.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(TREE_H) langhooks.h $(TREE_INLINE_H) toplev.h $(DIAGNOSTIC_CORE_H) $(FLAGS_H) $(GGC_H) \
     $(TARGET_H) $(CGRAPH_H) intl.h pointer-set.h $(FUNCTION_H) $(GIMPLE_H) \
     $(TREE_FLOW_H) $(TREE_PASS_H) debug.h $(DIAGNOSTIC_H) \
     $(FIBHEAP_H) output.h $(PARAMS_H) $(RTL_H) $(IPA_PROP_H) \
     gt-cgraphunit.h tree-iterator.h $(COVERAGE_H) $(TREE_DUMP_H) \
!    $(GIMPLE_PRETTY_PRINT_H) $(IPA_INLINE_H) $(IPA_UTILS_H) \
     $(LTO_STREAMER_H) output.h $(REGSET_H) $(EXCEPT_H) $(GCC_PLUGIN_H) plugin.h
  cgraphclones.o : cgraphclones.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(TREE_H) langhooks.h $(TREE_INLINE_H) toplev.h $(DIAGNOSTIC_CORE_H) $(FLAGS_H) $(GGC_H) \
*************** cgraphclones.o : cgraphclones.c $(CONFIG
*** 2849,2860 ****
     $(TREE_FLOW_H) $(TREE_PASS_H) debug.h $(DIAGNOSTIC_H) $(TREE_DUMP_H) \
     $(PARAMS_H) $(RTL_H) $(IPA_PROP_H) \
     tree-iterator.h $(COVERAGE_H) \
!    $(GIMPLE_PRETTY_PRINT_H) ipa-inline.h $(IPA_UTILS_H) \
     $(LTO_STREAMER_H) $(EXCEPT_H) $(GCC_PLUGIN_H) gt-cgraphclones.h
  cgraphbuild.o : cgraphbuild.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(TREE_H) langhooks.h $(CGRAPH_H) intl.h pointer-set.h $(GIMPLE_H) \
     $(TREE_FLOW_H) $(TREE_PASS_H) $(IPA_UTILS_H) $(EXCEPT_H) \
!    ipa-inline.h
  varpool.o : varpool.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(TREE_H) $(CGRAPH_H) langhooks.h $(DIAGNOSTIC_CORE_H) $(HASHTAB_H) \
     $(GGC_H) $(TIMEVAR_H) debug.h $(TARGET_H) output.h $(GIMPLE_H) \
--- 2850,2861 ----
     $(TREE_FLOW_H) $(TREE_PASS_H) debug.h $(DIAGNOSTIC_H) $(TREE_DUMP_H) \
     $(PARAMS_H) $(RTL_H) $(IPA_PROP_H) \
     tree-iterator.h $(COVERAGE_H) \
!    $(GIMPLE_PRETTY_PRINT_H) $(IPA_INLINE_H) $(IPA_UTILS_H) \
     $(LTO_STREAMER_H) $(EXCEPT_H) $(GCC_PLUGIN_H) gt-cgraphclones.h
  cgraphbuild.o : cgraphbuild.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(TREE_H) langhooks.h $(CGRAPH_H) intl.h pointer-set.h $(GIMPLE_H) \
     $(TREE_FLOW_H) $(TREE_PASS_H) $(IPA_UTILS_H) $(EXCEPT_H) \
!    $(IPA_INLINE_H)
  varpool.o : varpool.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(TREE_H) $(CGRAPH_H) langhooks.h $(DIAGNOSTIC_CORE_H) $(HASHTAB_H) \
     $(GGC_H) $(TIMEVAR_H) debug.h $(TARGET_H) output.h $(GIMPLE_H) \
*************** ipa-ref.o : ipa-ref.c $(CONFIG_H) $(SYST
*** 2874,2894 ****
  ipa-cp.o : ipa-cp.c $(CONFIG_H) $(SYSTEM_H) coretypes.h  \
     $(TREE_H) $(TARGET_H) $(GIMPLE_H) $(CGRAPH_H) $(IPA_PROP_H) $(TREE_FLOW_H) \
     $(TREE_PASS_H) $(FLAGS_H) $(DIAGNOSTIC_H) \
!    $(TREE_INLINE_H) $(PARAMS_H) $(TREE_PRETTY_PRINT_H) ipa-inline.h
  ipa-split.o : ipa-split.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
     $(TREE_H) $(TARGET_H) $(CGRAPH_H) $(IPA_PROP_H) $(TREE_FLOW_H) \
     $(TREE_PASS_H) $(FLAGS_H) $(DIAGNOSTIC_H) $(TREE_DUMP_H) \
!    $(TREE_INLINE_H) $(PARAMS_H) $(GIMPLE_PRETTY_PRINT_H) ipa-inline.h
  ipa-inline.o : ipa-inline.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(TREE_H) langhooks.h $(TREE_INLINE_H) $(FLAGS_H) $(CGRAPH_H) intl.h \
     $(DIAGNOSTIC_H) $(FIBHEAP_H) $(PARAMS_H) $(TREE_PASS_H) \
     $(COVERAGE_H) $(GGC_H) $(TREE_FLOW_H) $(RTL_H) $(IPA_PROP_H) \
!    $(EXCEPT_H) $(GIMPLE_PRETTY_PRINT_H) ipa-inline.h $(TARGET_H) $(IPA_UTILS_H)
  ipa-inline-analysis.o : ipa-inline-analysis.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(TREE_H) langhooks.h $(TREE_INLINE_H) $(FLAGS_H) $(CGRAPH_H) intl.h \
     $(DIAGNOSTIC_H) $(PARAMS_H) $(TREE_PASS_H) $(CFGLOOP_H) \
     $(HASHTAB_H) $(COVERAGE_H) $(GGC_H) $(TREE_FLOW_H) $(IPA_PROP_H) \
!    $(GIMPLE_PRETTY_PRINT_H) ipa-inline.h $(LTO_STREAMER_H) $(DATA_STREAMER_H) \
     $(TREE_STREAMER_H)
  ipa-inline-transform.o : ipa-inline-transform.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(TREE_H) langhooks.h $(TREE_INLINE_H) $(FLAGS_H) $(CGRAPH_H) intl.h \
--- 2875,2896 ----
  ipa-cp.o : ipa-cp.c $(CONFIG_H) $(SYSTEM_H) coretypes.h  \
     $(TREE_H) $(TARGET_H) $(GIMPLE_H) $(CGRAPH_H) $(IPA_PROP_H) $(TREE_FLOW_H) \
     $(TREE_PASS_H) $(FLAGS_H) $(DIAGNOSTIC_H) \
!    $(TREE_INLINE_H) $(PARAMS_H) $(TREE_PRETTY_PRINT_H) $(IPA_INLINE_H)
  ipa-split.o : ipa-split.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
     $(TREE_H) $(TARGET_H) $(CGRAPH_H) $(IPA_PROP_H) $(TREE_FLOW_H) \
     $(TREE_PASS_H) $(FLAGS_H) $(DIAGNOSTIC_H) $(TREE_DUMP_H) \
!    $(TREE_INLINE_H) $(PARAMS_H) $(GIMPLE_PRETTY_PRINT_H) $(IPA_INLINE_H)
  ipa-inline.o : ipa-inline.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(TREE_H) langhooks.h $(TREE_INLINE_H) $(FLAGS_H) $(CGRAPH_H) intl.h \
     $(DIAGNOSTIC_H) $(FIBHEAP_H) $(PARAMS_H) $(TREE_PASS_H) \
     $(COVERAGE_H) $(GGC_H) $(TREE_FLOW_H) $(RTL_H) $(IPA_PROP_H) \
!    $(EXCEPT_H) $(GIMPLE_PRETTY_PRINT_H) $(IPA_INLINE_H) $(TARGET_H) \
!    $(IPA_UTILS_H)
  ipa-inline-analysis.o : ipa-inline-analysis.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(TREE_H) langhooks.h $(TREE_INLINE_H) $(FLAGS_H) $(CGRAPH_H) intl.h \
     $(DIAGNOSTIC_H) $(PARAMS_H) $(TREE_PASS_H) $(CFGLOOP_H) \
     $(HASHTAB_H) $(COVERAGE_H) $(GGC_H) $(TREE_FLOW_H) $(IPA_PROP_H) \
!    $(GIMPLE_PRETTY_PRINT_H) $(IPA_INLINE_H) $(LTO_STREAMER_H) $(DATA_STREAMER_H) \
     $(TREE_STREAMER_H)
  ipa-inline-transform.o : ipa-inline-transform.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(TREE_H) langhooks.h $(TREE_INLINE_H) $(FLAGS_H) $(CGRAPH_H) intl.h \
Index: src/gcc/testsuite/gcc.dg/ipa/ipcp-agg-1.c
===================================================================
*** /dev/null
--- src/gcc/testsuite/gcc.dg/ipa/ipcp-agg-1.c
***************
*** 0 ****
--- 1,37 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O3 -fno-ipa-sra -fdump-ipa-cp-details -fdump-tree-optimized-slim"  } */
+ /* { dg-add-options bind_pic_locally } */
+ 
+ struct S
+ {
+   int a, b, c;
+ };
+ 
+ void *blah(int, void *);
+ 
+ static void __attribute__ ((noinline))
+ foo (struct S *p)
+ {
+   int i, c = p->c;
+   int b = p->b;
+   void *v = (void *) p;
+ 
+   for (i= 0; i< c; i++)
+     v = blah(b + i, v);
+ }
+ 
+ void
+ entry (void)
+ {
+   struct S s;
+   s.a = 1;
+   s.b = 64;
+   s.c = 32;
+   foo (&s);
+ }
+ 
+ /* { dg-final { scan-ipa-dump "Creating a specialized node of foo.*for all known contexts" "cp" } } */
+ /* { dg-final { scan-ipa-dump-times "Aggregate replacements:" 2 "cp" } } */
+ /* { dg-final { cleanup-ipa-dump "cp" } } */
+ /* { dg-final { scan-tree-dump-not "->c;" "optimized" } } */
+ /* { dg-final { cleanup-tree-dump "optimized" } } */
Index: src/gcc/testsuite/gcc.dg/ipa/ipcp-agg-2.c
===================================================================
*** /dev/null
--- src/gcc/testsuite/gcc.dg/ipa/ipcp-agg-2.c
***************
*** 0 ****
--- 1,43 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O3 -fno-ipa-sra -fdump-ipa-cp-details -fdump-tree-optimized-slim"  } */
+ /* { dg-add-options bind_pic_locally } */
+ 
+ struct S
+ {
+   int a, b, c;
+ };
+ 
+ void *blah(int, void *);
+ 
+ static void __attribute__ ((noinline))
+ foo (struct S *p)
+ {
+   int i, c = p->c;
+   int b = p->b;
+   void *v = (void *) p;
+ 
+   for (i= 0; i< c; i++)
+     v = blah(b + i, v);
+ }
+ 
+ void
+ entry (int c)
+ {
+   struct S s;
+   int i;
+ 
+   for (i = 0; i<c; i++)
+     {
+       s.a = 1;
+       s.b = 64;
+       s.c = 32;
+       foo (&s);
+     }
+   s.c = 2;
+   foo (&s);
+ }
+ /* { dg-final { scan-ipa-dump-times "Creating a specialized node of foo/\[0-9\]*\\." 2 "cp" } } */
+ /* { dg-final { scan-ipa-dump-times "Aggregate replacements:" 4 "cp" } } */
+ /* { dg-final { cleanup-ipa-dump "cp" } } */
+ /* { dg-final { scan-tree-dump-not "->c;" "optimized" } } */
+ /* { dg-final { cleanup-tree-dump "optimized" } } */
Index: src/gcc/testsuite/gcc.dg/ipa/ipcp-agg-3.c
===================================================================
*** /dev/null
--- src/gcc/testsuite/gcc.dg/ipa/ipcp-agg-3.c
***************
*** 0 ****
--- 1,44 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O3 -fno-ipa-sra -fdump-ipa-cp-details -fdump-tree-optimized-slim"  } */
+ /* { dg-add-options bind_pic_locally } */
+ 
+ struct S
+ {
+   int a, b, c;
+ };
+ 
+ void *blah(int, void *);
+ 
+ static void __attribute__ ((noinline))
+ foo (int z, struct S *p)
+ {
+   int i, c = p->c;
+   int b = p->b;
+   void *v = (void *) p;
+ 
+   for (i= 0; i< c; i++)
+     v = blah(b + i, v);
+ }
+ 
+ void
+ entry (int c)
+ {
+   struct S s;
+   int i;
+ 
+   for (i = 0; i<c; i++)
+     {
+       s.a = 1;
+       s.b = 64;
+       s.c = 32;
+       foo (i, &s);
+     }
+   s.c = 2;
+   foo (0, &s);
+ }
+ /* { dg-final { scan-ipa-dump-times "Creating a specialized node of foo/\[0-9\]*\\." 2 "cp" } } */
+ /* { dg-final { scan-ipa-dump-times "Aggregate replacements: 1" 2 "cp" } } */
+ /* { dg-final { scan-ipa-dump-times "Aggregate replacements: 0" 2 "cp" } } */
+ /* { dg-final { cleanup-ipa-dump "cp" } } */
+ /* { dg-final { scan-tree-dump-not "->c;" "optimized" } } */
+ /* { dg-final { cleanup-tree-dump "optimized" } } */
Index: src/gcc/testsuite/gcc.dg/ipa/ipcp-agg-4.c
===================================================================
*** /dev/null
--- src/gcc/testsuite/gcc.dg/ipa/ipcp-agg-4.c
***************
*** 0 ****
--- 1,62 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O3 -fno-ipa-sra -fdump-ipa-cp-details -fdump-tree-optimized-slim"  } */
+ /* { dg-add-options bind_pic_locally } */
+ 
+ struct S
+ {
+   int a, b, c;
+ };
+ 
+ void *blah(int, void *);
+ 
+ static void __attribute__ ((noinline))
+ foo (struct S *p)
+ {
+   int i, c = p->c;
+   int b = p->b;
+   void *v = (void *) p;
+ 
+   for (i= 0; i< c; i++)
+     v = blah(b + i, v);
+ }
+ 
+ 
+ void
+ entry1 (int c)
+ {
+   struct S s;
+   int i;
+ 
+   for (i = 0; i<c; i++)
+     {
+       s.a = 1;
+       s.b = 64;
+       s.c = 32;
+       foo (&s);
+     }
+   s.c = 2;
+   foo (&s);
+ }
+ 
+ void
+ entry2 (int c)
+ {
+   struct S s;
+   int i;
+ 
+   for (i = 0; i<c; i++)
+     {
+       s.a = 6;
+       s.b = 64;
+       s.c = 32;
+       foo (&s);
+     }
+   s.c = 2;
+   foo (&s);
+ }
+ 
+ /* { dg-final { scan-ipa-dump-times "Creating a specialized node of foo/\[0-9\]*\\." 2 "cp" } } */
+ /* { dg-final { scan-ipa-dump-times "Aggregate replacements:" 4 "cp" } } */
+ /* { dg-final { cleanup-ipa-dump "cp" } } */
+ /* { dg-final { scan-tree-dump-not "->c;" "optimized" } } */
+ /* { dg-final { cleanup-tree-dump "optimized" } } */
Index: src/gcc/testsuite/gcc.dg/ipa/ipcp-agg-5.c
===================================================================
*** /dev/null
--- src/gcc/testsuite/gcc.dg/ipa/ipcp-agg-5.c
***************
*** 0 ****
--- 1,68 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O3 -fno-ipa-sra -fdump-ipa-cp-details -fdump-tree-optimized-slim"  } */
+ /* { dg-add-options bind_pic_locally } */
+ 
+ struct S
+ {
+   int a, b, c;
+ };
+ 
+ void *blah(int, void *);
+ 
+ static void __attribute__ ((noinline))
+ foo (struct S *p)
+ {
+   int i, c = p->c;
+   int b = p->b;
+   void *v = (void *) p;
+ 
+   for (i= 0; i< c; i++)
+     v = blah(b + i, v);
+ }
+ 
+ static void __attribute__ ((noinline))
+ bar (struct S *p)
+ {
+   foo (p);
+ }
+ 
+ void
+ entry1 (int c)
+ {
+   struct S s;
+   int i;
+ 
+   for (i = 0; i<c; i++)
+     {
+       s.a = 1;
+       s.b = 64;
+       s.c = 32;
+       bar (&s);
+     }
+   s.c = 2;
+   bar (&s);
+ }
+ 
+ void
+ entry2 (int c)
+ {
+   struct S s;
+   int i;
+ 
+   for (i = 0; i<c; i++)
+     {
+       s.a = 6;
+       s.b = 64;
+       s.c = 32;
+       foo (&s);
+     }
+   s.c = 2;
+   foo (&s);
+ }
+ 
+ /* { dg-final { scan-ipa-dump-times "Creating a specialized node of foo/\[0-9\]*\\." 2 "cp" } } */
+ /* { dg-final { scan-ipa-dump-times "Creating a specialized node of bar/\[0-9\]*\\." 2 "cp" } } */
+ /* { dg-final { scan-ipa-dump-times "Aggregate replacements:" 8 "cp" } } */
+ /* { dg-final { cleanup-ipa-dump "cp" } } */
+ /* { dg-final { scan-tree-dump-not "->c;" "optimized" } } */
+ /* { dg-final { cleanup-tree-dump "optimized" } } */
Index: src/gcc/testsuite/gcc.dg/ipa/ipcp-agg-6.c
===================================================================
*** /dev/null
--- src/gcc/testsuite/gcc.dg/ipa/ipcp-agg-6.c
***************
*** 0 ****
--- 1,75 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O3 -fno-ipa-sra -fdump-ipa-cp-details -fdump-tree-optimized-slim"  } */
+ /* { dg-add-options bind_pic_locally } */
+ 
+ struct S
+ {
+   int a, b, c;
+ };
+ 
+ void *blah(int, void *);
+ 
+ static void __attribute__ ((noinline))
+ foo (struct S *p)
+ {
+   int i, c = p->c;
+   int b = p->b;
+   void *v = (void *) p;
+ 
+   for (i= 0; i< c; i++)
+     v = blah(b + i, v);
+ }
+ 
+ static void __attribute__ ((noinline))
+ bar (struct S *p)
+ {
+   foo (p);
+ }
+ 
+ static void __attribute__ ((noinline))
+ bar_2 (struct S *p)
+ {
+   foo (p);
+ }
+ 
+ void
+ entry1 (int c)
+ {
+   struct S s;
+   int i;
+ 
+   for (i = 0; i<c; i++)
+     {
+       s.a = 1;
+       s.b = 64;
+       s.c = 32;
+       bar (&s);
+     }
+   s.c = 2;
+   bar (&s);
+ }
+ 
+ void
+ entry2 (int c)
+ {
+   struct S s;
+   int i;
+ 
+   for (i = 0; i<c; i++)
+     {
+       s.a = 6;
+       s.b = 64;
+       s.c = 32;
+       bar_2 (&s);
+     }
+   s.c = 2;
+   foo (&s);
+ }
+ 
+ /* { dg-final { scan-ipa-dump-times "Creating a specialized node of foo/\[0-9\]*\\." 2 "cp" } } */
+ /* { dg-final { scan-ipa-dump-times "Creating a specialized node of bar/\[0-9\]*\\." 2 "cp" } } */
+ /* { dg-final { scan-ipa-dump "Creating a specialized node of bar_2.*for all known contexts" "cp" } } */
+ /* { dg-final { scan-ipa-dump-times "Aggregate replacements:" 10 "cp" } } */
+ /* { dg-final { cleanup-ipa-dump "cp" } } */
+ /* { dg-final { scan-tree-dump-not "->c;" "optimized" } } */
+ /* { dg-final { cleanup-tree-dump "optimized" } } */
Index: src/gcc/testsuite/gfortran.dg/pr48636-2.f90
===================================================================
*** /dev/null
--- src/gcc/testsuite/gfortran.dg/pr48636-2.f90
***************
*** 0 ****
--- 1,38 ----
+ ! { dg-do compile }
+ ! { dg-options "-O3 -fdump-ipa-cp-details -fno-inline" }
+ 
+ module foo
+   implicit none
+ contains
+   subroutine bar(a,x)
+     real, dimension(:,:), intent(in) :: a
+     real, intent(out) :: x
+     integer :: i,j
+ 
+     x = 0
+     do j=1,ubound(a,2)
+        do i=1,ubound(a,1)
+           x = x + a(i,j)**2
+        end do
+     end do
+   end subroutine bar
+ end module foo
+ 
+ program main
+   use foo
+   implicit none
+   real, dimension(2,3) :: a
+   real :: x
+   integer :: i
+ 
+   data a /1.0, 2.0, 3.0, -1.0, -2.0, -3.0/
+ 
+   do i=1,2000000
+      call bar(a,x)
+   end do
+   print *,x
+ end program main
+ 
+ ! { dg-final { scan-ipa-dump "Creating a specialized node of bar/\[0-9\]*\\." "cp" } }
+ ! { dg-final { scan-ipa-dump-times "Aggregate replacements\[^=\]*=\[^=\]*=\[^=\]*=\[^=\]*=\[^=\]*=\[^=\]*=\[^=\]*=\[^=\]*=\[^=\]*=" 2 "cp" } }
+ ! { dg-final { cleanup-ipa-dump "cp" } }
Index: src/gcc/testsuite/gfortran.dg/pr48636.f90
===================================================================
*** src.orig/gcc/testsuite/gfortran.dg/pr48636.f90
--- src/gcc/testsuite/gfortran.dg/pr48636.f90
***************
*** 1,5 ****
  ! { dg-do compile }
! ! { dg-options "-O3 -fdump-ipa-inline-details" }
  
  module foo
    implicit none
--- 1,5 ----
  ! { dg-do compile }
! ! { dg-options "-O3 -fdump-ipa-inline-details -fno-ipa-cp" }
  
  module foo
    implicit none
Index: src/gcc/testsuite/gfortran.dg/pr53787.f90
===================================================================
*** /dev/null
--- src/gcc/testsuite/gfortran.dg/pr53787.f90
***************
*** 0 ****
--- 1,21 ----
+ ! { dg-do compile }
+ ! { dg-options "-O3 -fdump-ipa-cp-details -fno-inline -fwhole-program" }
+ 
+   real x(10)
+   n = 10
+   call init(x,n)
+   print *, x
+ end program
+ 
+ subroutine init(x, n)
+   real x(10)
+   do i=1,n
+      x(i) = i*i + 1
+   enddo
+ 
+   return
+ end subroutine init
+ 
+ ! { dg-final { scan-ipa-dump "Creating a specialized node of init" "cp" } }
+ ! { dg-final { scan-ipa-dump-times "Aggregate replacements" 2 "cp" } }
+ ! { dg-final { cleanup-ipa-dump "cp" } }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]