The expression was flagged by UBSAN, the following should match
up the computations with the preceeding condition.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

        PR tree-optimization/127571
        * tree-ssa-sccvn.cc (vn_walk_cb_data::push_partial_def):
        Re-associate offset computation to avoid overflow.
---
 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 997a37a6647..c496ff93d11 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);
     }
 
-- 
2.51.0

Reply via email to