]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix profile_probability constructor arg [PR123153]
authorVictor Do Nascimento <victor.donascimento@arm.com>
Wed, 17 Dec 2025 14:43:41 +0000 (14:43 +0000)
committerVictor Do Nascimento <victor.donascimento@arm.com>
Thu, 18 Dec 2025 11:07:48 +0000 (11:07 +0000)
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.

gcc/tree-vect-loop-manip.cc

index 5d7d599b9749060063ca324bed21d59e2f158541..e2ea0426050e9feb28142964cdf4f0dc980ec63a 100644 (file)
@@ -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,