https://gcc.gnu.org/g:3ecf5b73c7f1104441dee2d591e1cb47785f3fa7

commit r17-5330-g3ecf5b73c7f1104441dee2d591e1cb47785f3fa7
Author: linden <[email protected]>
Date:   Wed Oct 14 08:35:02 2026 +1300

    tree-ssa-ccp: avoid copying lattice values and shift counts
    
    valid_lattice_transition only reads its ccp_prop_value_t arguments, so
    take them by const reference.  bit_value_binop's shift case copied r2val
    into a widest_int it never modifies; use r2val directly (the rotate case
    keeps its copy, as it negates it).  No functional change.
    
    gcc/ChangeLog:
    
            * tree-ssa-ccp.cc (valid_lattice_transition): Take old_val and
            new_val by const reference.
            (bit_value_binop): In the shift case, use r2val directly instead
            of a local copy.
    
    Signed-off-by: linden <[email protected]>

Diff:
---
 gcc/tree-ssa-ccp.cc | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc
index 9930d78956fe..981346230b05 100644
--- a/gcc/tree-ssa-ccp.cc
+++ b/gcc/tree-ssa-ccp.cc
@@ -433,7 +433,8 @@ canonicalize_value (ccp_prop_value_t *val)
 /* Return whether the lattice transition is valid.  */
 
 static bool
-valid_lattice_transition (ccp_prop_value_t old_val, ccp_prop_value_t new_val)
+valid_lattice_transition (const ccp_prop_value_t &old_val,
+                         const ccp_prop_value_t &new_val)
 {
   /* Lattice transitions must always be monotonically increasing in
      value.  */
@@ -1633,25 +1634,24 @@ bit_value_binop (enum tree_code code, signop sgn, int 
width,
         is zero.  */
       if (r2mask == 0)
        {
-         widest_int shift = r2val;
-         if (shift == 0)
+         if (r2val == 0)
            {
              *mask = r1mask;
              *val = r1val;
            }
          else
            {
-             if (wi::neg_p (shift, r2type_sgn))
+             if (wi::neg_p (r2val, r2type_sgn))
                break;
              if (code == RSHIFT_EXPR)
                {
-                 *mask = wi::rshift (wi::ext (r1mask, width, sgn), shift, sgn);
-                 *val = wi::rshift (wi::ext (r1val, width, sgn), shift, sgn);
+                 *mask = wi::rshift (wi::ext (r1mask, width, sgn), r2val, sgn);
+                 *val = wi::rshift (wi::ext (r1val, width, sgn), r2val, sgn);
                }
              else
                {
-                 *mask = wi::ext (r1mask << shift, width, sgn);
-                 *val = wi::ext (r1val << shift, width, sgn);
+                 *mask = wi::ext (r1mask << r2val, width, sgn);
+                 *val = wi::ext (r1val << r2val, width, sgn);
                }
            }
        }

Reply via email to