]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
slsr: fix overflow from create_add_on_incoming_edge [PR106883]
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Sat, 17 Jan 2026 04:25:56 +0000 (20:25 -0800)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Fri, 23 Jan 2026 16:03:07 +0000 (08:03 -0800)
This fixes the overlfow that might be introduced from
creater_add_on_incoming_edge. I have not found a testcase where this
shows up, there possibility could be.

PR tree-optimization/106883

gcc/ChangeLog:

* gimple-ssa-strength-reduction.cc (create_add_on_incoming_edge): Rewrite
the new addition on the edge too.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
gcc/gimple-ssa-strength-reduction.cc

index abfc8e00d81df154c5b29f0defd9d10b441b8928..990943c767cd54c97d2e0d62be2ebb06f6144fca 100644 (file)
@@ -2364,7 +2364,14 @@ create_add_on_incoming_edge (slsr_cand_t c, tree basis_name,
     }
 
   gimple_set_location (new_stmt, loc);
-  gsi_insert_on_edge (e, new_stmt);
+  if (gimple_needing_rewrite_undefined (new_stmt))
+    {
+      gimple_seq stmts;
+      stmts = rewrite_to_defined_unconditional (new_stmt);
+      gsi_insert_seq_on_edge (e, stmts);
+    }
+  else
+    gsi_insert_on_edge (e, new_stmt);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {