Document and test __builtin_expect_with_probability.
authorMartin Liska <mliska@suse.cz>
Tue, 9 Jul 2019 09:22:30 +0000 (11:22 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Tue, 9 Jul 2019 09:22:30 +0000 (09:22 +0000)
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

gcc/ChangeLog
gcc/doc/extend.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/predict-17.c

index 8fccc6bdab5abaadad1e2426ef28759675725b3d..5072a03e56bf06e5196f4d6f1af24209c9dc3331 100644 (file)
@@ -6,6 +6,11 @@
        (vn_reference_lookup_pieces): Adjust.
        (vn_reference_lookup): Pass down original ref if we valueized.
 
+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
index f2619e12f93e769843da25a8c7633dc61eb5dcc0..061607411eb20f36100bfef95381e0de0270da6a 100644 (file)
@@ -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
index e9d01950ea389066f23b0f095e380f4b38442ab4..ce78f7781f514e4e6fb22f5a8cbe5d271a28d655 100644 (file)
@@ -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.
index 5069aa47c8c7df532d87dec5517e990d2cf0cc93..45b618a942cf1eb76599b3155656c47bd834a21e 100644 (file)
@@ -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"} } */
+