On 5/25/22 13:55, Jakub Jelinek wrote: > On Wed, May 25, 2022 at 01:52:46PM +0200, Martin Liška wrote: >> Similarly to g:22d9c8802add09a93308319fc37dd3a0f1125393, I would like to use >> {UN,}LIKELY macros in libgomp. If the community is fine, I'm planning doing >> the same in other GCC's libraries. > > I must say I prefer __builtin_expect over the macros any time. > > Jakub >
I respect that. Btw. I noticed one discrepancy: ./libgomp/loop_ull.c: /* Cheap overflow protection. */ if (__builtin_expect ((nthreads | ws->chunk_size_ull) < 1ULL << (sizeof (gomp_ull) * __CHAR_BIT__ / 2 - 1), 1)) ws->mode = ws->end_ull < (__LONG_LONG_MAX__ * 2ULL + 1 - (nthreads + 1) * ws->chunk_size_ull); while: ./libgomp/loop.c: /* Cheap overflow protection. */ if (__builtin_expect ((nthreads | ws->chunk_size) >= 1UL << (sizeof (long) * __CHAR_BIT__ / 2 - 1), 0)) ws->mode = 0; So once, it uses __builtin_expect(..., 1) and second time __builtin_expect(..., 0). Is it expected? Thanks, Martin