[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / pr103109-2.c
blob4b93519ec6508ef02f63860c2181fe7c2f5dd8fa
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mdejagnu-cpu=power9" } */
3 /* { dg-require-effective-target int128 } */
4 /* { dg-require-effective-target p9modulo_hw } */
5 /* { dg-require-effective-target has_arch_ppc64 } */
7 #include "pr103109.h"
9 union U {
10 __int128 i128;
11 struct {
12 long l1;
13 long l2;
14 } s;
17 __int128
18 create_i128 (long most_sig, long least_sig)
20 union U u;
22 #if __LITTLE_ENDIAN__
23 u.s.l1 = least_sig;
24 u.s.l2 = most_sig;
25 #else
26 u.s.l1 = most_sig;
27 u.s.l2 = least_sig;
28 #endif
29 return u.i128;
32 #define DEBUG 0
34 #if DEBUG
35 #include <stdio.h>
36 #include <stdlib.h>
38 void print_i128(__int128 val, int unsignedp)
40 if (unsignedp)
41 printf(" %llu ", (unsigned long long)(val >> 64));
42 else
43 printf(" %lld ", (signed long long)(val >> 64));
45 printf("%llu (0x%llx %llx)",
46 (unsigned long long)(val & 0xFFFFFFFFFFFFFFFF),
47 (unsigned long long)(val >> 64),
48 (unsigned long long)(val & 0xFFFFFFFFFFFFFFFF));
50 #endif
52 void abort (void);
54 int main ()
56 long a = 0xFEDCBA9876543210L;
57 long b = 0x1000000L;
58 long c = 0x123456L;
59 __int128 expected_result = create_i128 (0xFFFFFFFFFFFEDCBAL,
60 0x9876543210123456L);
62 __int128 result = multiply_add (a, b, c);
64 if (result != expected_result)
66 #if DEBUG
67 printf ("ERROR: multiply_add (%lld, %lld, %lld) = ", a, b, c);
68 print_i128 (result, 0);
69 printf ("\n does not match expected_result = ");
70 print_i128 (expected_result, 0);
71 printf ("\n\n");
72 #else
73 abort();
74 #endif
77 unsigned long au = 0xFEDCBA9876543210UL;
78 unsigned long bu = 0x1000000UL;
79 unsigned long cu = 0x123456UL;
80 unsigned __int128 expected_resultu = create_i128 (0x0000000000FEDCBAL,
81 0x9876543210123456L);
83 unsigned __int128 resultu = multiply_addu (au, bu, cu);
84 if (resultu != expected_resultu)
86 #if DEBUG
87 printf ("ERROR: multiply_addu (%llu, %llu, %llu) = ", au, bu, cu);
88 print_i128 (resultu, 1);
89 printf ("\n does not match expected_result = ");
90 print_i128 (expected_resultu, 1);
91 printf ("\n\n");
92 #else
93 abort();
94 #endif