> Unlike strlenopt-80.c which is a compile-time test that verifies
> that the optimization successfully folds the strlen expressions,
> strlenopt-81.c is a runtime test that verifies the optimization
> isn't done when it might not be safe.   It shouldn't fail anywhere,
> whether or not the optimization is actually done.  Are you seeing
> it fail on some targets?  (That would suggest a bug.)

Yeah, I got link fail on RISC-V, error message is:
undefined reference to `test_on_line_101_not_eliminated'

And Jim told me there is already a bug entry for this issue:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92128

It cause the __builtin_strlen not optimized/folded in test_local_cpy_4,
and the reason is blocked by __builtin_memcpy, it's same issue in
strlenopt-80.c, so I there is two way to fix this issue:

1. check result and call fail function instead of using ELIM marco.
2. Only allow part of target run this testcase like strlenopt-80.c.

This patch take the second way.

Thanks :)


On Sat, Feb 15, 2020 at 1:22 AM Martin Sebor <mse...@gmail.com> wrote:
>
> On 2/13/20 8:34 PM, Kito Cheng wrote:
> >   - strlenopt-81.c has same limitation as strlenopt-80.c, this
> >     optimization only work when memcpy expand into load/store.
>
> Unlike strlenopt-80.c which is a compile-time test that verifies
> that the optimization successfully folds the strlen expressions,
> strlenopt-81.c is a runtime test that verifies the optimization
> isn't done when it might not be safe.   It shouldn't fail anywhere,
> whether or not the optimization is actually done.  Are you seeing
> it fail on some targets?  (That would suggest a bug.)
>
> The test does look like it has a minor issue though: it uses
> -fdump-tree-optimized but it doesn't actually scan the output for
> anything.  I think it was copied from another test and not removed
> by accident.  It should be removed.  (The comment at the top is
> also missing the bug number that it was committed for; it should
> be added.)  I can take care of this if you can confirm the above
> (i.e., that there's no runtime failure on any of the targets
> excluded in your patch).
>
> Martin
>
> >
> > ChangeLog
> >
> > gcc/testsuite
> >
> > Kito Cheng  <kito.ch...@sifive.com>
> >
> >       * gcc.dg/strlenopt-81.c: Add target limitation.
> > ---
> >   gcc/testsuite/gcc.dg/strlenopt-81.c | 6 +++++-
> >   1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/gcc/testsuite/gcc.dg/strlenopt-81.c 
> > b/gcc/testsuite/gcc.dg/strlenopt-81.c
> > index 95ac29aa71f..4a0dfc4f17d 100644
> > --- a/gcc/testsuite/gcc.dg/strlenopt-81.c
> > +++ b/gcc/testsuite/gcc.dg/strlenopt-81.c
> > @@ -1,5 +1,9 @@
> >   /* PR tree-optimization/ - fold strlen relational expressions
> > -   { dg-do run }
> > +   { dg-do run { target aarch64*-*-* i?86-*-* powerpc*-*-* x86_64-*-* } }
> > +   The optimization is only implemented for MEM_REF stores and other
> > +   targets than those below may not transform the memcpy call into
> > +   such a store.
> > +
> >      { dg-options "-O2 -Wall -Wno-unused-local-typedefs 
> > -fdump-tree-optimized" } */
> >
> >   typedef __SIZE_TYPE__ size_t;
> >
>

Reply via email to