This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, fortran] Use memcmp() for string comparison for constant-length kind=1 strings
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- Cc: Thomas Koenig <tkoenig at netcologne dot de>, "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 27 Mar 2013 09:16:08 +0100
- Subject: Re: [patch, fortran] Use memcmp() for string comparison for constant-length kind=1 strings
- References: <515082C3 dot 9070602 at netcologne dot de> <CAO9iq9H07xUrh7ka+Z1RDUY8zHOvQkwa2zAmMvcLX7ANJvDtWw at mail dot gmail dot com>
On Tue, Mar 26, 2013 at 11:53:27PM +0200, Janne Blomqvist wrote:
> On Mon, Mar 25, 2013 at 7:00 PM, Thomas Koenig <tkoenig@netcologne.de> wrote:
> > Hello world,
> >
> > this patch uses memcpy() directly when comparing two kind=1 strings of
> > equal and constant lengths. The test case modification depends
> > on the previous patch at
> >
Could you omit of equal lengths part? Do memcmp with minimum of lengths
and if not equal call compare_string for suffixes.
> > http://gcc.gnu.org/ml/gcc-patches/2013-03/msg00996.html
> >
> > for setting the string lengths for substrings.
> >
> > Regression-tested. No extra test case because the original test
> > cases have to be modified to avoid failure, and test the new
> > feature. OK for trunk after committing the patch above?
> >
> > 2013-03-25 Thomas Koenig <tkoenig@gcc.gnu.org>
> >
> > * trans-expr.c (build_memcmp_call): New function.
> > (gfc_build_compare_string): If the kind=1 strings to be
> > compared have constant and equal lengths, use
> > memcmp().
> >
> > 2013-03-25 Thomas Koenig <tkoenig@gcc.gnu.org>
> >
> > * gfortran.dg/character_comparison_3.f90: Adjust for use of memcmp
> > for constant and equal string lengths.
> > * gfortran.dg/character_comparison_5.f90: Likewise.
>
> Ok. I think the same optimization could be done for kind=4 strings as
> well, but nobody probably uses those anyway..
>
>
> --
> Janne Blomqvist