[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / pr101596-3.c
blob4b92661412daa41d70ed011f3dfa5d2c98d5d86a
1 /* { dg-do run } */
2 /* { dg-require-effective-target power10_hw } */
3 /* { dg-options "-mdejagnu-cpu=power10 -O2 -ftree-vectorize -fno-vect-cost-model" } */
5 /* Verify the execution goes well with shift count either 32 or 48. */
7 #define N 128
9 typedef signed int si;
10 typedef signed short sh;
11 typedef signed long long sll;
12 typedef unsigned int ui;
13 typedef unsigned short uh;
14 typedef unsigned long long ull;
16 si si_a[N], si_b[N];
17 ui ui_a[N], ui_b[N];
18 sh sh_c[N];
19 uh uh_c[N];
21 #define TEST(NTYPE, TYPE, WTYPE, CNT) \
22 void __attribute__ ((noipa)) test_##TYPE##CNT () \
23 { \
24 for (int i = 0; i < N; i++) \
25 NTYPE##_c[i] = ((WTYPE) TYPE##_a[i] * (WTYPE) TYPE##_b[i]) >> CNT; \
26 } \
28 void __attribute__ ((noipa, optimize ("O1"))) check_##TYPE##CNT () \
29 { \
30 test_##TYPE##CNT (); \
31 for (int i = 0; i < N; i++) \
32 { \
33 NTYPE exp = ((WTYPE) TYPE##_a[i] * (WTYPE) TYPE##_b[i]) >> CNT; \
34 if (NTYPE##_c[i] != exp) \
35 __builtin_abort (); \
36 } \
39 TEST (sh, si, sll, 32)
40 TEST (sh, si, sll, 48)
41 TEST (uh, ui, ull, 32)
42 TEST (uh, ui, ull, 48)
44 int
45 main ()
48 for (int i = 0; i < N; i++)
50 ui_a[i] = si_a[i] = 0x12345678ULL + 0x1000ULL * (i * 3 - 1);
51 ui_b[i] = si_b[i] = 0x87654321ULL - 0x500000ULL * (i * 5 + 1);
54 check_si32 ();
55 check_si48 ();
56 check_ui32 ();
57 check_ui48 ();