diff options
author | Martin Liska <mliska@suse.cz> | 2016-06-09 13:26:32 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2016-06-09 11:26:32 +0000 |
commit | 28cd6814b5bf87cb65505df85c326f7a1975a60d (patch) | |
tree | 7133cef2e1c0ff75c2d83d40121ac1869377f5f0 /gcc | |
parent | 7d82e8e465d2466e0aab64bbaf442bfc79cb891e (diff) | |
download | gcc-28cd6814b5bf87cb65505df85c326f7a1975a60d.zip gcc-28cd6814b5bf87cb65505df85c326f7a1975a60d.tar.gz gcc-28cd6814b5bf87cb65505df85c326f7a1975a60d.tar.bz2 |
Introduce filtering for edge_predictions.
* predict.c (filter_predictions): New function.
(remove_predictions_associated_with_edge): Use the filter
function.
(equal_edge_p): New function.
From-SVN: r237253
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/predict.c | 37 |
2 files changed, 36 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ee271d4..3484047 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-06-09 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. + 2016-06-09 Stefan Bruens <stefan.bruens@rwth-aachen.de> * doc/invoke.texi (ARM Options): Use lexicographical ordering. diff --git a/gcc/predict.c b/gcc/predict.c index 837c2f3..f00428f 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,39 @@ 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 |