https://gcc.gnu.org/g:02535f61b977d5886b5e176406d0ff307dadbb15

commit r17-4491-g02535f61b977d5886b5e176406d0ff307dadbb15
Author: Filip Kastl <[email protected]>
Date:   Sun Sep 20 18:10:30 2026 +0200

    gimple: switch lowering: State that the bit test algorithm is optimal
    
    A comment regarding the bit test finding algorithm says that the
    algorithm "...tries to end up with as few clusters as possible".  It not
    only tries, it actually achieves the fewest possible clusters.  For
    people reading this code, I think it is more helpful to state that the
    algorithm is optimal in this regard.  That's what this patch addresses.
    
    Committing as obvious.
    
    gcc/ChangeLog:
    
            * tree-switch-conversion.cc (bit_test_cluster::find_bit_tests):
            State that the bit test algorithm is optimal.
    
    Signed-off-by: Filip Kastl <[email protected]>

Diff:
---
 gcc/tree-switch-conversion.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-switch-conversion.cc b/gcc/tree-switch-conversion.cc
index f3e77647daae..16564e5ee017 100644
--- a/gcc/tree-switch-conversion.cc
+++ b/gcc/tree-switch-conversion.cc
@@ -1803,8 +1803,9 @@ bit_test_cluster::find_bit_tests (vec<cluster *> 
&clusters, int max_c)
      Out: List of simple clusters and bit test clusters such that each bit test
      cluster can_be_handled() and is_beneficial()
 
-     Tries to merge consecutive clusters into bigger (bit test) ones.  Tries to
-     end up with as few clusters as possible.  */
+     Merges consecutive clusters into bigger (bit test) clusters.  Produces the
+     optimal solution -- the number of clusters in the output list is
+     minimal.  */
 
   unsigned l = clusters.length ();

Reply via email to