summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/sh/strlen.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.target/sh/strlen.c')
-rw-r--r--gcc/testsuite/gcc.target/sh/strlen.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/sh/strlen.c b/gcc/testsuite/gcc.target/sh/strlen.c
new file mode 100644
index 00000000000..115baba99cd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/sh/strlen.c
@@ -0,0 +1,19 @@
+/* Check that the __builtin_strlen function is inlined with cmp/str
+ when optimizing for speed. */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-skip-if "" { "sh*-*-*" } { "-m5*" } { "" } } */
+/* { dg-final { scan-assembler-not "jmp" } } */
+/* { dg-final { scan-assembler-times "cmp/str" 2 } } */
+/* { dg-final { scan-assembler-times "tst\t#3" 1 } } */
+
+test00 (const char *s1)
+{
+ return __builtin_strlen (s1);
+}
+
+/* Check that no test for alignment is needed. */
+test03(const char *s1)
+{
+ return __builtin_strlen (__builtin_assume_aligned (s1, 4));
+}