On Wed, May 25, 2022 at 03:13:09PM +0200, Martin Liška wrote: > 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?
Yes. The comparison is different. The first case is or_of_the_two_values < 0x80000000ULL which is predicted likely (usually both number of threads and chunk size are small numbers). While in the other case it is or_of_the_two_values >= 0x80000000UL (or 0x8000UL for 32-bit arches) and again, we predict both numbers to be small and so the comparison to be false. Jakub