From patchwork Wed Sep 1 15:17:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcus Shawcroft X-Patchwork-Id: 63383 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 83E1AB7154 for ; Thu, 2 Sep 2010 01:18:15 +1000 (EST) Received: (qmail 24534 invoked by alias); 1 Sep 2010 15:18:10 -0000 Received: (qmail 24518 invoked by uid 22791); 1 Sep 2010 15:18:09 -0000 X-SWARE-Spam-Status: No, hits=-0.2 required=5.0 tests=AWL, BAYES_00, MSGID_MULTIPLE_AT, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cam-admin0.cambridge.arm.com (HELO cam-admin0.cambridge.arm.com) (217.140.96.50) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 01 Sep 2010 15:18:03 +0000 Received: from cam-owa2.Emea.Arm.com (cam-owa2.emea.arm.com [10.1.105.18]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id o81FGIF9003166 for ; Wed, 1 Sep 2010 16:16:18 +0100 (BST) Received: from e102573 ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 1 Sep 2010 16:18:00 +0100 From: "Marcus Shawcroft" To: Subject: [PATCH, ARM] Provide __builtin_expect() hints in linux-atomic.c Date: Wed, 1 Sep 2010 16:17:57 +0100 Message-ID: <000401cb49e8$db9d98d0$92d8ca70$@shawcroft@arm.com> MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org The out of line linux-atomic.c code does not provide __builtin_expect() hints, this patch adds them.. Regression tested. Ok? /Marcus 2010-09-01 Marcus Shawcroft * config/arm/linux-atomic.c (__sync_val_compare_and_swap_4): Insert __builtin_expect(). (SUBWORD_VAL_CAS): Likewise. diff --git a/gcc/config/arm/linux-atomic.c b/gcc/config/arm/linux-atomic.c index 685f16b..ddedeb5 100644 --- a/gcc/config/arm/linux-atomic.c +++ b/gcc/config/arm/linux-atomic.c @@ -155,12 +155,12 @@ __sync_val_compare_and_swap_4 (int *ptr, int oldval, int newval) { 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; } } @@ -180,7 +180,8 @@ __sync_val_compare_and_swap_4 (int *ptr, int oldval, int newval) { \ 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) \ @@ -189,7 +190,7 @@ __sync_val_compare_and_swap_4 (int *ptr, int oldval, int newval) fail = __kernel_cmpxchg (actual_oldval, actual_newval, \ wordptr); \ \ - if (!fail) \ + if (__builtin_expect (!fail, 1)) \ return oldval; \ } \ }