https://gcc.gnu.org/g:831137be51a54715b73a6178dbfb28215d1963df

commit r15-3788-g831137be51a54715b73a6178dbfb28215d1963df
Author: Andrew Pinski <quic_apin...@quicinc.com>
Date:   Sun Sep 22 13:18:30 2024 -0700

    gimple: Simplify gimple_seq_nondebug_singleton_p
    
    The implementation of gimple_seq_nondebug_singleton_p
    was convoluted on how to determine if the sequence
    was a singleton (which could contain debug statements).
    
    This simplifies the function into two calls. One to get the start
    after all of the debug statements and then check to see if it
    is at the one before the end (or there is only debug statements
    afterwards).
    
    Bootstrapped and tested on x86_64-linux-gnu (including ada).
    
    gcc/ChangeLog:
    
            * gimple-iterator.h (gimple_seq_nondebug_singleton_p):
            Rewrite to be simplely, 
gsi_start_nondebug/gsi_one_nondebug_before_end_p.
    
    Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>

Diff:
---
 gcc/gimple-iterator.h | 23 ++---------------------
 1 file changed, 2 insertions(+), 21 deletions(-)

diff --git a/gcc/gimple-iterator.h b/gcc/gimple-iterator.h
index 501f0549d925..97176d639d9f 100644
--- a/gcc/gimple-iterator.h
+++ b/gcc/gimple-iterator.h
@@ -430,28 +430,9 @@ gsi_seq (gimple_stmt_iterator i)
 inline bool
 gimple_seq_nondebug_singleton_p (gimple_seq seq)
 {
-  gimple_stmt_iterator gsi;
-
-  /* Find a nondebug gimple.  */
-  gsi.ptr = gimple_seq_first (seq);
-  gsi.seq = &seq;
-  gsi.bb = NULL;
-  while (!gsi_end_p (gsi)
-        && is_gimple_debug (gsi_stmt (gsi)))
-    gsi_next (&gsi);
-
-  /* No nondebug gimple found, not a singleton.  */
-  if (gsi_end_p (gsi))
-    return false;
-
-  /* Find a next nondebug gimple.  */
-  gsi_next (&gsi);
-  while (!gsi_end_p (gsi)
-        && is_gimple_debug (gsi_stmt (gsi)))
-    gsi_next (&gsi);
+  gimple_stmt_iterator gsi = gsi_start_nondebug (seq);
 
-  /* Only a singleton if there's no next nondebug gimple.  */
-  return gsi_end_p (gsi);
+  return gsi_one_nondebug_before_end_p (gsi);
 }
 
 #endif /* GCC_GIMPLE_ITERATOR_H */

Reply via email to