[ported from trunk r163805, adjusted to apply to linux-atomic.c in config/m68k/, the commit didn't add a ChangeLog entry so it is based on the original patch submission ] From: "Marcus Shawcroft" Subject: [PATCH, ARM] Provide __builtin_expect() hints in linux-atomic.c Date: Wed, 1 Sep 2010 16:17:57 +0100 List-Archive: The out of line linux-atomic.c code does not provide __builtin_expect() hints, this patch adds them.. gcc/ 2010-09-03 Marcus Shawcroft * config/arm/linux-atomic.c (__sync_val_compare_and_swap_4): Insert __builtin_expect(). (SUBWORD_VAL_CAS): Likewise. --- gcc-4.6.3/gcc/config/m68k/linux-atomic.c.~1~ 2012-06-18 22:09:59.000000000 +0200 +++ gcc-4.6.3/gcc/config/m68k/linux-atomic.c 2012-06-18 22:11:05.000000000 +0200 @@ -160,12 +160,12 @@ __sync_val_compare_and_swap_4 (int *ptr, { actual_oldval = *ptr; - if (oldval != actual_oldval) + if (__builtin_expect (oldval != actual_oldval, 0)) return actual_oldval; fail = __kernel_cmpxchg (actual_oldval, newval, ptr); - if (!fail) + if (__builtin_expect (!fail, 1)) return oldval; } } @@ -185,7 +185,8 @@ __sync_val_compare_and_swap_4 (int *ptr, { \ actual_oldval = *wordptr; \ \ - if (((actual_oldval & mask) >> shift) != (unsigned int) oldval) \ + if (__builtin_expect (((actual_oldval & mask) >> shift) != \ + (unsigned int) oldval, 0)) \ return (actual_oldval & mask) >> shift; \ \ actual_newval = (actual_oldval & ~mask) \ @@ -194,7 +195,7 @@ __sync_val_compare_and_swap_4 (int *ptr, fail = __kernel_cmpxchg (actual_oldval, actual_newval, \ wordptr); \ \ - if (!fail) \ + if (__builtin_expect (!fail, 1)) \ return oldval; \ } \ }