+2004-09-15 Jakub Jelinek <jakub@redhat.com>
+
+ * builtins.c (expand_builtin_memmove): Optimize memmove (x, y, 1)
+ into memcpy (x, y, 1) if memcpy can be expanded inline.
+
2004-09-15 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
PR tree-optimization/17468
target, mode, EXPAND_NORMAL);
}
+ /* If length is 1 and we can expand memcpy call inline,
+ it is ok to use memcpy as well. */
+ if (integer_onep (len))
+ {
+ rtx ret = expand_builtin_mempcpy (arglist, target, mode,
+ /*endp=*/0);
+ if (ret)
+ return ret;
+ }
+
/* Otherwise, call the normal function. */
return 0;
}
+2004-09-15 Jakub Jelinek <jakub@redhat.com>
+
+ * gcc.c-torture/execute/builtins/memmove.c (main_test): Formatting.
+ * gcc.c-torture/execute/builtins/memmove-2.c: New test.
+ * gcc.c-torture/execute/builtins/memmove-2-lib.c: New.
+
2004-09-14 Mark Mitchell <mark@codesourcery.com>
PR c++/17324
--- /dev/null
+#include "lib/memmove.c"
--- /dev/null
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Check builtin memmove and bcopy optimization when length is 1.
+
+ Written by Jakub Jelinek, 9/14/2004. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern void *memmove (void *, const void *, size_t);
+extern void bcopy (const void *, void *, size_t);
+extern int memcmp (const void *, const void *, size_t);
+
+char p[32] = "abcdefg";
+char *q = p + 4;
+
+void
+main_test (void)
+{
+ /* memmove with length 1 can be optimized into memcpy if it can be
+ expanded inline. */
+ if (memmove (p + 2, p + 3, 1) != p + 2 || memcmp (p, "abddefg", 8))
+ abort ();
+ if (memmove (p + 1, p + 1, 1) != p + 1 || memcmp (p, "abddefg", 8))
+ abort ();
+ if (memmove (q, p + 4, 1) != p + 4 || memcmp (p, "abddefg", 8))
+ abort ();
+ bcopy (p + 5, p + 6, 1);
+ if (memcmp (p, "abddeff", 8))
+ abort ();
+ bcopy (p + 1, p + 1, 1);
+ if (memcmp (p, "abddeff", 8))
+ abort ();
+ bcopy (q, p + 4, 1);
+ if (memcmp (p, "abddeff", 8))
+ abort ();
+}
-/* Copyright (C) 2003 Free Software Foundation.
+/* Copyright (C) 2003, 2004 Free Software Foundation.
Ensure builtin memmove and bcopy perform correctly.
struct bar b1[sizeof bar/sizeof*bar];
int bz[sizeof baz/sizeof*baz];
- if (memmove (f1, foo, sizeof (foo)) != f1 || memcmp (f1, foo, sizeof(foo)))
- abort();
- if (memmove (b1, bar, sizeof (bar)) != b1 || memcmp (b1, bar, sizeof(bar)))
- abort();
+ if (memmove (f1, foo, sizeof (foo)) != f1 || memcmp (f1, foo, sizeof (foo)))
+ abort ();
+ if (memmove (b1, bar, sizeof (bar)) != b1 || memcmp (b1, bar, sizeof (bar)))
+ abort ();
bcopy (baz, bz, sizeof (baz));
- if (memcmp (bz, baz, sizeof(baz)))
- abort();
+ if (memcmp (bz, baz, sizeof (baz)))
+ abort ();
if (memmove (p, "abcde", 6) != p || memcmp (p, "abcde", 6))
abort ();