Displaying 20 results from an estimated 100 matches for "__builtin_expect".
2006 Apr 04
0
Need help debugging (long)
...uing.
Substituting charset 'ANSI_X3.4-1968' for LOCALE
Breakpoint 2, smb_iconv_close (cd=0x8412a28) at lib/iconv.c:315
315 if (cd->cd_direct) iconv_close((iconv_t)cd->cd_direct);
(gdb)
Continuing.
Breakpoint 3, iconv_close (cd=0x8412a50) at iconv_close.c:30
30 if (__builtin_expect (cd == (iconv_t *) -1L, 0))
(gdb)
Continuing.
smbd: gconv_db.c:232: __gconv_release_step: Assertion `step->__end_fct ==
((void *)0)' failed.
Program received signal SIGABRT, Aborted.
0xffffe410 in __kernel_vsyscall ()
(gdb) where
#0 0xffffe410 in __kernel_vsyscall ()
#1 0xb7ce576a in *__G...
2006 Jun 20
1
[patch] compiler.h fix use of likely/unlikely
...893f8a9..b7d9b50 100644
--- a/usr/include/klibc/compiler.h
+++ b/usr/include/klibc/compiler.h
@@ -91,12 +91,12 @@ # define __mallocfunc
#endif
/* likely/unlikely */
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))
-# define __likely(x) __builtin_expect((x), 1)
-# define __unlikely(x) __builtin_expect((x), 0)
+#if defined(__GNUC__)
+# define likely(x) __builtin_expect((x), 1)
+# define unlikely(x) __builtin_expect((x), 0)
#else
-# define __likely(x) (x)
-# define __unlikely(x) (x)
+# define likely(x) (x)
+# define unlikely(x) (x)
#endif...
2017 Apr 18
3
__builtin_expect hint ignored
https://godbolt.org/g/VvrbFZ
For the code below generated assembly is the worst possible - test 1, else test 3, else test 2 with expected value of 2 last ... Whats going on?
long case_2();
long case_3();
long case_1();
long case_else();
long test(long a) {
switch (__builtin_expect(a, 2)) {
case 2: return case_2();
case 3: return case_3();
case 1: return case_1();
case 0:
case 4:
case 5: return case_else();
default: __builtin_unreachable();
}
}
2016 Apr 22
2
[cfe-dev] [RFC] remove the llvm.expect intrinsic
...ng this is going to sound very strange, but I think that we need to understand a bit more about how this is being handled.
A while back one of my customers asked me if there was a method for advising the compiler how an if-statement was likely to resolve, and I said “sure” and told them to use ‘__builtin_expect’.
At the time I thought that the compiler was probably predicting a higher probability or true/false than was actually the case for a particular instance, as my customer was telling me that the compiler was optimising in favour of the less probable case (something the customer knew, but the inf...
2018 May 09
3
Ignored branch predictor hints
Hello,
#define likely(x) __builtin_expect((x),1)
// switch like
char * b(int e) {
if (likely(e == 0))
return "0";
else if (e == 1)
return "1";
else return "f";
}
GCC correctly prefers the first case:
b(int):
mov eax, OFFSET FLAT:.LC0
test edi, edi
jne .L7
ret
But Clang s...
2012 Oct 23
0
[LLVMdev] precondition suggestion to LLVM
Hi Niko,
Do you mean branch prediction, i.e. __builtin_expect [1]? Many
compilers support it, I think clang (LLVM's C/C++ frontend) is among
them.
- D.
[1] http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
2012/10/23 Niko Zarzani <koni10 at hotmail.it>:
> Hi all,
> Is there any way to tell LLVM some additional information about the
>...
2018 May 09
2
Ignored branch predictor hints
Hi Dávid,
Looks like you can defeat the switch conversion by adding a dummy asm(“”):
#define likely(x) __builtin_expect((x),1)
// switch like
char * b(int e) {
if (likely(e == 0))
return "0";
asm("");
if (e == 1)
return "1";
else return "f";
}
Dave
> On May 9, 2018, at 2:33 PM, Dávid Bolvanský via llvm-dev <llvm-dev at lists.llvm.org>...
2010 Dec 21
0
[LLVMdev] proposal for improving profile info support
...e. We should fix that. I've been collecting ideas from other LLVM developers over the last few weeks, and I've put them together here to solicit feedback. Most of the good ideas here are thanks to Andy Trick.
Background:
There are at least 3 different sources of profile information:
* __builtin_expect: The programmer provides branch prediction hints using this builtin function.
* Static estimates: The compiler analyzes the code and uses simple heuristics or more sophisticated analyses to estimate the profile information.
* Profile feedback: Profile information is collected during one or more e...
2018 May 09
0
Ignored branch predictor hints
...at gmail.com>:
> I did
>
> https://bugs.llvm.org/show_bug.cgi?id=37368
>
> 2018-05-09 20:29 GMT+02:00 David Zarzycki <dave at znu.io>:
>
>> I’d wager that the if-else chain is being converted to a "switch
>> statement” during an optimization pass and the __builtin_expect() hint is
>> lost. Can you file a bug? https://bugs.llvm.org
>>
>>
>> On May 9, 2018, at 1:57 PM, Dávid Bolvanský via llvm-dev <
>> llvm-dev at lists.llvm.org> wrote:
>>
>> Hello,
>>
>> #define likely(x) __builtin_expect((x),1)
>&...
2012 Oct 22
5
[LLVMdev] precondition suggestion to LLVM
Hi all,Is there any way to tell LLVM some additional information about the variables in the code in order to make better optimization?For example, if my function has a certain precondition (such as x>0) then it will be possible to better optimize the code given that information (which the compiler does not know).I am new in this field and I don't know if there are ways to tell the compiler
2007 Apr 07
2
Cannot compile 1.4.2 on Slackware 7
...his?)
However I'm currently stuck here:
/usr/src/asterisk-1.4.2# make
[LD] aelparse.o aelbison.o pbx_ael.o ael_main.o ast_expr2f.o
ast_expr2.o strcompat.o -> aelparse
aelparse.o: In function `ael_yylex':
/usr/src/asterisk-1.4.2/include/asterisk/strings.h:167: undefined
reference to `__builtin_expect'
ast_expr2f.o: In function `ast_expr':
/usr/src/asterisk-1.4.2/include/asterisk/strings.h:167: undefined
reference to `__builtin_expect'
collect2: ld returned 1 exit status
make[1]: *** [aelparse] Error 1
make: *** [utils] Error 2
I don't know enough about the internals of Asterisk...
2019 Nov 02
2
[PATCH nbdkit] server: Use GCC hints to move debug and error handling code out of hot paths.
...rver/internal.h
+++ b/server/internal.h
@@ -45,6 +45,17 @@
#include "cleanup.h"
#include "nbd-protocol.h"
+/* Define unlikely macro, but only for GCC. These are used to move
+ * debug and error handling code out of hot paths.
+ */
+#if defined(__GNUC__)
+#define unlikely(x) __builtin_expect (!!(x), 0)
+#define if_verbose if (unlikely (verbose))
+#else
+#define unlikely(x) (x)
+#define if_verbose if (verbose)
+#endif
+
#ifdef __APPLE__
#define UNIX_PATH_MAX 104
#else
@@ -262,7 +273,11 @@ extern int crypto_negotiate_tls (struct connection *conn,
__attribute__((__nonnull__ (1)));...
2011 Aug 31
2
[LLVMdev] Branch transformation with branch-weight metadata
Hello :)
I am looking around __builtin_expect() directive for optimization.
( http://llvm.org/docs/BranchWeightMetadata.html )
Since it is not included in v2.9, I am searching about it on svn trunk.
I found that the lowering phase generates branch-weight metadata node for
that directive.
However, I can't find any code related to the metad...
2010 Jul 04
0
[LLVMdev] Question about SmallVector implementation detail
...itive condition result?
> I'am interested by the reason of that, that's look curious for me.
It's a micro-optimization for code layout and code size. The idea is that we want this to get inlined, so tail duplicating the if condition would be bad. This would be a good candidate for __builtin_expect as well.
In the big picture, it probably doesn't matter much either way :)
-Chris
2016 Sep 22
2
Mark code from source to IR
Hi everyone,
I am looking at a way to mark part of a source code for an optimisation pass (or how to transfert information from source code to IR).
I want to work on C / C++ / Objective-c and Swift.
Something like:
...
//Begin Optimisation
if(i % 2){
printf(“Something”);
}
//End Optimisation
for(int i = 0; i < 10; ++i){
printf("%d, “, i);
}
printf("\n”);
…
I have found
2018 May 09
0
Ignored branch predictor hints
...ce branch predictor hints are broken in a
valid C++20 code:
https://godbolt.org/g/dpSDqd
Dňa st 9. 5. 2018, 20:40 David Zarzycki <dave at znu.io> napísal(a):
> Hi Dávid,
>
> Looks like you can defeat the switch conversion by adding a dummy asm(“”):
>
> #define likely(x) __builtin_expect((x),1)
>
> // switch like
> char * b(int e) {
> if (likely(e == 0))
> return "0";
> asm("");
> if (e == 1)
> return "1";
> else return "f";
> }
>
> Dave
>
> On May 9, 2018, at 2:33 PM,...
2013 Feb 24
3
[PATCH dontapply 0/2] tools/virtio updates for API testing
Here's a patchset to update tools/virtio with
changes in 3.8, as well as the proposed API extension.
Useful to see whether the extra level of indirection
adds measureable overhead.
I will upstream at least patch 1 soon.
Michael S. Tsirkin (2):
tools/virtio: fix build for 3.8
tools/virtio: update for the new virtio API
drivers/vhost/test.c | 4 +++-
tools/virtio/Makefile
2013 Feb 24
3
[PATCH dontapply 0/2] tools/virtio updates for API testing
Here's a patchset to update tools/virtio with
changes in 3.8, as well as the proposed API extension.
Useful to see whether the extra level of indirection
adds measureable overhead.
I will upstream at least patch 1 soon.
Michael S. Tsirkin (2):
tools/virtio: fix build for 3.8
tools/virtio: update for the new virtio API
drivers/vhost/test.c | 4 +++-
tools/virtio/Makefile
2010 Jul 04
2
[LLVMdev] Question about SmallVector implementation detail
Hello,
I have just a little question about the SmallVector implemention.
In SmallVectorImpl, the following method is currently implemented as:
void push_back(const T &Elt) {
if (this->EndX < this->CapacityX) {
Retry:
new (this->end()) T(Elt);
this->setEnd(this->end()+1);
return;
}
this->grow();
goto Retry;
}
2016 Apr 22
3
[RFC] remove the llvm.expect intrinsic
I, of course, thought the ~100 lines added by D19299 was a reasonable trade
for the ~800 lines removed in D19300.
David Li (and anyone else following along), do you still like those patches
after hearing this objection or should I abandon?
On Fri, Apr 22, 2016 at 11:55 AM, Reid Kleckner <rnk at google.com> wrote:
> Sorry, I didn't realize that was the clang side.
>
> I think