This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 1/2] Introduce filtering for edge_predictions.
- From: marxin <mliska at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Cc: hubicka at ucw dot cz
- Date: Tue, 31 May 2016 17:29:06 +0200
- Subject: [PATCH 1/2] Introduce filtering for edge_predictions.
- Authentication-results: sourceware.org; auth=none
- References: <cover dot 1464868111 dot git dot mliska at suse dot cz>
- Resent-user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0
gcc/ChangeLog:
2016-05-31 Martin Liska <mliska@suse.cz>
* predict.c (filter_predictions): New function.
(remove_predictions_associated_with_edge): Use the filter
function.
(equal_edge_p): New function.
---
gcc/predict.c | 38 ++++++++++++++++++++++++++++++--------
1 file changed, 30 insertions(+), 8 deletions(-)
diff --git a/gcc/predict.c b/gcc/predict.c
index e9dda20..51a9993 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -609,16 +609,16 @@ gimple_predict_edge (edge e, enum br_predictor predictor, int probability)
}
}
-/* Remove all predictions on given basic block that are attached
- to edge E. */
+/* Filter edge predictions PREDS by a function FILTER. DATA are passed
+ to the filter function. */
+
void
-remove_predictions_associated_with_edge (edge e)
+filter_predictions (edge_prediction **preds,
+ bool (*filter) (edge_prediction *, void *), void *data)
{
if (!bb_predictions)
return;
- edge_prediction **preds = bb_predictions->get (e->src);
-
if (preds)
{
struct edge_prediction **prediction = preds;
@@ -626,18 +626,40 @@ remove_predictions_associated_with_edge (edge e)
while (*prediction)
{
- if ((*prediction)->ep_edge == e)
+ if ((*filter) (*prediction, data))
+ prediction = &((*prediction)->ep_next);
+ else
{
next = (*prediction)->ep_next;
free (*prediction);
*prediction = next;
}
- else
- prediction = &((*prediction)->ep_next);
}
}
}
+/* Filter function predicate that returns true for a edge predicate P
+ if its edge is equal to DATA. */
+
+bool
+equal_edge_p (edge_prediction *p, void *data)
+{
+ return p->ep_edge == (edge)data;
+}
+
+/* Remove all predictions on given basic block that are attached
+ to edge E. */
+
+void
+remove_predictions_associated_with_edge (edge e)
+{
+ if (!bb_predictions)
+ return;
+
+ edge_prediction **preds = bb_predictions->get (e->src);
+ filter_predictions (preds, equal_edge_p, e);
+}
+
/* Clears the list of predictions stored for BB. */
static void
--
2.8.3