https://gcc.gnu.org/g:d6ca7e8e1cf62734f0257cdc668da907cf3e0297

commit r17-4621-gd6ca7e8e1cf62734f0257cdc668da907cf3e0297
Author: Richard Biener <[email protected]>
Date:   Wed Sep 23 15:46:30 2026 +0200

    tree-optimization/127571 - fix association of offset computation
    
    The expression was flagged by UBSAN, the following should match
    up the computations with the preceeding condition.
    
            PR tree-optimization/127571
            * tree-ssa-sccvn.cc (vn_walk_cb_data::push_partial_def):
            Re-associate offset computation to avoid overflow.

Diff:
---
 gcc/tree-ssa-sccvn.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index 997a37a66476..c496ff93d11c 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -2081,7 +2081,7 @@ vn_walk_cb_data::push_partial_def (pd_data pd,
          pd.offset += o;
        }
       if (pd.size + pd.offset > offseti + maxsizei)
-       pd.size = maxsizei + ((pd.size + pd.offset - offseti - maxsizei)
+       pd.size = maxsizei + ((pd.size + pd.offset - (offseti + maxsizei))
                              % BITS_PER_UNIT);
     }

Reply via email to