aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2019-07-09 11:22:30 +0200
committerMartin Liska <marxin@gcc.gnu.org>2019-07-09 09:22:30 +0000
commitb52db15861e60f5ca82b63caabed6a00da98c7d7 (patch)
tree857cb570588eecc0f1aa364494278c4b04ce7318 /gcc
parentc2851dc2896bfc0d27b32c90cafc873f67cd6727 (diff)
downloadgcc-b52db15861e60f5ca82b63caabed6a00da98c7d7.zip
gcc-b52db15861e60f5ca82b63caabed6a00da98c7d7.tar.gz
gcc-b52db15861e60f5ca82b63caabed6a00da98c7d7.tar.bz2
Document and test __builtin_expect_with_probability.
2019-07-09 Martin Liska <mliska@suse.cz> * doc/extend.texi: Document influence on loop optimizers. 2019-07-09 Martin Liska <mliska@suse.cz> * gcc.dg/predict-17.c: Test loop optimizer assumption about loop iterations. From-SVN: r273295
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/doc/extend.texi5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/predict-17.c4
4 files changed, 17 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8fccc6b..5072a03 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -8,6 +8,11 @@
2019-07-09 Martin Liska <mliska@suse.cz>
+ * doc/extend.texi: Document influence on loop
+ optimizers.
+
+2019-07-09 Martin Liska <mliska@suse.cz>
+
* lto-compress.c (lto_normalized_zstd_level): Do not use
ZSTD_CLEVEL_DEFAULT as it is not default in old releases
of libzstd. One can use 0 as a default compression level.
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index f2619e1..0616074 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -13045,8 +13045,11 @@ when testing pointer or floating-point values.
For the purposes of branch prediction optimizations, the probability that
a @code{__builtin_expect} expression is @code{true} is controlled by GCC's
@code{builtin-expect-probability} parameter, which defaults to 90%.
+
You can also use @code{__builtin_expect_with_probability} to explicitly
-assign a probability value to individual expressions.
+assign a probability value to individual expressions. If the built-in
+is used in a loop construct, the provided probability will influence
+the expected number of iterations made by loop optimizations.
@end deftypefn
@deftypefn {Built-in Function} long __builtin_expect_with_probability
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e9d0195..ce78f77 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-07-09 Martin Liska <mliska@suse.cz>
+
+ * gcc.dg/predict-17.c: Test loop optimizer assumption
+ about loop iterations.
+
2019-07-09 Richard Biener <rguenther@suse.de>
* gcc.dg/tree-ssa/alias-access-path-1.c: Scan fre1 dump.
diff --git a/gcc/testsuite/gcc.dg/predict-17.c b/gcc/testsuite/gcc.dg/predict-17.c
index 5069aa4..45b618a 100644
--- a/gcc/testsuite/gcc.dg/predict-17.c
+++ b/gcc/testsuite/gcc.dg/predict-17.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-profile_estimate" } */
+/* { dg-options "-O2 -fdump-tree-profile_estimate-details" } */
extern int global;
@@ -11,3 +11,5 @@ void foo (int base)
/* { dg-final { scan-tree-dump "first match heuristics: 5.00%" "profile_estimate"} } */
/* { dg-final { scan-tree-dump "__builtin_expect_with_probability heuristics of edge .*->.*: 5.00%" "profile_estimate"} } */
+/* { dg-final { scan-tree-dump "is probably executed at most 19" "profile_estimate"} } */
+