public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/39326] Segmentation fault with -O1, out of memory with -O2
Date: Tue, 12 Mar 2013 14:05:00 -0000	[thread overview]
Message-ID: <bug-39326-4-88nig72vsg@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-39326-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39326

--- Comment #47 from Richard Biener <rguenth at gcc dot gnu.org> 2013-03-12 14:05:10 UTC ---
With caching affine-combination compute and ao_ref compute I have it down to

 tree loop invariant motion: 596.91 (79%) usr   0.73 (29%) sys 599.77 (78%)
wall   31135 kB ( 3%) ggc

without limiting anything.  I tried a more intelligent ref_indep_in_loop
(avoiding another quadraticness in loop depth ...) but it gets slower ...

*************** ref_indep_loop_p_1 (struct loop *loop, m
*** 2230,2242 ****
    bitmap refs_to_check;
    unsigned i;
    bitmap_iterator bi;
!   bool ret = true, stored = bitmap_bit_p (ref->stored, loop->num);
    mem_ref_p aref;

!   if (stored)
!     refs_to_check = memory_accesses.all_refs_in_loop[loop->num];
    else
!     refs_to_check = memory_accesses.all_refs_stored_in_loop[loop->num];

    EXECUTE_IF_SET_IN_BITMAP (refs_to_check, 0, i, bi)
      {
--- 2233,2245 ----
    bitmap refs_to_check;
    unsigned i;
    bitmap_iterator bi;
!   bool ret = true;
    mem_ref_p aref;

!   if (bitmap_bit_p (ref->stored, loop->num))
!     refs_to_check = memory_accesses.refs_in_loop[loop->num];
    else
!     refs_to_check = memory_accesses.refs_stored_in_loop[loop->num];

    EXECUTE_IF_SET_IN_BITMAP (refs_to_check, 0, i, bi)
      {
*************** ref_indep_loop_p_1 (struct loop *loop, m
*** 2259,2272 ****
  static bool
  ref_indep_loop_p (struct loop *loop, mem_ref_p ref)
  {
-   bool ret;
-
    if (bitmap_bit_p (ref->indep_loop, loop->num))
      return true;
    if (bitmap_bit_p (ref->dep_loop, loop->num))
      return false;

!   ret = ref_indep_loop_p_1 (loop, ref);

    if (dump_file && (dump_flags & TDF_DETAILS))
      fprintf (dump_file, "Querying dependencies of ref %u in loop %d: %s\n",
--- 2262,2286 ----
  static bool
  ref_indep_loop_p (struct loop *loop, mem_ref_p ref)
  {
    if (bitmap_bit_p (ref->indep_loop, loop->num))
      return true;
    if (bitmap_bit_p (ref->dep_loop, loop->num))
      return false;

!   bool ret = true;
!   struct loop *inner = loop->inner;
!   while (inner)
!     {
!       if (!ref_indep_loop_p (inner, ref))
!       {
!         ret = false;
!         break;
!       }
!       inner = inner->next;
!     }
!
!   if (ret)
!     ret = ref_indep_loop_p_1 (loop, ref);

    if (dump_file && (dump_flags & TDF_DETAILS))
      fprintf (dump_file, "Querying dependencies of ref %u in loop %d: %s\n",


with it we can also get rid of the all_refs_in_loop bitmap (only
all_refs_stored_in_loop is then used, by store-motion).

I don't see why the above should result in slower operation :/  It should
save us the time to re-query references in sub-loops (yes, they should
be cached already ... still walking the bitmap is not free).

To mimic parts of this idea the dep_loop/indep_loop checking/setting can
be improved to cover outer loops like with

@@ -2296,7 +2218,12 @@ record_indep_loop (struct loop *loop, me
   if (indep)
     bitmap_set_bit (ref->indep_loop, loop->num);
   else
-    bitmap_set_bit (ref->dep_loop, loop->num);
+    do
+      {
+       bitmap_set_bit (ref->dep_loop, loop->num);
+       loop = loop_outer (loop);
+      }
+    while (loop != current_loops->tree_root);
 }

and

@@ -2339,8 +2266,13 @@ ref_indep_loop_p (struct loop *loop, mem
 {
   bool ret;

-  if (bitmap_bit_p (ref->indep_loop, loop->num))
-    return true;
+  struct loop *oloop = loop;
+  do
+    {
+      if (bitmap_bit_p (ref->indep_loop, oloop->num))
+       return true;
+      oloop = loop_outer (oloop);
+    }
+  while (oloop != current_loops->tree_root);
   if (bitmap_bit_p (ref->dep_loop, loop->num))
     return false;

(no difference in compile-time)

anyway, another obvious improvement is to merge the two two-bitmap
sets (they are tri-state, dependent, independent and unknown).  That's
more cache-friendly (now, where's that tri-state "bitmap" implementation
that also saves the half bit we waste ... ;))  It helps a bit.


  parent reply	other threads:[~2013-03-12 14:05 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-39326-4@http.gcc.gnu.org/bugzilla/>
2013-03-06 11:08 ` steven at gcc dot gnu.org
2013-03-06 11:38 ` rguenth at gcc dot gnu.org
2013-03-06 16:50 ` sergstesh at yahoo dot com
2013-03-06 23:39 ` steven at gcc dot gnu.org
2013-03-07  0:08 ` steven at gcc dot gnu.org
2013-03-07  0:27 ` steven at gcc dot gnu.org
2013-03-07  8:10 ` steven at gcc dot gnu.org
2013-03-07  8:45 ` rguenther at suse dot de
2013-03-07  8:48 ` rguenther at suse dot de
2013-03-07  8:53 ` rguenther at suse dot de
2013-03-07  9:58 ` steven at gcc dot gnu.org
2013-03-07 10:14 ` sergstesh at yahoo dot com
2013-03-07 10:15 ` rguenther at suse dot de
2013-03-07 17:14 ` sergstesh at yahoo dot com
2013-03-07 17:31 ` steven at gcc dot gnu.org
2013-03-07 17:34 ` steven at gcc dot gnu.org
2013-03-07 21:48 ` sergstesh at yahoo dot com
2013-03-07 22:16 ` steven at gcc dot gnu.org
2013-03-07 23:19 ` steven at gcc dot gnu.org
2013-03-08  9:14 ` rguenth at gcc dot gnu.org
2013-03-08  9:14 ` rguenth at gcc dot gnu.org
2013-03-08  9:23 ` rguenther at suse dot de
2013-03-09 14:58 ` steven at gcc dot gnu.org
2013-03-09 17:26 ` steven at gcc dot gnu.org
2013-03-11  9:40 ` steven at gcc dot gnu.org
2013-03-12 10:47 ` rguenth at gcc dot gnu.org
2013-03-12 14:05 ` rguenth at gcc dot gnu.org [this message]
2013-03-15 16:07 ` rguenth at gcc dot gnu.org
2013-03-18  8:44 ` rguenth at gcc dot gnu.org
2013-03-21 20:04 ` jakub at gcc dot gnu.org
2013-03-22 14:01 ` rguenth at gcc dot gnu.org
2013-03-26 10:10 ` rguenth at gcc dot gnu.org
2014-01-15 15:14 ` rguenth at gcc dot gnu.org
2014-01-17 13:53 ` rguenth at gcc dot gnu.org
2022-03-10 15:05 ` rguenth at gcc dot gnu.org
2024-02-20 13:14 ` rguenth at gcc dot gnu.org
2009-02-28 15:23 [Bug c/39326] New: " sergstesh at yahoo dot com
2009-03-02 17:16 ` [Bug middle-end/39326] " pinskia at gcc dot gnu dot org
2009-03-03 13:36 ` sergstesh at yahoo dot com
2009-03-03 13:49 ` rguenther at suse dot de
2009-03-03 14:15 ` sergstesh at yahoo dot com
2009-03-17 11:05 ` rguenth at gcc dot gnu dot org
2009-03-17 12:42 ` rguenth at gcc dot gnu dot org
2009-03-17 12:59 ` rguenth at gcc dot gnu dot org
2009-03-17 13:10 ` rguenth at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-39326-4-88nig72vsg@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).