[gcc r16-927] Fix profile_probability quality of switch

Jan Hubicka hubicka@gcc.gnu.org
Wed May 28 10:24:18 GMT 2025


https://gcc.gnu.org/g:8058e1f8857d580698c29590273e72c61de2c121

commit r16-927-g8058e1f8857d580698c29590273e72c61de2c121
Author: Jan Hubicka <hubicka@ucw.cz>
Date:   Wed May 28 12:23:48 2025 +0200

    Fix profile_probability quality of switch
    
    This fixes ages old bug I noticed only now where switch cases, in situation
    prediction is completely missing, gets all equal probability that should be
    GUESSED instead of ADJUSTED.
    
    gcc/ChangeLog:
    
            * predict.cc (set_even_probabilities): Set quality to guessed.

Diff:
---
 gcc/predict.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/predict.cc b/gcc/predict.cc
index ef31c48bfe25..16dd9b01112b 100644
--- a/gcc/predict.cc
+++ b/gcc/predict.cc
@@ -961,7 +961,7 @@ set_even_probabilities (basic_block bb,
 	    if (unlikely_edges != NULL && unlikely_edges->contains (e))
 	      e->probability = profile_probability::very_unlikely ();
 	    else
-	      e->probability = all / scale;
+	      e->probability = (all / scale).guessed ();
 	  }
 	else
 	  e->probability = profile_probability::never ();


More information about the Gcc-cvs mailing list