From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30709 invoked by alias); 5 Jan 2008 10:40:49 -0000 Received: (qmail 30699 invoked by uid 22791); 5 Jan 2008 10:40:48 -0000 X-Spam-Check-By: sourceware.org Received: from fg-out-1718.google.com (HELO fg-out-1718.google.com) (72.14.220.152) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 05 Jan 2008 10:40:30 +0000 Received: by fg-out-1718.google.com with SMTP id d23so3584156fga.28 for ; Sat, 05 Jan 2008 02:40:28 -0800 (PST) Received: by 10.82.138.6 with SMTP id l6mr31457861bud.13.1199529628181; Sat, 05 Jan 2008 02:40:28 -0800 (PST) Received: by 10.82.145.6 with HTTP; Sat, 5 Jan 2008 02:40:28 -0800 (PST) Message-ID: <84fc9c000801050240l6918b59dpd519dea81ddd3ad@mail.gmail.com> Date: Sat, 05 Jan 2008 10:40:00 -0000 From: "Richard Guenther" To: "Mark Mitchell" Subject: Re: __builtin_expect for indirect function calls Cc: trevor_smigiel@playstation.sony.com, "Hans-Peter Nilsson" , gcc , Russell_Olsen@playstation.sony.com, Andrew_Pinski@playstation.sony.com, "Mark Mendell" In-Reply-To: <477F190B.2000807@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20071218000552.GV3656@playstation.sony.com> <20071221220630.Y67443@dair.pair.com> <4772A350.6030907@codesourcery.com> <20080103233308.GD5853@playstation.sony.com> <477F190B.2000807@codesourcery.com> X-IsSubscribed: yes 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/msg00041.txt.bz2 On Jan 5, 2008 6:43 AM, Mark Mitchell wrote: > trevor_smigiel@playstation.sony.com wrote: > > > Currently, the prototype for __builtin_expect is > > > > long __builtin_expect (long expression, long constant); > > > > Extending it to functions would change it to > > > > T __builtin_expect (T expression, T expected); > > Yes, it really makes more sense for __builtin_expect to be polymorphic > in this way anyhow. I consider it a design wart that it's defined in > terms of "long". (For example, this means you can't use it for "long > long"!) > > > Rather than the above definition, we could choose not to inspect the > > context and just say: > > * T is the type of 'expression' > > * 'expected' is allowed to be a non-constant > > > > In this case I think there would only be compatibility issues with > > unusual uses of __builtin_expect, for example, if it was being used in a > > function argument and its type effected overload resolution. > > I think this is the abstractly right approach. However, you're right > that there are backwards-compatibility issues. Another issue is that on > platforms where "long" and "int" do not have the same width, something like: > > sizeof(__builtin_expect(1, 1)) > > will change its value. And, the current prototype is documented in the > manual. > > What do people think? Do we have the leeway to change this? Or should > we add __builtin_expect2? Or add an -fno-polymorphic-builtin-expect? > Or...? I think we should simply make __builtin_expect polymorphic, but make sure to promote integral arguments with rank less than long to long. Richard.