[gcc r16-6243] Fix profile_probability constructor arg [PR123153]
Victor Do Nascimento
victorldn@gcc.gnu.org
Thu Dec 18 11:08:05 GMT 2025
https://gcc.gnu.org/g:24bf392581ea6d931afc1e97d90d6a2d6bdaa183
commit r16-6243-g24bf392581ea6d931afc1e97d90d6a2d6bdaa183
Author: Victor Do Nascimento <victor.donascimento@arm.com>
Date: Wed Dec 17 14:43:41 2025 +0000
Fix profile_probability constructor arg [PR123153]
Given that profile probability is computed as an unsigned integer
value in the [0, max_probability = (uint32_t) 1 << (n_bits - 2)]
range (as opposed to a [0, 1] float), 50/50 likeihoods are encoded as
`even()', mapping to `max_probability / 2'.
The previous use of 0.5 for an even probability was, as a consequence
of the implicit `double' -> `uint32_t' conversion, silently set to 0 by
GCC when not using the `-Wconversion' flag.
We therefore replace the erroneous `probability (0.5, GUESSED)'
initialization with its correct `profile_probability::even ()'
counterpart.
gcc/ChangeLog:
PR tree-optimization/123153
* tree-vect-loop-manip.cc
(slpeel_tree_duplicate_loop_to_edge_cfg): use
profile_probability::even () for even likelihood.
Diff:
---
gcc/tree-vect-loop-manip.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc
index 5d7d599b9749..e2ea0426050e 100644
--- a/gcc/tree-vect-loop-manip.cc
+++ b/gcc/tree-vect-loop-manip.cc
@@ -1976,7 +1976,7 @@ slpeel_tree_duplicate_loop_to_edge_cfg (class loop *loop, edge loop_exit,
edge dup_exit = make_edge (bbcond, new_exit->dest, latch_is_false
? EDGE_TRUE_VALUE : EDGE_FALSE_VALUE);
- profile_probability probability (0.5, GUESSED);
+ profile_probability probability = profile_probability::even ();
to_latch_e->probability = dup_exit->probability = probability;
set_immediate_dominator (CDI_DOMINATORS, dup_exit->src,
More information about the Gcc-cvs
mailing list