On Mon, 5 Feb 2024, Tamar Christina wrote: > > It looks like LOOP_VINFO_EARLY_BRK_STORES is "reverse"? Is that > > why you are doing gsi_move_before + gsi_prev? Why do gsi_prev > > at all? > > > > As discussed on IRC, then how about this one. > Incremental building passed all tests and bootstrap is running. > > Ok for master if bootstrap and regtesting clean? > > Thanks, > Tamar > > gcc/ChangeLog: > > PR tree-optimization/113731 > * gimple-iterator.cc (gsi_move_before): Take new parameter for update > method. > * gimple-iterator.h (gsi_move_before): Default new param to > GSI_SAME_STMT. > * tree-vect-loop.cc (move_early_exit_stmts): Call gsi_move_before with > GSI_NEW_STMT. > > gcc/testsuite/ChangeLog: > > PR tree-optimization/113731 > * gcc.dg/vect/vect-early-break_111-pr113731.c: New test. > > --- inline copy of patch --- > > diff --git a/gcc/gimple-iterator.cc b/gcc/gimple-iterator.cc > index > 517c53376f0511af59e124f52ec7be566a6c4789..f67bcfbfdfdd7c6cb0ad0130972f5b1dc4429bcf > 100644 > --- a/gcc/gimple-iterator.cc > +++ b/gcc/gimple-iterator.cc > @@ -666,10 +666,11 @@ gsi_move_after (gimple_stmt_iterator *from, > gimple_stmt_iterator *to) > > > /* Move the statement at FROM so it comes right before the statement > - at TO. */ > + at TO using method M. */ > > void > -gsi_move_before (gimple_stmt_iterator *from, gimple_stmt_iterator *to) > +gsi_move_before (gimple_stmt_iterator *from, gimple_stmt_iterator *to, > + gsi_iterator_update m = GSI_SAME_STMT)
Looks like the wrong patch attached? This should be like in the ChangeLog. OK with that change Richard. > { > gimple *stmt = gsi_stmt (*from); > gsi_remove (from, false); > @@ -677,7 +678,7 @@ gsi_move_before (gimple_stmt_iterator *from, > gimple_stmt_iterator *to) > /* For consistency with gsi_move_after, it might be better to have > GSI_NEW_STMT here; however, that breaks several places that expect > that TO does not change. */ > - gsi_insert_before (to, stmt, GSI_SAME_STMT); > + gsi_insert_before (to, stmt, m); > } > > > diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_111-pr113731.c > b/gcc/testsuite/gcc.dg/vect/vect-early-break_111-pr113731.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..2d6db91df97625a7f11609d034e89af0461129b2 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_111-pr113731.c > @@ -0,0 +1,21 @@ > +/* { dg-do compile } */ > +/* { dg-add-options vect_early_break } */ > +/* { dg-require-effective-target vect_early_break } */ > +/* { dg-require-effective-target vect_int } */ > + > +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ > + > +char* inet_net_pton_ipv4_bits; > +char inet_net_pton_ipv4_odst; > +void __errno_location(); > +void inet_net_pton_ipv4(); > +void inet_net_pton() { inet_net_pton_ipv4(); } > +void inet_net_pton_ipv4(char *dst, int size) { > + while ((inet_net_pton_ipv4_bits > dst) & inet_net_pton_ipv4_odst) { > + if (size-- <= 0) > + goto emsgsize; > + *dst++ = '\0'; > + } > +emsgsize: > + __errno_location(); > +} > diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc > index > 30b90d99925bea74caf14833d8ab1695607d0fe9..9aba94bd6ca2061a19487ac4a2735a16d03bcbee > 100644 > --- a/gcc/tree-vect-loop.cc > +++ b/gcc/tree-vect-loop.cc > @@ -11800,8 +11800,7 @@ move_early_exit_stmts (loop_vec_info loop_vinfo) > dump_printf_loc (MSG_NOTE, vect_location, "moving stmt %G", stmt); > > gimple_stmt_iterator stmt_gsi = gsi_for_stmt (stmt); > - gsi_move_before (&stmt_gsi, &dest_gsi); > - gsi_prev (&dest_gsi); > + gsi_move_before (&stmt_gsi, &dest_gsi, GSI_NEW_STMT); > } > > /* Update all the stmts with their new reaching VUSES. */ > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)