| 1 |
! { dg-do run } |
| 2 |
! { dg-options "-ffree-line-length-none" } |
| 3 |
! { dg-require-effective-target fortran_integer_16 } |
| 4 |
|
| 5 |
#define CHECK(val,res) \ |
| 6 |
if (popcnt(val) /= res) STOP 1; \ |
| 7 |
if (runtime_popcnt(val) /= res) STOP 2 |
| 8 |
|
| 9 |
#define CHECK2(val) \ |
| 10 |
if (poppar(val) /= modulo(popcnt(val),2)) STOP 3; \ |
| 11 |
if (runtime_poppar(val) /= poppar(val)) STOP 4 |
| 12 |
|
| 13 |
CHECK(0_16, 0) |
| 14 |
CHECK(1_16, 1) |
| 15 |
|
| 16 |
CHECK(-1_16,128) |
| 17 |
CHECK(-8_16,128-3) |
| 18 |
|
| 19 |
CHECK(huge(0_16), 128-1) |
| 20 |
|
| 21 |
CHECK(-huge(0_16), 2) |
| 22 |
|
| 23 |
CHECK2(0_16) |
| 24 |
CHECK2(17_16) |
| 25 |
CHECK2(-17_16) |
| 26 |
CHECK2(huge(0_16)) |
| 27 |
CHECK2(-huge(0_16)) |
| 28 |
|
| 29 |
contains |
| 30 |
integer function runtime_popcnt (i) result(res) |
| 31 |
integer(kind=16), intent(in) :: i |
| 32 |
res = popcnt(i) |
| 33 |
end function |
| 34 |
|
| 35 |
integer function runtime_poppar (i) result(res) |
| 36 |
integer(kind=16), intent(in) :: i |
| 37 |
res = poppar(i) |
| 38 |
end function |
| 39 |
end |