Commit c2bd38e8 by Roger Sayle Committed by Richard Henderson

builtins.c (expand_builtin_memset, [...]): Additional arguments TARGET and MODE.

        * builtins.c (expand_builtin_memset, expand_builtin_memcpy,
        expand_builtin_strcpy): Additional arguments TARGET and MODE.
        (expand_builtin_bzero, expand_builtin_strcpy,
        expand_builtin_strncpy, expand_builtin_bzero): Pass additional
        TARGET and MODE parameters to the above functions.
        (expand_builtin_memset, expand_builtin_memcpy): Optimize the
        case where the LEN parameter is constant zero.
        (expand_builtin_memcmp): No longer conditional on
        HAVE_cmpstrsi.  Take an additional mode parameter.  Optimize
        the cases where len is either constant zero or one.
        Optimize to call to memcpy, even if the memcpy isn't inlined.
        (expand_builtin_strncpy): Optimize to call memcpy, even if the
        memcpy isn't inlined.
        (expand_builtin_strcmp, expand_builtin_strncmp): Always attempt
        to optimize to a call to memcmp.
        (expand_builtin): expand_builtin_memcmp can always be called,
        and pass the required parameters to expand_builtin_memcmp,
        expand_builtin_memset, expand_builtin_memcpy and
        expand_builtin_strcpy.

        * gcc.c-torture/execute/string-opt-14.c: New test case.
        * gcc.c-torture/execute/string-opt-15.c: New test case.

From-SVN: r47960
parent 897bb55f
2001-12-12 Roger Sayle <roger@eyesopen.com>
* builtins.c (expand_builtin_memset, expand_builtin_memcpy,
expand_builtin_strcpy): Additional arguments TARGET and MODE.
(expand_builtin_bzero, expand_builtin_strcpy,
expand_builtin_strncpy, expand_builtin_bzero): Pass additional
TARGET and MODE parameters to the above functions.
(expand_builtin_memset, expand_builtin_memcpy): Optimize the
case where the LEN parameter is constant zero.
(expand_builtin_memcmp): No longer conditional on
HAVE_cmpstrsi. Take an additional mode parameter. Optimize
the cases where len is either constant zero or one.
Optimize to call to memcpy, even if the memcpy isn't inlined.
(expand_builtin_strncpy): Optimize to call memcpy, even if the
memcpy isn't inlined.
(expand_builtin_strcmp, expand_builtin_strncmp): Always attempt
to optimize to a call to memcmp.
(expand_builtin): expand_builtin_memcmp can always be called,
and pass the required parameters to expand_builtin_memcmp,
expand_builtin_memset, expand_builtin_memcpy and
expand_builtin_strcpy.
2001-12-12 David O'Brien <obrien@FreeBSD.org>
* config.gcc (arm-*-freebsd*): Add target.
......
/* Copyright (C) 2001 Free Software Foundation.
Ensure builtin memset and memcpy are optimized away correctly.
Written by Roger Sayle, 11/23/2001. */
extern void abort (void);
typedef __SIZE_TYPE__ size_t;
extern void *memset (void *s, int c, size_t n);
extern void *memcpy (void *dest, const void *src, size_t n);
char dst[32];
char src[32];
int
main ()
{
memset (src, 0, 0);
memcpy (dst, src, 0);
return 0;
}
#ifdef __OPTIMIZE__
/* When optimizing, all the above cases should be transformed into
something else. So any remaining calls to the original function
should abort. */
static void *
memset (void *s, int c, size_t n)
{
abort ();
}
static void *
memcpy (void *dest, const void *src, size_t n)
{
abort ();
}
#endif
/* Copyright (C) 2001 Free Software Foundation.
Ensure that short builtin memcmp are optimized and perform correctly.
On architectures with a cmpstrsi instruction, this test doesn't determine
which optimization is being performed, but it does check for correctness.
Written by Roger Sayle, 12/02/2001. */
extern void abort (void);
typedef __SIZE_TYPE__ size_t;
extern int memcmp (const void *, const void *, size_t);
extern char *strcpy (char *, const char *);
int
main ()
{
char str[8];
strcpy (str, "3141");
if ( memcmp (str, str+2, 0) != 0 )
abort ();
if ( memcmp (str+1, str+3, 0) != 0 )
abort ();
if ( memcmp (str+1, str+3, 1) != 0 )
abort ();
if ( memcmp (str, str+2, 1) >= 0 )
abort ();
if ( memcmp (str+2, str, 1) <= 0 )
abort ();
return 0;
}
#ifdef __OPTIMIZE__
/* When optimizing, all the above cases should be transformed into
something else. So any remaining calls to the original function
should abort. */
static int
memcmp (const char *p1, const char *p2, size_t len)
{
abort ();
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment