• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: __builtin_expect in clang?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: __builtin_expect in clang?


  • Subject: Re: __builtin_expect in clang?
  • From: Andreas Grosam <email@hidden>
  • Date: Sat, 12 Nov 2011 11:57:37 +0100

Thank you all for the responses and interesting information,


On Nov 10, 2011, at 2:51 PM, Andreas Grosam wrote:

> I can't see any performance differences in a very hot code spot, when using it in branches, or omitting it, or even when giving the compiler *false* hints.
> So, I'm wondering whether  __builtin_expect is implemented in clang?


On Nov 12, 2011, at 4:49 AM, Wim Lewis wrote:

> I think it isn't. I ran clang (and llvm-gcc) with -O3 -S and compared the resulting assembly for opposite values of expect, and I couldn't come up with input for which there were any differences. gcc-4.2.1 makes some fairly obvious changes  based on that hint, though (moving unlikely code out of an inner loop, for example).
>

On Nov 11, 2011, at 5:22 PM, Don Quixote de la Mancha wrote:
> I don't have the first clue whether CLang or LLVM implement
> __builtin_expect, but if they did, and their implementation was
> complete, and your use of __builtin_expect was both widespread
> throughout your code and configured correctly, I would expect it to
> make a measurable difference even for instruction sets that don't have
> branch prediction bits.

For x86_64 I'm not seeing any difference in the runtime. The code is however already written such that the compiler should be able to produce fast code. When searching for __builtin_expect in clang related forums it appears that __builtin_expect is implemented. Bit to what extent?

So, I'm still wondering, whether I actually *should* observe at least some minor difference in performance, or whether there is an unnoticed bug in the optimizer or code generator.


Andreas _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • XCode 4.2 debugger fails to show proper local variable states
      • From: Dan Stenning <email@hidden>
References: 
 >__builtin_expect in clang? (From: Andreas Grosam <email@hidden>)

  • Prev by Date: Re: Stupid problem in llvm!
  • Next by Date: Re: Protocols documentation missing required methods?
  • Previous by thread: Re: __builtin_expect in clang?
  • Next by thread: XCode 4.2 debugger fails to show proper local variable states
  • Index(es):
    • Date
    • Thread