Hi. After we introduced new non-NULL malloc predictor, we can remove these __builtin_expects. Predictors will change in following way:
Before: Predictions for bb 5 first match heuristics: 10.00% combined heuristics: 10.00% __builtin_expect heuristics of edge 5->6: 10.00% call heuristics of edge 5->6 (ignored): 33.00% loop exit heuristics of edge 5->9 (ignored): 5.50% After: Predictions for bb 5 first match heuristics: 0.04% combined heuristics: 0.04% pointer (on trees) heuristics of edge 5->6 (ignored): 30.00% malloc returned non-NULL heuristics of edge 5->6: 0.04% call heuristics of edge 5->6 (ignored): 33.00% loop exit heuristics of edge 5->9 (ignored): 5.50% Maybe there are similar allocation-related expects, but I haven't found them. Ready after it survives regression tests? Martin libstdc++-v3/ChangeLog: 2018-08-10 Martin Liska <mli...@suse.cz> * libsupc++/new_op.cc (new): Remove __builtin_expect as malloc predictor can handle that. * libsupc++/new_opa.cc: Likewise. * libsupc++/new_opnt.cc (new): Likewise. --- libstdc++-v3/libsupc++/new_op.cc | 2 +- libstdc++-v3/libsupc++/new_opa.cc | 2 +- libstdc++-v3/libsupc++/new_opnt.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/libstdc++-v3/libsupc++/new_op.cc b/libstdc++-v3/libsupc++/new_op.cc index 3a1e38d9df7..3caa0bab2ea 100644 --- a/libstdc++-v3/libsupc++/new_op.cc +++ b/libstdc++-v3/libsupc++/new_op.cc @@ -47,7 +47,7 @@ operator new (std::size_t sz) _GLIBCXX_THROW (std::bad_alloc) if (sz == 0) sz = 1; - while (__builtin_expect ((p = malloc (sz)) == 0, false)) + while ((p = malloc (sz)) == 0) { new_handler handler = std::get_new_handler (); if (! handler) diff --git a/libstdc++-v3/libsupc++/new_opa.cc b/libstdc++-v3/libsupc++/new_opa.cc index 68eac5b8ceb..a27ff843ca1 100644 --- a/libstdc++-v3/libsupc++/new_opa.cc +++ b/libstdc++-v3/libsupc++/new_opa.cc @@ -126,7 +126,7 @@ operator new (std::size_t sz, std::align_val_t al) #endif using __gnu_cxx::aligned_alloc; - while (__builtin_expect ((p = aligned_alloc (align, sz)) == 0, false)) + while ((p = aligned_alloc (align, sz)) == 0) { new_handler handler = std::get_new_handler (); if (! handler) diff --git a/libstdc++-v3/libsupc++/new_opnt.cc b/libstdc++-v3/libsupc++/new_opnt.cc index a2dc33ad4d3..faab44e66c2 100644 --- a/libstdc++-v3/libsupc++/new_opnt.cc +++ b/libstdc++-v3/libsupc++/new_opnt.cc @@ -40,7 +40,7 @@ operator new (std::size_t sz, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT if (sz == 0) sz = 1; - while (__builtin_expect ((p = malloc (sz)) == 0, false)) + while ((p = malloc (sz)) == 0) { new_handler handler = std::get_new_handler (); if (! handler)