aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/loongarch/va_arg.c
blob: 980c96d0e3d521fa6fedccab9c836994f843a5eb (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
/* { dg-do compile } */
/* { dg-options "-O2" } */

/* Technically we shouldn't save any register for this function: it should be
   compiled as if it accepts 3 named arguments.  But AFAIK no compilers can
   achieve this "perfect" optimization now, so just ensure we are using the
   knowledge provided by stdarg pass and we won't save GARs impossible to be
   accessed with __builtin_va_arg () when the va_list does not escape.  */

/* { dg-final { scan-assembler-not "st.*r7" } } */

int
test (int a0, ...)
{
  void *arg;
  int a1, a2;

  __builtin_va_start (arg, a0);
  a1 = __builtin_va_arg (arg, int);
  a2 = __builtin_va_arg (arg, int);
  __builtin_va_end (arg);

  return a0 + a1 + a2;
}