File: copysign_softfloat_1.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A12.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 959,712 kB
  • sloc: cpp: 3,275,382; ansic: 2,061,766; ada: 840,956; f90: 208,513; makefile: 76,132; asm: 73,433; xml: 50,448; exp: 34,146; sh: 32,436; objc: 15,637; fortran: 14,012; python: 11,991; pascal: 6,787; awk: 4,779; perl: 3,054; yacc: 338; ml: 285; lex: 201; haskell: 122
file content (60 lines) | stat: -rw-r--r-- 1,436 bytes parent folder | download | duplicates (3)
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
/* { dg-do run } */
/* { dg-require-effective-target arm_thumb2_ok } */
/* { dg-additional-options "-mthumb -O2 --save-temps" } */

extern void abort (void);

#define N 16

float a_f[N] = {-0.1f, -3.2f, -6.3f, -9.4f,
		-12.5f, -15.6f, -18.7f, -21.8f,
		24.9f, 27.1f, 30.2f, 33.3f,
		36.4f, 39.5f, 42.6f, 45.7f};

float b_f[N] = {-1.2f, 3.4f, -5.6f, 7.8f,
		-9.0f, 1.0f, -2.0f, 3.0f,
		-4.0f, -5.0f, 6.0f, 7.0f,
		-8.0f, -9.0f, 10.0f, 11.0f};

float c_f[N] = {-0.1f, 3.2f, -6.3f, 9.4f,
		-12.5f, 15.6f, -18.7f, 21.8f,
		-24.9f, -27.1f, 30.2f, 33.3f,
		-36.4f, -39.5f, 42.6f, 45.7f};

double a_d[N] = {-0.1, -3.2, -6.3, -9.4,
		 -12.5, -15.6, -18.7, -21.8,
		 24.9, 27.1, 30.2, 33.3,
		 36.4, 39.5, 42.6, 45.7};

double b_d[N] = {-1.2, 3.4, -5.6, 7.8,
		 -9.0, 1.0, -2.0, 3.0,
		 -4.0, -5.0, 6.0, 7.0,
		 -8.0, -9.0, 10.0, 11.0};

double c_d[N] = {-0.1, 3.2, -6.3, 9.4,
		 -12.5, 15.6, -18.7, 21.8,
		 -24.9, -27.1, 30.2, 33.3,
		 -36.4, -39.5, 42.6, 45.7};

int
main (int argc, char **argv)
{
  int index = 0;

/* { dg-final { scan-assembler-times "bfi" 2 { target arm_softfloat } } } */
/* { dg-final { scan-assembler-times "lsr" 1 { target arm_softfloat } } } */
  for (index; index < N; index++)
    {
      if (__builtin_copysignf (a_f[index], b_f[index]) != c_f[index])
	abort();
    }

  for (index = 0; index < N; index++)
    {
      if (__builtin_copysign (a_d[index], b_d[index]) != c_d[index])
	abort();
    }

  return 0;
}