https://gcc.gnu.org/g:fa82fc957bccc0f29f2b41e66d1881ba821369ea

commit r17-4767-gfa82fc957bccc0f29f2b41e66d1881ba821369ea
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 ce2e2a8b169c..64956b05985a 100644
--- a/gcc/tree-ssa-forwprop.cc
+++ b/gcc/tree-ssa-forwprop.cc
@@ -1678,7 +1678,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