On Fri, Aug 13, 2021 at 06:22:48PM -0700, apinski--- via Gcc-patches wrote: > From: Andrew Pinski <apin...@marvell.com> > > Even though this does not change the generated code, > it does improve the initial RTL generation. > > gcc/ChangeLog: > > * tree-ssa-math-opts.c (match_arith_overflow): > Add range and nonzero bits information to > the new overflow ssa name. Also fold > the use statement. > --- > gcc/tree-ssa-math-opts.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c > index c4a6492b50d..bb7edeaa6f7 100644 > --- a/gcc/tree-ssa-math-opts.c > +++ b/gcc/tree-ssa-math-opts.c > @@ -4221,6 +4221,8 @@ match_arith_overflow (gimple_stmt_iterator *gsi, gimple > *stmt, > } > } > tree ovf = make_ssa_name (type); > + set_range_info (ovf, VR_RANGE, wi::zero (TYPE_PRECISION (type)), wi::one > (TYPE_PRECISION (type)));
Too long line. > + set_nonzero_bits (ovf, wi::one (TYPE_PRECISION (type))); Are you sure this is really needed? set_range_info should have computed that one from the range already: /* If it is a range, try to improve nonzero_bits from the min/max. */ if (range_type == VR_RANGE) { wide_int xorv = ri->get_min () ^ ri->get_max (); if (xorv != 0) xorv = wi::mask (precision - wi::clz (xorv), false, precision); ri->set_nonzero_bits (ri->get_nonzero_bits () & (ri->get_min () | xorv)); } > @@ -4279,6 +4281,8 @@ match_arith_overflow (gimple_stmt_iterator *gsi, gimple > *stmt, > gimple_assign_set_rhs1 (use_stmt, cond); > } > } > + gimple_stmt_iterator gsi1 = gsi_for_stmt (use_stmt); > + fold_stmt (&gsi1); > update_stmt (use_stmt); I don't think it is safe to do that here. First of all, the update_stmt is right after it, then some further code that still uses use_stmt right below and this is in a loop that iterates imm uses of that use_stmt too. If you want to fold use_stmt, can't it be done after the whole loop? > if (code == MULT_EXPR && use_stmt != orig_use_stmt) > { > -- > 2.27.0 Jakub