Patch is OK.

Thanks,
Tamar
________________________________
From: Victor Do Nascimento <[email protected]>
Sent: Thursday, December 18, 2025 10:13 AM
To: [email protected] <[email protected]>
Cc: Tamar Christina <[email protected]>; [email protected] 
<[email protected]>; Victor Do Nascimento <[email protected]>
Subject: [PATCH] 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.
---
 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 5d7d599b974..e2ea0426050 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,
--
2.43.0

Reply via email to