On Mon, Sep 08, 2025 at 02:38:48PM +0200, Richard Biener wrote: > When there's an asm goto in the latch of a loop we may not use > IP_END IVs since instantiating those would (need to) split the > latch edge which in turn invalidates IP_NORMAL position handling. > This is a revision of the PR107997 fix. > > Bootstrap and regtest running on x86_64-unknown-linux-gnu. > > PR tree-optimization/107997 > PR tree-optimization/121844 > * tree-ssa-loop-ivopts.cc (allow_ip_end_pos_p): Do not allow > IP_END for latches ending with a control stmt. > (create_new_iv): Do not split the latch edge, instead assert > that's not necessary.
LGTM. > * gcc.dg/torture/pr121844.c: New testcase. > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/torture/pr121844.c > @@ -0,0 +1,19 @@ > +/* { dg-do compile } */ > + > +#include <stdint.h> Why? Does it rely on the size of any of those types in any way? Can't you s/int32_t/int/ and s/int16_t/void/ and probably unsigned long long * for type of e? > + > +typedef uint64_t a; > +int32_t b[] = {}; > +int32_t **c; > +int16_t d() { > + a *e; This one is uninitialized, is that needed for the repro? Can't it be e.g. argument to the function instead? > + int32_t f; > + *c = &f; > + for (;;) > + asm goto("" : : : : g); > + for (; f; f--) { > + asm goto("" : : : : g); > + g: > + *e ^= b[f + 1]; > + } > +} Jakub