[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Evaluate / fold-popcnt.f90
blob9bc19c7df1fee69df8738d56527568c40f8caaa4
1 ! RUN: %python %S/test_folding.py %s %flang_fc1
2 ! Test counts of set bits.
4 module leadz_tests
5 logical, parameter :: test_z1 = leadz(0_1) .EQ. 8
6 logical, parameter :: test_o1 = leadz(1_1) .EQ. 7
7 logical, parameter :: test_t1 = leadz(2_1) .EQ. 6
8 logical, parameter :: test_f1 = leadz(15_1) .EQ. 4
9 logical, parameter :: test_b1 = leadz(16_1) .EQ. 3
10 logical, parameter :: test_m11 = leadz(-1_1) .EQ. 0
11 logical, parameter :: test_m12 = leadz(-2_1) .EQ. 0
12 logical, parameter :: test_mb1 = leadz(-120_1) .EQ. 0
14 logical, parameter :: test_z2 = leadz(0_2) .EQ. 16
15 logical, parameter :: test_o2 = leadz(1_2) .EQ. 15
16 logical, parameter :: test_t2 = leadz(2_2) .EQ. 14
17 logical, parameter :: test_f2 = leadz(15_2) .EQ. 12
18 logical, parameter :: test_m21 = leadz(-1_2) .EQ. 0
19 logical, parameter :: test_m22 = leadz(-2_2) .EQ. 0
20 logical, parameter :: test_mb2 = leadz(-32640_2) .EQ. 0
22 logical, parameter :: test_z4 = leadz(0_4) .EQ. 32
23 logical, parameter :: test_o4 = leadz(1_4) .EQ. 31
24 logical, parameter :: test_t4 = leadz(2_4) .EQ. 30
25 logical, parameter :: test_f4 = leadz(15_4) .EQ. 28
26 logical, parameter :: test_m41 = leadz(-1_4) .EQ. 0
27 logical, parameter :: test_m42 = leadz(-2_4) .EQ. 0
28 logical, parameter :: test_mb4 = leadz(-2147450880_4) .EQ. 0
30 logical, parameter :: test_z8 = leadz(0_8) .EQ. 64
31 logical, parameter :: test_o8 = leadz(1_8) .EQ. 63
32 logical, parameter :: test_t8 = leadz(2_8) .EQ. 62
33 logical, parameter :: test_f8 = leadz(15_8) .EQ. 60
34 logical, parameter :: test_m81 = leadz(-1_8) .EQ. 0
35 logical, parameter :: test_m82 = leadz(-2_8) .EQ. 0
36 logical, parameter :: test_mb8 = leadz(-9223372034707292160_8) .EQ. 0
38 logical, parameter :: test_z16 = leadz(0_16) .EQ. 128
39 logical, parameter :: test_o16 = leadz(1_16) .EQ. 127
40 logical, parameter :: test_t16 = leadz(2_16) .EQ. 126
41 logical, parameter :: test_f16 = leadz(15_16) .EQ. 124
42 logical, parameter :: test_m161 = leadz(-1_16) .EQ. 0
43 logical, parameter :: test_m162 = leadz(-2_16) .EQ. 0
44 logical, parameter :: test_mb16 = leadz(18446744073709551616_16) .EQ. 63
45 end module leadz_tests
47 module trailz_tests
48 logical, parameter :: test_z1 = trailz(0_1) .EQ. 8
49 logical, parameter :: test_o1 = trailz(1_1) .EQ. 0
50 logical, parameter :: test_t1 = trailz(2_1) .EQ. 1
51 logical, parameter :: test_f1 = trailz(15_1) .EQ. 0
52 logical, parameter :: test_b1 = trailz(16_1) .EQ. 4
53 logical, parameter :: test_m11 = trailz(-1_1) .EQ. 0
54 logical, parameter :: test_m12 = trailz(-2_1) .EQ. 1
55 logical, parameter :: test_mb1 = trailz(-120_1) .EQ. 3
57 logical, parameter :: test_z2 = trailz(0_2) .EQ. 16
58 logical, parameter :: test_o2 = trailz(1_2) .EQ. 0
59 logical, parameter :: test_t2 = trailz(2_2) .EQ. 1
60 logical, parameter :: test_f2 = trailz(15_2) .EQ. 0
61 logical, parameter :: test_m21 = trailz(-1_2) .EQ. 0
62 logical, parameter :: test_m22 = trailz(-2_2) .EQ. 1
63 logical, parameter :: test_mb2 = trailz(-32640_2) .EQ. 7
65 logical, parameter :: test_z4 = trailz(0_4) .EQ. 32
66 logical, parameter :: test_o4 = trailz(1_4) .EQ. 0
67 logical, parameter :: test_t4 = trailz(2_4) .EQ. 1
68 logical, parameter :: test_f4 = trailz(15_4) .EQ. 0
69 logical, parameter :: test_m41 = trailz(-1_4) .EQ. 0
70 logical, parameter :: test_m42 = trailz(-2_4) .EQ. 1
71 logical, parameter :: test_mb4 = trailz(-2147450880_4) .EQ. 15
73 logical, parameter :: test_z8 = trailz(0_8) .EQ. 64
74 logical, parameter :: test_o8 = trailz(1_8) .EQ. 0
75 logical, parameter :: test_t8 = trailz(2_8) .EQ. 1
76 logical, parameter :: test_f8 = trailz(15_8) .EQ. 0
77 logical, parameter :: test_m81 = trailz(-1_8) .EQ. 0
78 logical, parameter :: test_m82 = trailz(-2_8) .EQ. 1
79 logical, parameter :: test_mb8 = trailz(-9223372034707292160_8) .EQ. 31
81 logical, parameter :: test_z16 = trailz(0_16) .EQ. 128
82 logical, parameter :: test_o16 = trailz(1_16) .EQ. 0
83 logical, parameter :: test_t16 = trailz(2_16) .EQ. 1
84 logical, parameter :: test_f16 = trailz(15_16) .EQ. 0
85 logical, parameter :: test_m161 = trailz(-1_16) .EQ. 0
86 logical, parameter :: test_m162 = trailz(-2_16) .EQ. 1
87 logical, parameter :: test_mb16 = trailz(18446744073709551616_16) .EQ. 64
88 end module trailz_tests
90 module popcnt_tests
91 logical, parameter :: test_z1 = popcnt(0_1) .EQ. 0
92 logical, parameter :: test_o1 = popcnt(1_1) .EQ. 1
93 logical, parameter :: test_t1 = popcnt(2_1) .EQ. 1
94 logical, parameter :: test_f1 = popcnt(15_1) .EQ. 4
95 logical, parameter :: test_b1 = popcnt(16_1) .EQ. 1
96 logical, parameter :: test_m11 = popcnt(-1_1) .EQ. 8
97 logical, parameter :: test_m12 = popcnt(-2_1) .EQ. 7
98 logical, parameter :: test_mb1 = popcnt(-120_1) .EQ. 2
100 logical, parameter :: test_z2 = popcnt(0_2) .EQ. 0
101 logical, parameter :: test_o2 = popcnt(1_2) .EQ. 1
102 logical, parameter :: test_t2 = popcnt(2_2) .EQ. 1
103 logical, parameter :: test_f2 = popcnt(15_2) .EQ. 4
104 logical, parameter :: test_m21 = popcnt(-1_2) .EQ. 16
105 logical, parameter :: test_m22 = popcnt(-2_2) .EQ. 15
106 logical, parameter :: test_mb2 = popcnt(-32640_2) .EQ. 2
108 logical, parameter :: test_z4 = popcnt(0_4) .EQ. 0
109 logical, parameter :: test_o4 = popcnt(1_4) .EQ. 1
110 logical, parameter :: test_t4 = popcnt(2_4) .EQ. 1
111 logical, parameter :: test_f4 = popcnt(15_4) .EQ. 4
112 logical, parameter :: test_m41 = popcnt(-1_4) .EQ. 32
113 logical, parameter :: test_m42 = popcnt(-2_4) .EQ. 31
114 logical, parameter :: test_mb4 = popcnt(-2147450880_4) .EQ. 2
116 logical, parameter :: test_z8 = popcnt(0_8) .EQ. 0
117 logical, parameter :: test_o8 = popcnt(1_8) .EQ. 1
118 logical, parameter :: test_t8 = popcnt(2_8) .EQ. 1
119 logical, parameter :: test_f8 = popcnt(15_8) .EQ. 4
120 logical, parameter :: test_m81 = popcnt(-1_8) .EQ. 64
121 logical, parameter :: test_m82 = popcnt(-2_8) .EQ. 63
122 logical, parameter :: test_mb8 = popcnt(-9223372034707292160_8) .EQ. 2
124 logical, parameter :: test_z16 = popcnt(0_16) .EQ. 0
125 logical, parameter :: test_o16 = popcnt(1_16) .EQ. 1
126 logical, parameter :: test_t16 = popcnt(2_16) .EQ. 1
127 logical, parameter :: test_f16 = popcnt(15_16) .EQ. 4
128 logical, parameter :: test_m161 = popcnt(-1_16) .EQ. 128
129 logical, parameter :: test_m162 = popcnt(-2_16) .EQ. 127
130 logical, parameter :: test_mb16 = popcnt(18446744073709551616_16) .EQ. 1
131 end module popcnt_tests
133 module poppar_tests
134 logical, parameter :: test_z1 = poppar(0_1) .EQ. 0
135 logical, parameter :: test_o1 = poppar(1_1) .EQ. 1
136 logical, parameter :: test_t1 = poppar(2_1) .EQ. 1
137 logical, parameter :: test_f1 = poppar(15_1) .EQ. 0
138 logical, parameter :: test_b1 = poppar(16_1) .EQ. 1
139 logical, parameter :: test_m11 = poppar(-1_1) .EQ. 0
140 logical, parameter :: test_m12 = poppar(-2_1) .EQ. 1
141 logical, parameter :: test_mb1 = poppar(-120_1) .EQ. 0
143 logical, parameter :: test_z2 = poppar(0_2) .EQ. 0
144 logical, parameter :: test_o2 = poppar(1_2) .EQ. 1
145 logical, parameter :: test_t2 = poppar(2_2) .EQ. 1
146 logical, parameter :: test_f2 = poppar(15_2) .EQ. 0
147 logical, parameter :: test_m21 = poppar(-1_2) .EQ. 0
148 logical, parameter :: test_m22 = poppar(-2_2) .EQ. 1
149 logical, parameter :: test_mb2 = poppar(-32640_2) .EQ. 0
151 logical, parameter :: test_z4 = poppar(0_4) .EQ. 0
152 logical, parameter :: test_o4 = poppar(1_4) .EQ. 1
153 logical, parameter :: test_t4 = poppar(2_4) .EQ. 1
154 logical, parameter :: test_f4 = poppar(15_4) .EQ. 0
155 logical, parameter :: test_m41 = poppar(-1_4) .EQ. 0
156 logical, parameter :: test_m42 = poppar(-2_4) .EQ. 1
157 logical, parameter :: test_mb4 = poppar(-2147450880_4) .EQ. 0
159 logical, parameter :: test_z8 = poppar(0_8) .EQ. 0
160 logical, parameter :: test_o8 = poppar(1_8) .EQ. 1
161 logical, parameter :: test_t8 = poppar(2_8) .EQ. 1
162 logical, parameter :: test_f8 = poppar(15_8) .EQ. 0
163 logical, parameter :: test_m81 = poppar(-1_8) .EQ. 0
164 logical, parameter :: test_m82 = poppar(-2_8) .EQ. 1
165 logical, parameter :: test_mb8 = poppar(-9223372034707292160_8) .EQ. 0
167 logical, parameter :: test_z16 = poppar(0_16) .EQ. 0
168 logical, parameter :: test_o16 = poppar(1_16) .EQ. 1
169 logical, parameter :: test_t16 = poppar(2_16) .EQ. 1
170 logical, parameter :: test_f16 = poppar(15_16) .EQ. 0
171 logical, parameter :: test_m161 = poppar(-1_16) .EQ. 0
172 logical, parameter :: test_m162 = poppar(-2_16) .EQ. 1
173 logical, parameter :: test_mb16 = poppar(18446744073709551616_16) .EQ. 1
174 end module poppar_tests