diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-04-17 16:49:00 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-04-17 16:49:00 +0000 |
commit | 89cfe6e5e9de57da5f37c19da247bb81ce13cca8 (patch) | |
tree | 463f2ea9fd7c3ba92418e1563975dde99f0150de /gcc/extend.texi | |
parent | f36193386b67c514b709fba7155e306a1b1559b2 (diff) | |
download | gcc-89cfe6e5e9de57da5f37c19da247bb81ce13cca8.tar.gz |
* builtins.c (expand_builtin_expect): New.
(expand_builtin): Call it.
* builtins.def (BUILT_IN_EXPECT): New.
* c-common.c (c_common_nodes_and_builtins): Declare __builtin_expect.
* extend.texi: Document it.
* predict.c (expected_value_to_br_prob): New.
(find_expected_value): New.
* basic-block.h (expected_value_to_br_prob): Declare.
* toplev.c (rest_of_compilation): Invoke it.
* rtl.h (NOTE_EXPECTED_VALUE): New.
(NOTE_INSN_EXPECTED_VALUE): New.
* rtl.c (note_insn_name): Update.
* print-rtl.c (print_rtx): Reorg NOTE_LINE_NUMBER special
cases; handle NOTE_INSN_EXPECTED_VALUE.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33211 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/extend.texi')
-rw-r--r-- | gcc/extend.texi | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc/extend.texi b/gcc/extend.texi index 22fe7414d2e..36c451b8485 100644 --- a/gcc/extend.texi +++ b/gcc/extend.texi @@ -3199,7 +3199,9 @@ correspond to the C library functions @code{abort}, @code{abs}, @code{sinf}, @code{sinl}, @code{sqrt}, @code{sqrtf}, @code{sqrtl}, @code{strcmp}, @code{strcpy}, and @code{strlen}. +@table @code @findex __builtin_constant_p +@item __builtin_constant_p (@var{exp}) You can use the builtin function @code{__builtin_constant_p} to determine if a value is known to be constant at compile-time and hence that GNU CC can perform constant-folding on expressions involving that @@ -3228,6 +3230,39 @@ or constructor expression (@pxref{Constructors}) and will not return 1 when you pass a constant numeric value to the inline function unless you specify the @samp{-O} option. +@findex __builtin_expect +@item __builtin_expect(@var{exp}, @var{c}) +You may use @code{__builtin_expect} to provide the compiler with +branch prediction information. In general, you should prefer to +use actual profile feedback for this (@samp{-fprofile-arcs}), as +programmers are notoriously bad at predicting how their programs +actually preform. However, there are applications in which this +data is hard to collect. + +The return value is the value of @var{exp}, which should be an +integral expression. The value of @var{c} must be a compile-time +constant. The semantics of the builtin are that it is expected +that @var{exp} == @var{c}. For example: + +@smallexample +if (__builtin_expect (x, 0)) + foo (); +@end smallexample + +@noindent +would indicate that we do not expect to call @code{foo}, since +we expect @code{x} to be zero. Since you are limited to integral +expressions for @var{exp}, you should use constructions such as + +@smallexample +if (__builtin_expect (ptr != NULL, 1)) + error (); +@end smallexample + +@noindent +when testing pointer or floating-point values. +@end table + @node Deprecated Features @section Deprecated Features |