aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/arm/acle/saturation.c
blob: a9f99e562c08da5de8741648be63051931dde012 (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
/* { dg-do compile } */
/* { dg-require-effective-target arm_sat_ok } */
/* { dg-add-options arm_sat } */

#include <arm_acle.h>

int32_t
test_ssat (int32_t a)
{
  return __ssat (a, 8);
}

/* { dg-final { scan-assembler-times "ssat\t...?, #8, ...?" 1 } } */

uint32_t
test_usat (int32_t a)
{
  return __usat (a, 24);
}

/* { dg-final { scan-assembler-times "usat\t...?, #24, ...?" 1 } } */

/* Test that USAT doesn't get removed as we need its Q-setting behavior.  */
int
test_sat_occur (int32_t a)
{
  uint32_t res = __usat (a, 3);
  return __saturation_occurred ();
}

/* { dg-final { scan-assembler-times "usat\t...?, #3, ...?" 1 } } */
/* { dg-final { scan-assembler "mrs\t...?, APSR" } } */

void
test_set_sat (void)
{
  __set_saturation_occurred (0);
}

/* { dg-final { scan-assembler-times "msr\tAPSR_nzcvq, ...?" 1 } } */