This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Prevent loops from being optimized away
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 1 Apr 2016 10:18:10 -0500
- Subject: Re: [PATCH] Prevent loops from being optimized away
- Authentication-results: sourceware.org; auth=none
- References: <9fc51a58cc354a934ff5a5e2b232dae520090e2b dot 1459485314 dot git dot segher at kernel dot crashing dot org> <CAFiYyc2qMkR+5nezXENWJqL71U8m3HJBoq7C1EuPoxK-a5n4BQ at mail dot gmail dot com>
On Fri, Apr 01, 2016 at 09:36:49AM +0200, Richard Biener wrote:
> On Fri, Apr 1, 2016 at 6:54 AM, Segher Boessenkool
> <segher@kernel.crashing.org> wrote:
> > Sometimes people write loops that they do not want optimized away, even
> > when the compiler can replace those loops by a simple expression (or
> > nothing). For such people, this patch adds a compiler option.
> >
> > Bootstrapped on powerpc64-linux; regression check still in progress
> > (with Init(1) to actually test anything).
>
> -fno-tree-scev-cprop? -O0?
There are other cases where GCC can delete loops, for example cddce1.
> A new compiler option for this is complete overkill (and it's implementation
> is gross ;)). Semantics are also unclear, your patch would only make sure
> to preserve an empty loop with the asm in the latch, it wouldn't disallow
> replacing the overall effect with a computation.
That's right, and the loop can even still be unrolled, even fully
unrolled (which is good, not only should we not desert the loop but
we also shouldn't run around so much).
> Your patch would also miss a few testcases.
It already makes ~2000 (mainly vectorisation) testcases fail, is that
not enough coverage? :-)
Cheers,
Segher