This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
vartracking speedup
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: gcc-patches at gcc dot gnu dot org, jakub at redhat dot com
- Date: Thu, 3 Jun 2010 03:49:19 +0200
- Subject: vartracking speedup
Hi,
while looking into oprofiles, I noticed that dataflow_set_equiv_regs shows
quite top (0.6%) and pretty much all goes to memset. It is because at the end
of basic block for each pseudo we clear NUM_MACHINE_MODES words that
is quite some memory.
This patch adds a check if (set->regs[i]) to prevent the heavy work when
nothing is chnaged.
Note that rest of is reformating, this is one-liner.
Bootstrapped/regtested x86_64-linux, OK?
* var-trackin.c (dataflow_set_equiv_regs): Avoid hard work
when pseudo is not changed.
Index: var-tracking.c
===================================================================
--- var-tracking.c (revision 160154)
+++ var-tracking.c (working copy)
@@ -3691,71 +3691,72 @@ dataflow_set_equiv_regs (dataflow_set *s
attrs list, *listp;
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
- {
- rtx canon[NUM_MACHINE_MODES];
-
- memset (canon, 0, sizeof (canon));
-
- for (list = set->regs[i]; list; list = list->next)
- if (list->offset == 0 && dv_is_value_p (list->dv))
- {
- rtx val = dv_as_value (list->dv);
- rtx *cvalp = &canon[(int)GET_MODE (val)];
- rtx cval = *cvalp;
-
- if (canon_value_cmp (val, cval))
- *cvalp = val;
- }
-
- for (list = set->regs[i]; list; list = list->next)
- if (list->offset == 0 && dv_onepart_p (list->dv))
- {
- rtx cval = canon[(int)GET_MODE (list->loc)];
-
- if (!cval)
- continue;
-
- if (dv_is_value_p (list->dv))
- {
- rtx val = dv_as_value (list->dv);
-
- if (val == cval)
- continue;
-
- VALUE_RECURSED_INTO (val) = true;
- set_variable_part (set, val, dv_from_value (cval), 0,
- VAR_INIT_STATUS_INITIALIZED,
- NULL, NO_INSERT);
- }
-
- VALUE_RECURSED_INTO (cval) = true;
- set_variable_part (set, cval, list->dv, 0,
- VAR_INIT_STATUS_INITIALIZED, NULL, NO_INSERT);
- }
-
- for (listp = &set->regs[i]; (list = *listp);
- listp = list ? &list->next : listp)
- if (list->offset == 0 && dv_onepart_p (list->dv))
- {
- rtx cval = canon[(int)GET_MODE (list->loc)];
- void **slot;
-
- if (!cval)
- continue;
-
- if (dv_is_value_p (list->dv))
- {
- rtx val = dv_as_value (list->dv);
- if (!VALUE_RECURSED_INTO (val))
- continue;
- }
-
- slot = shared_hash_find_slot_noinsert (set->vars, list->dv);
- canonicalize_values_star (slot, set);
- if (*listp != list)
- list = NULL;
- }
- }
+ if (set->regs[i])
+ {
+ rtx canon[NUM_MACHINE_MODES];
+
+ memset (canon, 0, sizeof (canon));
+
+ for (list = set->regs[i]; list; list = list->next)
+ if (list->offset == 0 && dv_is_value_p (list->dv))
+ {
+ rtx val = dv_as_value (list->dv);
+ rtx *cvalp = &canon[(int)GET_MODE (val)];
+ rtx cval = *cvalp;
+
+ if (canon_value_cmp (val, cval))
+ *cvalp = val;
+ }
+
+ for (list = set->regs[i]; list; list = list->next)
+ if (list->offset == 0 && dv_onepart_p (list->dv))
+ {
+ rtx cval = canon[(int)GET_MODE (list->loc)];
+
+ if (!cval)
+ continue;
+
+ if (dv_is_value_p (list->dv))
+ {
+ rtx val = dv_as_value (list->dv);
+
+ if (val == cval)
+ continue;
+
+ VALUE_RECURSED_INTO (val) = true;
+ set_variable_part (set, val, dv_from_value (cval), 0,
+ VAR_INIT_STATUS_INITIALIZED,
+ NULL, NO_INSERT);
+ }
+
+ VALUE_RECURSED_INTO (cval) = true;
+ set_variable_part (set, cval, list->dv, 0,
+ VAR_INIT_STATUS_INITIALIZED, NULL, NO_INSERT);
+ }
+
+ for (listp = &set->regs[i]; (list = *listp);
+ listp = list ? &list->next : listp)
+ if (list->offset == 0 && dv_onepart_p (list->dv))
+ {
+ rtx cval = canon[(int)GET_MODE (list->loc)];
+ void **slot;
+
+ if (!cval)
+ continue;
+
+ if (dv_is_value_p (list->dv))
+ {
+ rtx val = dv_as_value (list->dv);
+ if (!VALUE_RECURSED_INTO (val))
+ continue;
+ }
+
+ slot = shared_hash_find_slot_noinsert (set->vars, list->dv);
+ canonicalize_values_star (slot, set);
+ if (*listp != list)
+ list = NULL;
+ }
+ }
}
/* Remove any redundant values in the location list of VAR, which must