1 /* Test the SCUTSS instruction. */
2 /* { dg-options "-mcpu=fr405" } */
3 /* { dg-do run } */
4 extern void abort (void);
5 extern void exit (int);
6
main()7 int main ()
8 {
9 struct {
10 long long value;
11 int cut_point;
12 int result;
13 } values[] = {
14 /* Non-saturating values */
15
16 { +0x0000000000001234LL, 44, +0x01234000 },
17 { ~0x0000000000001234LL, 44, ~0x01234fff },
18
19 { +0x0000011223300fffLL, 20, +0x11223301 },
20 { ~0x0000011223300fffLL, 20, ~0x11223300 },
21 { +0x0000011223300800LL, 20, +0x11223301 },
22 { ~0x0000011223300800LL, 20, ~0x11223300 },
23 { +0x00000112233007ffLL, 20, +0x11223300 },
24 { ~0x00000112233007ffLL, 20, ~0x112232ff },
25 { +0x0000011223300000LL, 20, +0x11223300 },
26 { ~0x0000011223300000LL, 20, ~0x112232ff },
27
28 { +0x1234567fffffffffLL, -4, +0x01234568 },
29 { ~0x1234567fffffffffLL, -4, ~0x01234567 },
30 { +0x1234567800000000LL, -4, +0x01234568 },
31 { ~0x1234567800000000LL, -4, ~0x01234567 },
32 { +0x12345677ffffffffLL, -4, +0x01234567 },
33 { ~0x12345677ffffffffLL, -4, ~0x01234566 },
34 { +0x1234567000000000LL, -4, +0x01234567 },
35 { ~0x1234567000000000LL, -4, ~0x01234566 },
36
37 /* Saturation tests */
38
39 { +0x4000000000000000LL, 44, +0x7fffffff },
40 { ~0x4000000000000000LL, 44, ~0x7fffffff },
41 { +0x0000000000080000LL, 44, +0x7fffffff },
42 { ~0x0000000000080000LL, 44, ~0x7fffffff },
43 { +0x000000000007ffffLL, 44, +0x7ffff000 },
44 { ~0x000000000007ffffLL, 44, ~0x7fffffff },
45 { +0x000000000007fffeLL, 44, +0x7fffe000 },
46 { ~0x000000000007fffeLL, 44, ~0x7fffefff },
47
48 { +0x4000000000000000LL, 20, +0x7fffffff },
49 { ~0x4000000000000000LL, 20, ~0x7fffffff },
50 { +0x0000080000000000LL, 20, +0x7fffffff },
51 { ~0x0000080000000000LL, 20, ~0x7fffffff },
52 { +0x000007ffffffffffLL, 20, +0x7fffffff },
53 { ~0x000007ffffffffffLL, 20, ~0x7fffffff },
54 { +0x000007fffffff000LL, 20, +0x7fffffff },
55 { ~0x000007fffffff000LL, 20, ~0x7ffffffe },
56 { +0x000007ffffffe000LL, 20, +0x7ffffffe },
57 { ~0x000007ffffffefffLL, 20, ~0x7ffffffe }
58 };
59
60 unsigned int i;
61
62 for (i = 0; i < sizeof (values) / sizeof (values[0]); i++)
63 {
64 __IACCsetll (0, values[i].value);
65 if (__SCUTSS (values[i].cut_point) != values[i].result)
66 abort ();
67 }
68 exit (0);
69 }
70