Debian Codegraph @

gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c

raw
1 /* Machine description pattern tests. */
2
3 /*
4 { dg-options "-mzarch -save-temps" }
5
6 Note that dejagnu-1.5.1 has a bug so that the action from the second dg-do
7 always wins, even if the condition is false. If this test is run on hardware
8 older than z10 with a buggy dejagnu release, the execution part will fail.
9
10 { dg-do assemble }
11 { dg-do run { target { s390_useable_hw } } }
12
13 Skip test if -O0, -march=z900, -march=z9-109 or -march=z9-ec is present on
14 the command line:
15
16 { dg-skip-if "" { *-*-* } { "-march=z9*" "-O0" } { "" } }
17
18 Skip test if the -O or the -march= option is missing from the command line
19 because it's difficult to detect the default:
20
21 { dg-skip-if "" { *-*-* } { "*" } { "-O*" } }
22 { dg-skip-if "" { *-*-* } { "*" } { "-march=*" } }
23 */
24
25 unsigned int a, b;
26
27 __attribute__ ((noinline)) unsigned int
28 si_sll (unsigned int x)
29 {
30 return (x << 1);
31 }
32
33 __attribute__ ((noinline)) unsigned int
34 si_srl (unsigned int x)
35 {
36 return (x >> 2);
37 }
38
39 __attribute__ ((noinline)) unsigned int
40 rosbg_si_sll (unsigned int a, unsigned int b)
41 {
42 return a | (b << 1);
43 }
44 /* { dg-final { scan-assembler-times "rosbg\t%r.,%r.,32,62,1" 1 } } */
45
46 __attribute__ ((noinline)) unsigned int
47 rosbg_si_srl (void)
48 {
49 return a | (b >> 2);
50 }
51 /* { dg-final { scan-assembler-times "rosbg\t%r.,%r.,34,63,62" 1 } } */
52
53 __attribute__ ((noinline)) unsigned int
54 rxsbg_si_sll (unsigned int a, unsigned int b)
55 {
56 return a ^ (b << 1);
57 }
58 /* { dg-final { scan-assembler-times "rxsbg\t%r.,%r.,32,62,1" 1 } } */
59
60 __attribute__ ((noinline)) unsigned int
61 rxsbg_si_srl (void)
62 {
63 return a ^ (b >> 2);
64 }
65 /* { dg-final { scan-assembler-times "rxsbg\t%r.,%r.,34,63,62" 1 } } */
66
67 __attribute__ ((noinline)) unsigned long long
68 di_sll (unsigned long long x)
69 {
70 return (x << 1);
71 }
72
73 __attribute__ ((noinline)) unsigned long long
74 di_srl (unsigned long long x)
75 {
76 return (x >> 2);
77 }
78
79 __attribute__ ((noinline)) unsigned long long
80 rosbg_di_sll (unsigned long long a, unsigned long long b)
81 {
82 return a | (b << 1);
83 }
84 /* { dg-final { scan-assembler-times "rosbg\t%r.,%r.,0,62,1" 1 } } */
85
86 __attribute__ ((noinline)) unsigned long long
87 rosbg_di_srl (unsigned long long a, unsigned long long b)
88 {
89 return a | (b >> 2);
90 }
91 /* { dg-final { scan-assembler-times "rosbg\t%r.,%r.,2,63,62" 1 } } */
92
93 __attribute__ ((noinline)) unsigned long long
94 rxsbg_di_sll (unsigned long long a, unsigned long long b)
95 {
96 return a ^ (b << 1);
97 }
98 /* { dg-final { scan-assembler-times "rxsbg\t%r.,%r.,0,62,1" 1 } } */
99
100 __attribute__ ((noinline)) unsigned long long
101 rxsbg_di_srl (unsigned long long a, unsigned long long b)
102 {
103 return a ^ (b >> 2);
104 }
105 /* { dg-final { scan-assembler-times "rxsbg\t%r.,%r.,2,63,62" 1 } } */
106
107 int
108 main (void)
109 {
110 /* SIMode */
111 {
112 unsigned int r;
113 a = 0x12488421u;
114 b = 0x88881111u;
115 unsigned int csll = si_sll (b);
116 unsigned int csrl = si_srl (b);
117
118 r = rosbg_si_sll (a, b);
119 if (r != (a | csll))
120 __builtin_abort ();
121 r = rosbg_si_srl ();
122 if (r != (a | csrl))
123 __builtin_abort ();
124 r = rxsbg_si_sll (a, b);
125 if (r != (a ^ csll))
126 __builtin_abort ();
127 r = rxsbg_si_srl ();
128 if (r != (a ^ csrl))
129 __builtin_abort ();
130 }
131 /* DIMode */
132 {
133 unsigned long long r;
134 unsigned long long a = 0x1248357997538421lu;
135 unsigned long long b = 0x8888444422221111lu;
136 unsigned long long csll = di_sll (b);
137 unsigned long long csrl = di_srl (b);
138
139 r = rosbg_di_sll (a, b);
140 if (r != (a | csll))
141 __builtin_abort ();
142 r = rosbg_di_srl (a, b);
143 if (r != (a | csrl))
144 __builtin_abort ();
145 r = rxsbg_di_sll (a, b);
146 if (r != (a ^ csll))
147 __builtin_abort ();
148 r = rxsbg_di_srl (a, b);
149 if (r != (a ^ csrl))
150 __builtin_abort ();
151 }
152 return 0;
153 }