-/* { dg-do compile } */
-/* { dg-require-effective-target arm_unaligned } */
-/* { dg-options "-O2" } */
+/* { dg-do run } */
+/* { dg-options "-O2 -save-temps" } */
#include <string.h>
-void unknown_alignment (char *dest, char *src)
+char src[17] __attribute__ ((aligned(8))) = "abcdefghijklmnopq";
+char result[17] __attribute__ ((aligned(8))) = {0};
+
+void __attribute__ ((noinline,noclone))
+unknown_alignment (char *dest, char *src)
{
memcpy (dest, src, 15);
}
-/* We should see three unaligned word loads and store pairs, one unaligned
- ldrh/strh pair, and an ldrb/strb pair. Sanity check that. */
+int main ()
+{
+ int i;
+ unknown_alignment (result+1, src+2);
+ for (i = 0; i < 15; i++)
+ if (result[i+1] != src[i+2])
+ __builtin_abort ();
+ if (result[16] != 0)
+ __builtin_abort ();
+ return 0;
+}
+
+/* Check that we don't use any instructions that assume an aligned source. */
+/* { dg-final { scan-assembler-not {(ldm(ia)?\tr[0-9]|ldrd\t.*\[r[0-9]|vldr)} } } */
-/* { dg-final { scan-assembler-times "@ unaligned" 8 } } */
-/* { dg-final { scan-assembler-times "ldrh" 1 } } */
-/* { dg-final { scan-assembler-times "strh" 1 } } */
-/* { dg-final { scan-assembler-times "ldrb" 1 } } */
-/* { dg-final { scan-assembler-times "strb" 1 } } */
+/* Check that we don't use any instructions that assume an aligned dest. */
+/* { dg-final { scan-assembler-not {(stm(ia)?\tr[0-9]|strd\t.*\[r[0-9]|vstr)} } } */
-/* { dg-do compile } */
-/* { dg-require-effective-target arm_unaligned } */
-/* { dg-options "-O2" } */
+/* { dg-do run } */
+/* { dg-options "-O2 -save-temps" } */
#include <string.h>
-char dest[16] = { 0 };
+char dest[16] __attribute__((aligned(8))) = { 0 } ;
+char input[17] __attribute__ ((aligned(8))) = "abcdefghijklmnop";
-void aligned_dest (char *src)
+void __attribute__ ((noinline,noclone)) aligned_dest (char *src)
{
memcpy (dest, src, 15);
}
-/* Expect a multi-word store for the main part of the copy, but subword
- loads/stores for the remainder. */
+int main ()
+{
+ int i;
+ aligned_dest (input+1);
+ for (i = 0; i < 15; i++)
+ if (dest[i] != input[i+1])
+ __builtin_abort ();
+ if (dest[15] != 0)
+ __builtin_abort ();
+ return 0;
+}
-/* { dg-final { scan-assembler-times "ldmia" 0 } } */
-/* { dg-final { scan-assembler-times "ldrd" 0 } } */
-/* { dg-final { scan-assembler-times "stmia" 1 { target { ! { arm_prefer_ldrd_strd } } } } } */
-/* { dg-final { scan-assembler-times "strd" 1 { target { arm_prefer_ldrd_strd } } } } */
-/* { dg-final { scan-assembler-times "ldrh" 1 } } */
-/* { dg-final { scan-assembler-times "strh" 1 } } */
-/* { dg-final { scan-assembler-times "ldrb" 1 } } */
-/* { dg-final { scan-assembler-times "strb" 1 } } */
+/* Check that we don't use any instructions that assume an aligned source. */
+/* { dg-final { scan-assembler-not {(ldm(ia)?\tr[0-9]|ldrd\t.*\[r[0-9]|vldr)} } } */
-/* { dg-do compile } */
-/* { dg-require-effective-target arm_unaligned } */
-/* { dg-options "-O2" } */
+/* { dg-do run } */
+/* { dg-options "-O2 -save-temps" } */
#include <string.h>
-char src[16] = {0};
+char src[17] __attribute__ ((aligned(8))) = "abcdefghijklmnop";
+char result[17] __attribute__ ((aligned(8))) = {0};
-void aligned_src (char *dest)
+void __attribute__ ((noinline,noclone)) aligned_src (char *dest)
{
memcpy (dest, src, 15);
}
-/* Expect a multi-word load for the main part of the copy, but subword
- loads/stores for the remainder. */
+int main ()
+{
+ int i;
+ aligned_src (result+1);
+ for (i = 0; i < 15; i++)
+ if (result[i+1] != src[i])
+ __builtin_abort ();
+ if (result[16] != 0)
+ __builtin_abort ();
+ return 0;
+}
-/* { dg-final { scan-assembler-times "ldmia" 1 { target { ! { arm_prefer_ldrd_strd } } } } } */
-/* { dg-final { scan-assembler-times "ldrd" 1 { target { arm_prefer_ldrd_strd } } } } */
-/* { dg-final { scan-assembler-times "strd" 0 } } */
-/* { dg-final { scan-assembler-times "stm" 0 } } */
-/* { dg-final { scan-assembler-times "ldrh" 1 { target { ! { arm_prefer_ldrd_strd } } } } } */
-/* { dg-final { scan-assembler-times "strh" 1 } } */
-/* { dg-final { scan-assembler-times "ldrb" 1 { target { ! { arm_prefer_ldrd_strd } } } } } */
-/* { dg-final { scan-assembler-times "strb" 1 } } */
+/* Check that we don't use any instructions that assume an aligned dest. */
+/* { dg-final { scan-assembler-not {(stm(ia)?\tr[0-9]|strd\t.*\[r[0-9]|vstr)} } } */
-/* { dg-do compile } */
-/* { dg-require-effective-target arm_unaligned } */
-/* { dg-options "-O2" } */
+/* { dg-do run } */
+/* { dg-options "-O2 -save-temps" } */
#include <string.h>
-char src[16] = { 0 };
-char dest[16] = { 0 };
+char src[16] __attribute__ ((aligned(8))) = "abcdefghijklmnop";
+char dest[16] __attribute__ ((aligned(8))) = { 0 };
-void aligned_both (void)
+void __attribute__ ((noinline,noclone))
+aligned_both (void)
{
- memcpy (dest, src, 15);
+ memcpy (dest, src, 16);
}
-/* We know both src and dest to be aligned: expect multiword loads/stores. */
+int main ()
+{
+ int i;
+ aligned_both ();
+ for (i = 0; i < 16; i++)
+ if (dest[i] != src[i])
+ __builtin_abort ();
+ return 0;
+}
-/* { dg-final { scan-assembler-times "ldm" 1 { target { ! { arm_prefer_ldrd_strd } } } } } */
-/* { dg-final { scan-assembler-times "stmia" 1 { target { ! { arm_prefer_ldrd_strd } } } } } */
-/* { dg-final { scan-assembler "ldrd" { target { arm_prefer_ldrd_strd } } } } */
-/* { dg-final { scan-assembler-times "ldm" 0 { target { arm_prefer_ldrd_strd } } } } */
-/* { dg-final { scan-assembler "strd" { target { arm_prefer_ldrd_strd } } } } */
-/* { dg-final { scan-assembler-times "stm" 0 { target { arm_prefer_ldrd_strd } } } } */
+/* There should be no 'unaligned' comments. */
+/* { dg-final { scan-assembler-not "unaligned" } } */