[PATCH] Fix PR42455

Richard Guenther rguenther@suse.de
Fri Jan 1 20:19:00 GMT 2010


SRA code generation depends on the order accesses are analyzed.
The following makes this order UID order to avoid code generation
differences with -g.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2010-01-01  Richard Guenther  <rguenther@suse.de>

	PR debug/42455
	* tree-sra.c (analyze_all_variable_accesses): Work in DECL_UID
	order.

Index: gcc/tree-sra.c
===================================================================
*** gcc/tree-sra.c	(revision 155556)
--- gcc/tree-sra.c	(working copy)
*************** propagate_all_subaccesses (void)
*** 1885,1929 ****
  static bool
  analyze_all_variable_accesses (void)
  {
-   tree var;
-   referenced_var_iterator rvi;
    int res = 0;
  
!   FOR_EACH_REFERENCED_VAR (var, rvi)
!     if (bitmap_bit_p (candidate_bitmap, DECL_UID (var)))
!       {
! 	struct access *access;
  
! 	access = sort_and_splice_var_accesses (var);
! 	if (access)
! 	  build_access_trees (access);
! 	else
! 	  disqualify_candidate (var,
! 				"No or inhibitingly overlapping accesses.");
!       }
  
    propagate_all_subaccesses ();
  
!   FOR_EACH_REFERENCED_VAR (var, rvi)
!     if (bitmap_bit_p (candidate_bitmap, DECL_UID (var)))
!       {
! 	struct access *access = get_first_repr_for_decl (var);
  
! 	if (analyze_access_trees (access))
! 	  {
! 	    res++;
! 	    if (dump_file && (dump_flags & TDF_DETAILS))
! 	      {
! 		fprintf (dump_file, "\nAccess trees for ");
! 		print_generic_expr (dump_file, var, 0);
! 		fprintf (dump_file, " (UID: %u): \n", DECL_UID (var));
! 		dump_access_tree (dump_file, access);
! 		fprintf (dump_file, "\n");
! 	      }
! 	  }
! 	else
! 	  disqualify_candidate (var, "No scalar replacements to be created.");
!       }
  
    if (res)
      {
--- 1885,1934 ----
  static bool
  analyze_all_variable_accesses (void)
  {
    int res = 0;
+   bitmap tmp = BITMAP_ALLOC (NULL);
+   bitmap_iterator bi;
+   unsigned i;
  
!   bitmap_copy (tmp, candidate_bitmap);
!   EXECUTE_IF_SET_IN_BITMAP (tmp, 0, i, bi)
!     {
!       tree var = referenced_var (i);
!       struct access *access;
  
!       access = sort_and_splice_var_accesses (var);
!       if (access)
! 	build_access_trees (access);
!       else
! 	disqualify_candidate (var,
! 			      "No or inhibitingly overlapping accesses.");
!     }
  
    propagate_all_subaccesses ();
  
!   bitmap_copy (tmp, candidate_bitmap);
!   EXECUTE_IF_SET_IN_BITMAP (tmp, 0, i, bi)
!     {
!       tree var = referenced_var (i);
!       struct access *access = get_first_repr_for_decl (var);
  
!       if (analyze_access_trees (access))
! 	{
! 	  res++;
! 	  if (dump_file && (dump_flags & TDF_DETAILS))
! 	    {
! 	      fprintf (dump_file, "\nAccess trees for ");
! 	      print_generic_expr (dump_file, var, 0);
! 	      fprintf (dump_file, " (UID: %u): \n", DECL_UID (var));
! 	      dump_access_tree (dump_file, access);
! 	      fprintf (dump_file, "\n");
! 	    }
! 	}
!       else
! 	disqualify_candidate (var, "No scalar replacements to be created.");
!     }
! 
!   BITMAP_FREE (tmp);
  
    if (res)
      {



More information about the Gcc-patches mailing list