From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19421 invoked by alias); 3 Jan 2008 23:46:29 -0000 Received: (qmail 19413 invoked by uid 22791); 3 Jan 2008 23:46:28 -0000 X-Spam-Check-By: sourceware.org Received: from outbound-wa4.frontbridge.com (HELO outbound6-wa4-R.bigfish.com) (216.32.181.16) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 03 Jan 2008 23:43:11 +0000 Received: from outbound6-wa4.bigfish.com (localhost.localdomain [127.0.0.1]) by outbound6-wa4-R.bigfish.com (Postfix) with ESMTP id 9EC73186B014; Thu, 3 Jan 2008 23:43:09 +0000 (UTC) Received: from mail120-wa4-R.bigfish.com (si1-wa4 [10.8.14.5]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by outbound6-wa4.bigfish.com (Postfix) with ESMTP id 9D35E16806B; Thu, 3 Jan 2008 23:43:09 +0000 (UTC) Received: from mail120-wa4 (localhost.localdomain [127.0.0.1]) by mail120-wa4-R.bigfish.com (Postfix) with ESMTP id 8610C6B8475; Thu, 3 Jan 2008 23:43:09 +0000 (UTC) X-BigFish: V X-MS-Exchange-Organization-Antispam-Report: OrigIP: 160.33.66.75;Service: EHS Received: by mail120-wa4 (MessageSwitch) id 1199403789299800_31852; Thu, 3 Jan 2008 23:43:09 +0000 (UCT) Received: from mail8.fw-sd.sony.com (mail8.fw-sd.sony.com [160.33.66.75]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail120-wa4.bigfish.com (Postfix) with ESMTP id 20C347F8085; Thu, 3 Jan 2008 23:43:09 +0000 (UTC) Received: from mail3.sjc.in.sel.sony.com (mail3.sjc.in.sel.sony.com [43.134.1.211]) by mail8.fw-sd.sony.com (8.12.11/8.12.11) with ESMTP id m03Nh83b003985; Thu, 3 Jan 2008 23:43:08 GMT Received: from constantine.playstation.sony.com ([162.49.67.15]) by mail3.sjc.in.sel.sony.com (8.12.11/8.12.11) with ESMTP id m03Nh728020478; Thu, 3 Jan 2008 23:43:07 GMT Received: from deagol.playstation.sony.com ([10.98.10.144]) by constantine.playstation.sony.com (Lotus Domino Release 7.0.2FP2) with ESMTP id 2008010315430766-1224 ; Thu, 3 Jan 2008 15:43:07 -0800 Received: from trevor by deagol.playstation.sony.com with local (Exim 3.36 #1 (Debian)) id 1JAZiN-0003Jd-00; Thu, 03 Jan 2008 15:43:07 -0800 Date: Thu, 03 Jan 2008 23:46:00 -0000 To: Hans-Peter Nilsson Cc: gcc , Russell_Olsen@playstation.sony.com, Mark Mitchell , Andrew_Pinski@PlayStation.Sony.Com, Mark Mendell Subject: Re: __builtin_expect for indirect function calls Message-ID: <20080103234307.GE5853@playstation.sony.com> References: <20071218000552.GV3656@playstation.sony.com> <20071221220630.Y67443@dair.pair.com> MIME-Version: 1.0 In-Reply-To: <20071221220630.Y67443@dair.pair.com> User-Agent: Mutt/1.5.13 (2006-08-11) From: trevor_smigiel@playstation.sony.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2008-01/txt/msg00031.txt.bz2 > > > > which returns the value of FP with the same type as FP, and tells the > > compiler that PFP is the expected target of FP. Trival examples: > > > > typedef void (*fptr_t)(void); > > > > extern void foo(void); > > > > void > > call_fp (fptr_t fp) > > { > > /* Call the function pointed to by fp, but predict it as if it is > > calling foo() */ > > __builtin_expect_call (fp, foo)(); > > __builtin_expect (fp, foo); /* alt __builtin_expect (fp == foo, 1); */ > fp (); > > } > > > > void > > call_fp_predicted (fptr_t fp, fptr_t predicted) > > { > > /* same as above but the function we are calling doesn't have to be > > known at compile time */ > > __builtin_expect_call (fp, predicted)(); > > __builtin_expect (fp, predicted); > fp(); > > I guess the information just isn't readily available in the > preferred form when needed and *that* part could more or less > simply be fixed? The main reason I didn't like this is that in some other context 'fp' could be any expression, potentially with side effects. This would require either special handling by the compiler, or the user would have to be sure to write it such that the side effects only happen once. Trevor