| 1 |
! { dg-do run } |
| 2 |
! { dg-options "-ffree-line-length-none" } |
| 3 |
|
| 4 |
interface runtime_popcnt |
| 5 |
procedure runtime_popcnt_i1 |
| 6 |
procedure runtime_popcnt_i2 |
| 7 |
procedure runtime_popcnt_i4 |
| 8 |
procedure runtime_popcnt_i8 |
| 9 |
end interface |
| 10 |
|
| 11 |
interface runtime_poppar |
| 12 |
procedure runtime_poppar_i1 |
| 13 |
procedure runtime_poppar_i2 |
| 14 |
procedure runtime_poppar_i4 |
| 15 |
procedure runtime_poppar_i8 |
| 16 |
end interface |
| 17 |
|
| 18 |
#define CHECK(val,res) \ |
| 19 |
if (popcnt(val) /= res) STOP 1; \ |
| 20 |
if (runtime_popcnt(val) /= res) STOP 2 |
| 21 |
|
| 22 |
#define CHECK2(val) \ |
| 23 |
if (poppar(val) /= modulo(popcnt(val),2)) STOP 3; \ |
| 24 |
if (runtime_poppar(val) /= poppar(val)) STOP 4 |
| 25 |
|
| 26 |
CHECK(0_1, 0) |
| 27 |
CHECK(0_2, 0) |
| 28 |
CHECK(0_4, 0) |
| 29 |
CHECK(0_8, 0) |
| 30 |
|
| 31 |
CHECK(1_1, 1) |
| 32 |
CHECK(1_2, 1) |
| 33 |
CHECK(1_4, 1) |
| 34 |
CHECK(1_8, 1) |
| 35 |
|
| 36 |
CHECK(-1_1,8) |
| 37 |
CHECK(-1_2,16) |
| 38 |
CHECK(-1_4,32) |
| 39 |
CHECK(-1_8,64) |
| 40 |
|
| 41 |
CHECK(-8_1,8-3) |
| 42 |
CHECK(-8_2,16-3) |
| 43 |
CHECK(-8_4,32-3) |
| 44 |
CHECK(-8_8,64-3) |
| 45 |
|
| 46 |
CHECK(huge(0_1), 8-1) |
| 47 |
CHECK(huge(0_2), 16-1) |
| 48 |
CHECK(huge(0_4), 32-1) |
| 49 |
CHECK(huge(0_8), 64-1) |
| 50 |
|
| 51 |
CHECK(-huge(0_1), 2) |
| 52 |
CHECK(-huge(0_2), 2) |
| 53 |
CHECK(-huge(0_4), 2) |
| 54 |
CHECK(-huge(0_8), 2) |
| 55 |
|
| 56 |
CHECK2(0_1) |
| 57 |
CHECK2(0_2) |
| 58 |
CHECK2(0_4) |
| 59 |
CHECK2(0_8) |
| 60 |
|
| 61 |
CHECK2(17_1) |
| 62 |
CHECK2(17_2) |
| 63 |
CHECK2(17_4) |
| 64 |
CHECK2(17_8) |
| 65 |
|
| 66 |
CHECK2(-17_1) |
| 67 |
CHECK2(-17_2) |
| 68 |
CHECK2(-17_4) |
| 69 |
CHECK2(-17_8) |
| 70 |
|
| 71 |
CHECK2(huge(0_1)) |
| 72 |
CHECK2(huge(0_2)) |
| 73 |
CHECK2(huge(0_4)) |
| 74 |
CHECK2(huge(0_8)) |
| 75 |
|
| 76 |
CHECK2(-huge(0_1)) |
| 77 |
CHECK2(-huge(0_2)) |
| 78 |
CHECK2(-huge(0_4)) |
| 79 |
CHECK2(-huge(0_8)) |
| 80 |
|
| 81 |
contains |
| 82 |
integer function runtime_popcnt_i1 (i) result(res) |
| 83 |
integer(kind=1), intent(in) :: i |
| 84 |
res = popcnt(i) |
| 85 |
end function |
| 86 |
|
| 87 |
integer function runtime_popcnt_i2 (i) result(res) |
| 88 |
integer(kind=2), intent(in) :: i |
| 89 |
res = popcnt(i) |
| 90 |
end function |
| 91 |
|
| 92 |
integer function runtime_popcnt_i4 (i) result(res) |
| 93 |
integer(kind=4), intent(in) :: i |
| 94 |
res = popcnt(i) |
| 95 |
end function |
| 96 |
|
| 97 |
integer function runtime_popcnt_i8 (i) result(res) |
| 98 |
integer(kind=8), intent(in) :: i |
| 99 |
res = popcnt(i) |
| 100 |
end function |
| 101 |
|
| 102 |
integer function runtime_poppar_i1 (i) result(res) |
| 103 |
integer(kind=1), intent(in) :: i |
| 104 |
res = poppar(i) |
| 105 |
end function |
| 106 |
|
| 107 |
integer function runtime_poppar_i2 (i) result(res) |
| 108 |
integer(kind=2), intent(in) :: i |
| 109 |
res = poppar(i) |
| 110 |
end function |
| 111 |
|
| 112 |
integer function runtime_poppar_i4 (i) result(res) |
| 113 |
integer(kind=4), intent(in) :: i |
| 114 |
res = poppar(i) |
| 115 |
end function |
| 116 |
|
| 117 |
integer function runtime_poppar_i8 (i) result(res) |
| 118 |
integer(kind=8), intent(in) :: i |
| 119 |
res = poppar(i) |
| 120 |
end function |
| 121 |
end |