Hi,

the STMT parameter of the new 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 based 
on GCC 16.

Tested on x86-64/Linux, OK for the mainline and 16 branch?


2026-09-29  Eric Botcazou  <[email protected]>

        * 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.

-- 
Eric Botcazou
diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
index ce2e2a8b169..64956b05985 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