https://gcc.gnu.org/g:91bfbe9389b0783eaabaea682b10cd85b4dd2002

commit r16-9712-g91bfbe9389b0783eaabaea682b10cd85b4dd2002
Author: Eric Botcazou <[email protected]>
Date:   Tue Sep 29 20:46:24 2026 +0200

    Fix pasto in optimize_agr_copyprop_1
    
    The STMT parameter of optimize_agr_copyprop_1 in tree-ssa-forwprop.cc is
    only used for the dump file:
    
      if (dump_file && (dump_flags & TDF_DETAILS))
        {
          fprintf (dump_file, "Simplified\n  ");
          print_gimple_stmt (dump_file, use_stmt, 0, dump_flags);
          fprintf (dump_file, "after previous\n  ");
          print_gimple_stmt (dump_file, stmt, 0, dump_flags);
        }
    
    so it makes no sense to use the index of its BB to purge EH edges:
    
      if (maybe_clean_or_replace_eh_stmt (orig_stmt, use_stmt))
        bitmap_set_bit (to_purge, gimple_bb (stmt)->index);
    
    Instead the index of the BB of USE_STMT needs to be used, as in the attached
    patch.  This fixes the failure of 4 ACATS tests with a modified compiler.
    
    gcc/
            * tree-ssa-forwprop.cc (optimize_agr_copyprop_1): Use the index of
            the basic block of USE_STMT instead of STMT to purge EH edges.

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

diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
index ce8bd0e0599d..3971ff024479 100644
--- a/gcc/tree-ssa-forwprop.cc
+++ b/gcc/tree-ssa-forwprop.cc
@@ -1687,7 +1687,7 @@ optimize_agr_copyprop_1 (gimple *stmt, gimple *use_stmt,
       print_gimple_stmt (dump_file, use_stmt, 0, dump_flags);
     }
   if (maybe_clean_or_replace_eh_stmt (orig_stmt, use_stmt))
-    bitmap_set_bit (to_purge, gimple_bb (stmt)->index);
+    bitmap_set_bit (to_purge, gimple_bb (use_stmt)->index);
   statistics_counter_event (cfun, "copy prop for aggregate", 1);
 }

Reply via email to