https://gcc.gnu.org/g:8ae508ca5a3cf5ed4c0d511bb41c47ed005e5a06

commit r16-7002-g8ae508ca5a3cf5ed4c0d511bb41c47ed005e5a06
Author: Andrew Pinski <[email protected]>
Date:   Fri Jan 16 20:25:56 2026 -0800

    slsr: fix overflow from create_add_on_incoming_edge [PR106883]
    
    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 <[email protected]>

Diff:
---
 gcc/gimple-ssa-strength-reduction.cc | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/gimple-ssa-strength-reduction.cc 
b/gcc/gimple-ssa-strength-reduction.cc
index abfc8e00d81d..990943c767cd 100644
--- a/gcc/gimple-ssa-strength-reduction.cc
+++ b/gcc/gimple-ssa-strength-reduction.cc
@@ -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))
     {

Reply via email to