public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [alias-export] Remove exported ddg info for insns in unrolled loop
@ 2009-04-22 15:50 Andrey Belevantsev
  0 siblings, 0 replies; only message in thread
From: Andrey Belevantsev @ 2009-04-22 15:50 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 1110 bytes --]

Hello,

When answering alias queries with data dependency information, we can 
disambiguate references that have nonzero distance vectors (unless we're 
doing it for modulo scheduling).  However, unrolling makes exported 
distance vectors invalid.  Fixing it the right way would be to compute 
the correct distance.  For now I've just nuked the wrong info from the 
hashtable.

Bootstrapped on x86-64 together with Jakub's patch for infamous PR39794, 
which was supposed to be the test case for the above problem kindly 
constructed by Alexander Monakov (but we found that the test case fails 
nicely even without ddg-export :), committed to alias-export branch.

Andrey

2009-04-22  Andrey Belevantsev  <abel@ispras.ru>

         Apply Jakub's patch for PR39794.
         * alias-export.c (walk_mems): New.
         (remove_exported_ddg_data): New.
         (init_ddg_info): Allow disambiguation using inter loop deps.
         * alias-export.h (remove_exported_ddg_data): Export.
         * loop-unroll.c (apply_opt_in_copies): Use it for removing saved
         ddg information from insns in unrolled loop.

[-- Attachment #2: fix-unroll-ddg-export.diff --]
[-- Type: text/x-patch, Size: 3247 bytes --]

Index: gcc/loop-unroll.c
===================================================================
*** gcc/loop-unroll.c	(revision 146024)
--- gcc/loop-unroll.c	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 33,38 ****
--- 33,39 ----
  #include "expr.h"
  #include "hashtab.h"
  #include "recog.h"    
+ #include "alias-export.h"
  
  /* This pass performs loop unrolling and peeling.  We only perform these
     optimizations on innermost loops (with single exception) because
*************** apply_opt_in_copies (struct opt_info *op
*** 2207,2212 ****
--- 2208,2216 ----
                    expand_var_during_unrolling (ves, insn);
                  }
              }
+ 
+           if (flag_ddg_export)
+             remove_exported_ddg_data (insn);
            orig_insn = NEXT_INSN (orig_insn);
          }
      }
*************** apply_opt_in_copies (struct opt_info *op
*** 2245,2250 ****
--- 2249,2257 ----
            
            if (!INSN_P (orig_insn))
   	    continue;
+ 
+           if (flag_ddg_export)
+             remove_exported_ddg_data (orig_insn);
            
            ivts_templ.insn = orig_insn;
            if (opt_info->insns_to_split)
Index: gcc/alias-export.c
===================================================================
*** gcc/alias-export.c	(revision 146147)
--- gcc/alias-export.c	(working copy)
*************** init_ddg_info (void)
*** 818,824 ****
     = htab_create (1, (htab_hash) htab_hash_datarefs_pair,
  		  (htab_eq) htab_eq_datarefs_pair,
  		  (htab_del) htab_del_datarefs_pair);
!   ddg_info->disambiguate_only_intra_loop_deps = true;
  }
  
  /* Save the data reference DRF in the ddg_info structure.  */
--- 818,824 ----
     = htab_create (1, (htab_hash) htab_hash_datarefs_pair,
  		  (htab_eq) htab_eq_datarefs_pair,
  		  (htab_del) htab_del_datarefs_pair);
!   ddg_info->disambiguate_only_intra_loop_deps = false;
  }
  
  /* Save the data reference DRF in the ddg_info structure.  */
*************** print_ddg_export_stats (void)
*** 1027,1032 ****
--- 1027,1056 ----
    ddg_info->alias_success_nonzero_dist = 0;
  }
  
+ /* A callback for for_each_rtx to remove exported data for mems.  */
+ static int
+ walk_mems (rtx *x, void *data ATTRIBUTE_UNUSED)
+ {
+   if (MEM_P (*x) && MEM_ORIG_EXPR (*x) && find_dataref (MEM_ORIG_EXPR (*x)))
+     {
+       tree_dataref td;
+ 
+       td.ref = MEM_ORIG_EXPR (*x);
+       htab_remove_elt (ddg_info->tree_to_dataref, &td);
+ 
+       return -1;
+     }
+   return 0;
+ }
+ 
+ /* Remove saved dependency data for INSN.  Used when INSN is in the loop that
+    was unrolled.  */
+ void
+ remove_exported_ddg_data (rtx insn)
+ {
+   for_each_rtx (&PATTERN (insn), walk_mems, NULL);
+ }
+ 
  #if 0
  void
  ddg_export_disambiguate_only_intra_loop_deps (bool b)
Index: gcc/alias-export.h
===================================================================
*** gcc/alias-export.h	(revision 146034)
--- gcc/alias-export.h	(working copy)
*************** extern bool alias_export_test (tree, tre
*** 33,38 ****
--- 33,39 ----
  
  extern bool ddg_export_may_alias_p (tree, tree, int);
  extern void replace_var_in_datarefs (tree, tree);
+ extern void remove_exported_ddg_data (rtx);
  
  
  #endif /* GCC_ALIAS_EXPORT_H */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-04-22 15:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-22 15:50 [alias-export] Remove exported ddg info for insns in unrolled loop Andrey Belevantsev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).