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 target/104686] [12 Regression] Huge compile-time regression building SPEC 2017 538.imagick_r with -march=skylake
Date: Tue, 01 Mar 2022 15:45:38 +0000	[thread overview]
Message-ID: <bug-104686-4-Dk8XYMSbq2@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104686-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104686

--- Comment #16 from Richard Biener <rguenth at gcc dot gnu.org> ---
it doesn't make a difference for this testcase but profiling shows that
allocnos_conflict_p is quite expensive so it's best to do it after the other
continue checks like the following.  I also notice that the comment of
allocnos_conflict_p says

/* Return TRUE if allocnos A1 and A2 conflicts. Here we are
   interesting only in conflicts of allocnos with intersected allocno
   classes. */

so doing it after the ira_reg_classes_intersect_p check makes even more
sense(?)

diff --git a/gcc/ira-color.cc b/gcc/ira-color.cc
index 8b6db1bb417..a5fd79484eb 100644
--- a/gcc/ira-color.cc
+++ b/gcc/ira-color.cc
@@ -1572,15 +1572,14 @@ update_conflict_hard_regno_costs (int *costs, enum
reg_class aclass,
        else
          gcc_unreachable ();

+       another_aclass = ALLOCNO_CLASS (another_allocno);
        if (another_allocno == from
+           || ALLOCNO_ASSIGNED_P (another_allocno)
+           || ALLOCNO_COLOR_DATA (another_allocno)->may_be_spilled_p
+           || ! ira_reg_classes_intersect_p[aclass][another_aclass]
            || allocnos_conflict_p (another_allocno, start))
          continue;

-       another_aclass = ALLOCNO_CLASS (another_allocno);
-       if (! ira_reg_classes_intersect_p[aclass][another_aclass]
-           || ALLOCNO_ASSIGNED_P (another_allocno)
-           || ALLOCNO_COLOR_DATA (another_allocno)->may_be_spilled_p)
-         continue;
        class_size = ira_class_hard_regs_num[another_aclass];
        ira_allocate_and_copy_costs
          (&ALLOCNO_UPDATED_CONFLICT_HARD_REG_COSTS (another_allocno),


Now, what's more odd is that we sometimes have a nice bitmap representation
for the conflicts but we always iterate.  So it _seems_ we should be able
to do sth like

diff --git a/gcc/ira-color.cc b/gcc/ira-color.cc
index 8b6db1bb417..682d1ef7562 100644
--- a/gcc/ira-color.cc
+++ b/gcc/ira-color.cc
@@ -1352,9 +1352,23 @@ allocnos_conflict_p (ira_allocno_t a1, ira_allocno_t a2)
     {
       obj = ALLOCNO_OBJECT (a1, word);
       /* Take preferences of conflicting allocnos into account.  */
-      FOR_EACH_OBJECT_CONFLICT (obj, conflict_obj, oci)
-       if (OBJECT_ALLOCNO (conflict_obj) == a2)
-         return true;
+      if  (!OBJECT_CONFLICT_VEC_P (obj))
+       {
+         for (int w2 = 0; w2 < ALLOCNO_NUM_OBJECTS (a2); w2++)
+           {
+             ira_object_t obj2 = ALLOCNO_OBJECT (a2, w2);
+             if (OBJECT_CONFLICT_ID (obj2) >= OBJECT_MIN (obj)
+                 && OBJECT_CONFLICT_ID (obj2) <= OBJECT_MAX (obj)
+                 && TEST_MINMAX_SET_BIT (OBJECT_CONFLICT_BITVEC (obj),
+                                         OBJECT_CONFLICT_ID (obj2),
+                                         OBJECT_MIN (obj), OBJECT_MAX (obj)))
+               return true;
+           }
+       }
+      else
+       FOR_EACH_OBJECT_CONFLICT (obj, conflict_obj, oci)
+         if (OBJECT_ALLOCNO (conflict_obj) == a2)
+           return true;
     }
   return false;
 }  

which reduces compile-time from 10s to 1s for me ... the above should
be split out so we can "optimally" use the bit test for
object vs. allocno when possible.

Vlad - any thoughts about the above two things?  Shall I try to polish and
optimize the bit test or would you be willing to pick those two speedups up?

  parent reply	other threads:[~2022-03-01 15:45 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-25 12:05 [Bug target/104686] New: " rguenth at gcc dot gnu.org
2022-02-25 12:06 ` [Bug target/104686] " rguenth at gcc dot gnu.org
2022-02-25 12:07 ` rguenth at gcc dot gnu.org
2022-02-25 12:13 ` rguenth at gcc dot gnu.org
2022-02-25 12:23 ` marxin at gcc dot gnu.org
2022-02-25 12:23 ` marxin at gcc dot gnu.org
2022-02-25 12:29 ` marxin at gcc dot gnu.org
2022-02-25 12:36 ` rguenth at gcc dot gnu.org
2022-02-25 12:38 ` marxin at gcc dot gnu.org
2022-02-25 12:47 ` marxin at gcc dot gnu.org
2022-02-25 13:00 ` rguenth at gcc dot gnu.org
2022-02-25 13:17 ` rguenth at gcc dot gnu.org
2022-02-28  1:19 ` crazylht at gmail dot com
2022-02-28  1:48 ` crazylht at gmail dot com
2022-02-28  7:03 ` cvs-commit at gcc dot gnu.org
2022-02-28  7:03 ` rguenth at gcc dot gnu.org
2022-03-01  9:20 ` rguenth at gcc dot gnu.org
2022-03-01 15:45 ` rguenth at gcc dot gnu.org [this message]
2022-03-01 15:54 ` rguenth at gcc dot gnu.org
2022-03-01 16:40 ` rguenth at gcc dot gnu.org
2022-03-01 21:58 ` vmakarov at gcc dot gnu.org
2022-03-02  8:08 ` rguenth at gcc dot gnu.org
2022-03-02 14:09 ` cvs-commit at gcc dot gnu.org
2022-03-02 14:10 ` rguenth at gcc dot gnu.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-104686-4-Dk8XYMSbq2@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).