https://gcc.gnu.org/g:174b6d942ed142a9c013fd8ca301f6b4124a1cf5

commit r17-6375-g174b6d942ed142a9c013fd8ca301f6b4124a1cf5
Author: Andrea Pinski <[email protected]>
Date:   Tue Nov 17 14:26:58 2026 -0800

    range-fold: Fix register_outgoing_edges variable definitions
    
    This is based on the review from
    
https://gcc.sashiko.dev/#/patchset/20261027010152.2642509-1-andrew.pinski%40oss.qualcomm.com
    But reading the code, this was pre-existing issue just made worse
    by my patch. Anyways this moves the definition of r1/r2 to each of the
    branches which will make sure the memory is free'd correctly.
    
    Pushed as obvious after bootstrap/test on x86_64-linux-gnu.
    
    gcc/ChangeLog:
    
            * gimple-range-fold.cc (fur_source::register_outgoing_edges): Move
            the definitions of r1/r2 to the branches which use them.
    
    Signed-off-by: Andrea Pinski <[email protected]>

Diff:
---
 gcc/gimple-range-fold.cc | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index 2f552628c56f..ea26f07b0a4f 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -1951,9 +1951,9 @@ fur_source::register_outgoing_edges (gcond *s, irange 
&lhs_range,
   // if (a_2 < b_5)
   tree ssa1 = gimple_range_ssa_p (handler.operand1 ());
   tree ssa2 = gimple_range_ssa_p (handler.operand2 ());
-  value_range r1,r2;
   if (ssa1 && ssa2)
     {
+      value_range r1,r2;
       r1.set_varying (TREE_TYPE (ssa1));
       r2.set_varying (TREE_TYPE (ssa2));
       if (e0)
@@ -1994,12 +1994,13 @@ fur_source::register_outgoing_edges (gcond *s, irange 
&lhs_range,
       value_range r (TREE_TYPE (name));
       if (ssa1 && ssa2)
        {
-         r1.set_varying (TREE_TYPE (ssa1));
-         r2.set_varying (TREE_TYPE (ssa2));
          if (e0 && gori ()->edge_range_p (r, e0, name, *m_query)
              && !r.undefined_p ()
              && !r.varying_p ())
            {
+             value_range r1,r2;
+             r1.set_varying (TREE_TYPE (ssa1));
+             r2.set_varying (TREE_TYPE (ssa2));
              if (!gori ()->edge_range_p (r1, e0, ssa1, *m_query)
                  || r1.undefined_p ())
                r1.set_varying (TREE_TYPE (ssa1));
@@ -2014,6 +2015,9 @@ fur_source::register_outgoing_edges (gcond *s, irange 
&lhs_range,
              && !r.undefined_p ()
              && !r.varying_p ())
            {
+             value_range r1,r2;
+             r1.set_varying (TREE_TYPE (ssa1));
+             r2.set_varying (TREE_TYPE (ssa2));
              if (!gori ()->edge_range_p (r1, e1, ssa1, *m_query)
                  || r1.undefined_p ())
                r1.set_varying (TREE_TYPE (ssa1));

Reply via email to