C -std=gnu++14 LP64 note (test for > > > > g++warnings, line 56) > > > > g++: g++.dg/warn/Warray-bounds-20.C -std=gnu++14 note (test for > > > > g++warnings, line 66) > > > > g++: g++.dg/warn/Warray-bounds-20.C -std=gnu++17 LP64 note (test for > > > > g++warnings, line 56) > > > > g++: g++.dg/warn/Warray-bounds-20.C -std=gnu++17 note (test for > > > > g++warnings, line 66) > > > > g++: g++.dg/warn/Warray-bounds-20.C -std=gnu++20 LP64 note (test for > > > > g++warnings, line 56) > > > > g++: g++.dg/warn/Warray-bounds-20.C -std=gnu++20 note (test for > > > > g++warnings, line 66) > > > > g++: g++.dg/warn/Warray-bounds-20.C -std=gnu++98 LP64 note (test for > > > > g++warnings, line 56) > > > > g++: g++.dg/warn/Warray-bounds-20.C -std=gnu++98 note (test for > > > > g++warnings, line 66) > > This seems to expect unrolling for an init loop rolling 1 times. I don't > see 1/3 of the stmts vanishing but it's definitely an interesting corner > case. That's why I was thinking of maybe adding a --param specifying > an absolute growth we consider "no growth" - but of course that's > ugly as well but it would cover these small loops. > > How do the sizes play out here after your change? Before it's > > size: 13-3, last_iteration: 2-2 > Loop size: 13 > Estimated size after unrolling: 13 After: size: 13-3, last_iteration: 2-2 Loop size: 13 Estimated size after unrolling: 20 Not unrolling loop 1: size would grow.
> > and the init is quite complex with virtual pointer inits. We do have > > size: 1 _14 = _5 + -1; > Induction variable computation will be folded away. > size: 1 _15 = _4 + 40; > BB: 3, after_exit: 1 > > where we don't realize the + 40 of _15 will be folded into the dereferences > but that would only subtract 1. > > size: 3 C::C (_23, &MEM <const void *[8]> [(void *)&_ZTT2D1 + 48B]); > > that's the biggest cost. > > To diagnose the array bound issue we rely on early unrolling since we avoid > -Warray-bounds after late unrolling due to false positives. > > This is definitely not an unrolling that preserves code size. > > > gcc: gcc.dg/Warray-bounds-68.c (test for warnings, line 18) > > > > gcc: gcc.dg/graphite/interchange-8.c execution test > > An execute fail is bad ... can we avoid this (but file a bugreport!) when It's PR115101 > placing #pragma GCC unroll before the innermost loop? We should > probably honor that in early unrolling (not sure if we do). > > > gcc: gcc.dg/tree-prof/update-cunroll-2.c scan-tree-dump-not optimized > > "Invalid sum" > > > > gcc: gcc.dg/tree-ssa/cunroll-1.c scan-tree-dump cunrolli "Last > > iteration exit edge was proved true." > > > > gcc: gcc.dg/tree-ssa/cunroll-1.c scan-tree-dump cunrolli "loop with 2 > > iterations completely unrolled" > > again the current estimate is the same before/after unrolling, here > we expect to retain one compare & branch. > > > gcc: gcc.dg/tree-ssa/dump-6.c scan-tree-dump store-merging "MEM > > <unsigned long> \\[\\(char \\*\\)\\&a8] = " > > > > gcc: gcc.dg/tree-ssa/loop-36.c scan-tree-dump-not dce3 "c.array" > > again the 2/3 scaling is difficult to warrant. The goal of the early > unrolling > pass was abstraction penalty removal which works for low trip-count loops. > So maybe that new --param for allowed growth should scale but instead > of scaling by the loop size as 2/3 does it should scale by the number of > times we peel which means offsetting the body size estimate by a constant. > > Honza? Any idea how to go forward here? > > Thanks, > Richard. > > > gcc: gcc.dg/tree-ssa/ssa-dom-cse-5.c scan-tree-dump-times dom2 "return 3;" 1 > > > > gcc: gcc.dg/tree-ssa/update-cunroll.c scan-tree-dump-times optimized > > "Invalid sum" 0 > > > > gcc: gcc.dg/tree-ssa/vrp88.c scan-tree-dump vrp1 "Folded into: if.*" > > > > gcc: gcc.dg/vect/no-vfa-vect-dv-2.c scan-tree-dump-times vect > > "vectorized 3 loops" 1 > > > > > > > > If we need some extra leeway for UL_NO_GROWTH for what we expect > > > to unroll it might be better to add sth like --param > > > nogrowth-completely-peeled-insns > > > specifying a fixed surplus size? Or we need to look at what's the problem > > > with the testcases regressing or the one you are trying to fix. > > > > > > I did experiment with better estimating cleanup done at some point > > > (see attached), > > > but didn't get to finishing that (and as said, as we're running VN on the > > > result > > > we'd ideally do that as part of the estimation somehow). > > > > > > Richard. > > > > > > > + unr_insns = unr_insns * 2 / 3; > > > > + > > > > if (unr_insns <= 0) > > > > unr_insns = 1; > > > > > > > > @@ -837,7 +847,7 @@ try_unroll_loop_completely (class loop *loop, > > > > > > > > unsigned HOST_WIDE_INT ninsns = size.overall; > > > > unsigned HOST_WIDE_INT unr_insns > > > > - = estimated_unrolled_size (&size, n_unroll); > > > > + = estimated_unrolled_size (&size, n_unroll, ul, loop); > > > > if (dump_file && (dump_flags & TDF_DETAILS)) > > > > { > > > > fprintf (dump_file, " Loop size: %d\n", (int) ninsns); > > > > -- > > > > 2.31.1 > > > > > > > > > > > > -- > > BR, > > Hongtao -- BR, Hongtao