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 } */
18 create_i128 (long most_sig
, long least_sig
)
38 void print_i128(__int128 val
, int unsignedp
)
41 printf(" %llu ", (unsigned long long)(val
>> 64));
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));
56 long a
= 0xFEDCBA9876543210L
;
59 __int128 expected_result
= create_i128 (0xFFFFFFFFFFFEDCBAL
,
62 __int128 result
= multiply_add (a
, b
, c
);
64 if (result
!= expected_result
)
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);
77 unsigned long au
= 0xFEDCBA9876543210UL
;
78 unsigned long bu
= 0x1000000UL
;
79 unsigned long cu
= 0x123456UL
;
80 unsigned __int128 expected_resultu
= create_i128 (0x0000000000FEDCBAL
,
83 unsigned __int128 resultu
= multiply_addu (au
, bu
, cu
);
84 if (resultu
!= expected_resultu
)
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);