File: builtins-msum-runnable.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 (76 lines) | stat: -rw-r--r-- 2,580 bytes parent folder | download | duplicates (2)
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
/* { dg-do run } */
/* { dg-require-effective-target p9vector_hw } */
/* { dg-require-effective-target int128 } */
/* { dg-options "-mdejagnu-cpu=power9 -O2" } */

#include <altivec.h>

#ifdef DEBUG
#include <stdio.h>
#endif

void abort (void);

int
main()
{
  vector __uint128_t arg_uint128, result_uint128, expected_uint128;
  vector __int128_t arg_int128, result_int128, expected_int128;

  arg_uint128[0] = 0x1627384950617243;
  arg_uint128[0] = arg_uint128[0] << 64;
  arg_uint128[0] |= 0x9405182930415263;
  expected_uint128[0] = 0x1627384950617243;
  expected_uint128[0] = expected_uint128[0] << 64;
  expected_uint128[0] |= 0xb6b07e42a570e5fe;
  vector unsigned long long arg_vull2 = {0x12345678,0x44445555};
  vector unsigned long long arg_vull3 = {0x6789abcd,0x66667777};
  result_uint128 = vec_msum (arg_vull2, arg_vull3, arg_uint128);

  if (result_uint128[0] != expected_uint128[0])
    {
#ifdef DEBUG
       printf("result_uint128[0] doesn't match expected_u128[0]\n");
       printf("arg_vull2  %llx %llx \n",  arg_vull2[0], arg_vull2[1]);
       printf("arg_vull3  %llx %llx \n",  arg_vull3[0], arg_vull3[1]);
       printf("arg_uint128[0] =  %llx ", arg_uint128[0] >> 64);
       printf(" %llx\n",	 arg_uint128[0] & 0xFFFFFFFFFFFFFFFF);

       printf("result_uint128[0] =  %llx ", result_uint128[0] >> 64);
       printf(" %llx\n", result_uint128[0] & 0xFFFFFFFFFFFFFFFF);

       printf("expected_uint128[0] =  %llx ", expected_uint128[0] >> 64);
       printf(" %llx\n", expected_uint128[0] & 0xFFFFFFFFFFFFFFFF);
#else
       abort();
#endif
    }

  arg_int128[0] = 0x1627384950617283;
  arg_int128[0] = arg_int128[0] << 64;
  arg_int128[0] |= 0x9405182930415263;
  expected_int128[0] = 0x1627384950617283;
  expected_int128[0] = expected_int128[0] << 64;
  expected_int128[0] |= 0xd99f35969c11cbfa;
  vector signed long long arg_vll2 = { 0x567890ab, 0x1233456 };
  vector signed long long arg_vll3 = { 0xcdef0123, 0x9873451 };
  result_int128 = vec_msum (arg_vll2, arg_vll3, arg_int128);

  if (result_int128[0] != expected_int128[0])
    {
#ifdef DEBUG
       printf("result_int128[0] doesn't match expected128[0]\n");
       printf("arg_int128[0] =  %llx ", arg_int128[0] >> 64);
       printf(" %llx\n",	 arg_int128[0] & 0xFFFFFFFFFFFFFFFF);

       printf("result_int128[0] =  %llx ", result_int128[0] >> 64);
       printf(" %llx\n", result_int128[0] & 0xFFFFFFFFFFFFFFFF);

       printf("expected_int128[0] =  %llx ", expected_int128[0] >> 64);
       printf(" %llx\n", expected_int128[0] & 0xFFFFFFFFFFFFFFFF);
#else
       abort();
#endif
    }
}