On Sun, Apr 27, 2025 at 10:20 PM Andrew Pinski <pins...@gmail.com> wrote:
>
> On Sat, Apr 5, 2025 at 4:56 AM Andrew Pinski <quic_apin...@quicinc.com> wrote:
> >
> > After EVRP was switched to the ranger (r12-2305-g398572c1544d8b), we are 
> > better handling the case
> > where __builtin_unreachable comes after a loop. Instead of removing 
> > __builtin_unreachable and having
> > the loop become an infinite one; it is kept around longer and allows GCC to 
> > unroll the loop 2 times instead
> > of 3 times. When GCC unrolled the loop 3 times, GCC would produce a bogus 
> > Warray-bounds warning for the 3rd
> > iteration.
> > This adds the testcase to make sure we don't regress on this case. It is 
> > originally extracted from LLVM source
> > code too.
>
> Ping? It would be useful to have this testcase so we don't regress the
> warning; especially since this is extracted from LLVM (with asserts
> turned off which IIRC is the default way of building LLVM these days).

OK.

> Thanks,
> Andrew
>
> >
> >         PR tree-optimization/100038
> >
> > gcc/testsuite/ChangeLog:
> >
> >         * g++.dg/tree-ssa/pr100038.C: New test.
> >
> > Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>
> > ---
> >  gcc/testsuite/g++.dg/tree-ssa/pr100038.C | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> >  create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr100038.C
> >
> > diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr100038.C 
> > b/gcc/testsuite/g++.dg/tree-ssa/pr100038.C
> > new file mode 100644
> > index 00000000000..7024c4db2b2
> > --- /dev/null
> > +++ b/gcc/testsuite/g++.dg/tree-ssa/pr100038.C
> > @@ -0,0 +1,17 @@
> > +// { dg-do compile }
> > +// { dg-options "-O2 -Wextra -Wall -Warray-bounds" }
> > +
> > +struct SparseBitVectorElement {
> > +  long Bits[2];
> > +  int find_first() const;
> > +};
> > +
> > +// we should not get an `array subscript 2 is above array bounds of`
> > +// warning here because we have an unreachable at that point
> > +
> > +int SparseBitVectorElement::find_first() const {
> > +  for (unsigned i = 0; i < 2; ++i)
> > +    if (Bits[i]) // { dg-bogus "is above array bounds of" }
> > +      return i;
> > +  __builtin_unreachable();
> > +}
> > --
> > 2.43.0
> >

Reply via email to