aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/arm/memset-inline-5.c
blob: 9107d811a94ffe9b5ec738d803bef8c2e5a4aadf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* { dg-do run } */
/* { dg-skip-if "Don't inline memset using neon instructions on cortex-a9" { *-*-* } { "-mcpu=cortex-a9" } { "" } } */
/* { dg-skip-if "Don't inline memset using neon instructions on cortex-a9" { *-*-* } { "-mtune=cortex-a9" } { "" } } */
/* { dg-options "-save-temps -O2 -fno-inline" } */
/* { dg-add-options "arm_neon" } */

#include <string.h>
#include <stdlib.h>

#define LEN (100)
int a[LEN];
int b[LEN];
int c[LEN];
int d[LEN];
void
foo1 (void)
{
    memset (a, -1, 16);
    return;
}

void
foo2 (void)
{
  memset (b, 1, 25);
  return;
}

void
foo3 (void)
{
  memset (c, -1, 19);
  return;
}

void
foo4 (void)
{
  memset (d, 1, 23);
  return;
}

void
check (signed char *arr, int idx, int len, int v)
{
  int i;
  for (i = 0; i < idx; i++)
    if (arr[i] != v)
      abort ();

  for (i = idx; i < len; i++)
    if (arr[i] != 0)
      abort ();
}

int
main(void)
{
  foo1 ();
  check ((signed char *)a, 16, sizeof (a), -1);

  foo2 ();
  check ((signed char *)b, 25, sizeof (b), 1);

  foo3 ();
  check ((signed char *)c, 19, sizeof (c), -1);

  foo4 ();
  check ((signed char *)d, 23, sizeof (d), 1);

  return 0;
}

/* { dg-final { scan-assembler-not "bl?\[ \t\]+memset" { target { arm_little_endian && arm_neon } } } } */
/* { dg-final { scan-assembler "vst1" { target { arm_little_endian && arm_neon } } } } */
/* { dg-final { scan-assembler-not "vstr"  { target { arm_little_endian && arm_neon } } } } */
/* { dg-final { cleanup-saved-temps } } */