This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Improve predictions for hot and cold labels ([[likely]], [[unlikely]]).
- From: Martin Liška <mliska at suse dot cz>
- To: Bernhard Reutner-Fischer <rep dot dot dot nop at gmail dot com>, gcc-patches at gcc dot gnu dot org
- Cc: Jason Merrill <jason at redhat dot com>, Jan Hubicka <hubicka at ucw dot cz>
- Date: Fri, 28 Dec 2018 15:52:25 +0100
- Subject: Re: [PATCH] Improve predictions for hot and cold labels ([[likely]], [[unlikely]]).
- References: <cbe66900-a132-7157-99f1-765c43368295@suse.cz> <0BBB0656-0D20-4299-B15D-CBC39A84DC23@gmail.com>
On 12/6/18 9:23 AM, Bernhard Reutner-Fischer wrote:
> On 30 November 2018 10:47:45 CET, "Martin Liška" <mliska@suse.cz> wrote:
>> Hi.
>>
>> This patch is a reaction to Jason's commit where he introduced new C++
>> attributes.
>> First I would like to align cold/hot to __builtin_expect, so I adjusted
>> probability
>> and made the predictors first match predictors.
>>
>> Second I fixed how we consider the predictors in switch statements, so
>> that
>> we can correctly predict situation in predict-3.
>>
>> Honza is fine with the patch, I'll install it later if there are no
>> objections.
>> Survives tests and bootstrap on xc86_64-linux-gnu.
>
> I don't have the sources at hand but in:
>
> +/* Branches to hot labels are likely. */
> +DEF_PREDICTOR (PRED_HOT_LABEL, "hot label", HITRATE (90),
> + PRED_FLAG_FIRST_MATCH)
> +
> +/* Branches to cold labels are extremely unlikely. */
> +DEF_PREDICTOR (PRED_COLD_LABEL, "cold label", HITRATE (90),
> + PRED_FLAG_FIRST_MATCH)
> +
>
> I would have expected cold labels to have a rather low hitrate, like maybe 2 or 7, not 90 ?
No, it's fine, as we combine that with (from predict.h):
enum prediction
{
NOT_TAKEN,
TAKEN
};
So it will get 10%.
Martin
>
> Thanks,
>