1 ! Test the SHIFTA, SHIFTL and SHIFTR intrinsics.
4 ! { dg-options "-ffree-line-length-none" }
31 #define CHECK(I,SHIFT,RESA,RESL,RESR) \
32 if (shifta(I,SHIFT) /= RESA) call abort ; \
33 if (shiftr(I,SHIFT) /= RESR) call abort ; \
34 if (shiftl(I,SHIFT) /= RESL) call abort ; \
35 if (run_shifta(I,SHIFT) /= RESA) call abort ; \
36 if (run_shiftr(I,SHIFT) /= RESR) call abort ; \
37 if (run_shiftl(I,SHIFT) /= RESL) call abort ; \
38 if (ishft(I,SHIFT) /= RESL) call abort ; \
39 if (ishft(I,-SHIFT) /= RESR) call abort ; \
40 if (run_ishft(I,SHIFT) /= RESL) call abort ; \
41 if (run_ishft(I,-SHIFT) /= RESR) call abort
43 CHECK(0_1,0,0_1,0_1,0_1)
44 CHECK(11_1,0,11_1,11_1,11_1)
45 CHECK(-11_1,0,-11_1,-11_1,-11_1)
46 CHECK(0_1,1,0_1,0_1,0_1)
47 CHECK(11_1,1,5_1,22_1,5_1)
48 CHECK(11_1,2,2_1,44_1,2_1)
49 CHECK(-11_1,1,-6_1,-22_1,huge(0_1)-5_1)
51 CHECK(0_2,0,0_2,0_2,0_2)
52 CHECK(11_2,0,11_2,11_2,11_2)
53 CHECK(-11_2,0,-11_2,-11_2,-11_2)
54 CHECK(0_2,1,0_2,0_2,0_2)
55 CHECK(11_2,1,5_2,22_2,5_2)
56 CHECK(11_2,2,2_2,44_2,2_2)
57 CHECK(-11_2,1,-6_2,-22_2,huge(0_2)-5_2)
59 CHECK(0_4,0,0_4,0_4,0_4)
60 CHECK(11_4,0,11_4,11_4,11_4)
61 CHECK(-11_4,0,-11_4,-11_4,-11_4)
62 CHECK(0_4,1,0_4,0_4,0_4)
63 CHECK(11_4,1,5_4,22_4,5_4)
64 CHECK(11_4,2,2_4,44_4,2_4)
65 CHECK(-11_4,1,-6_4,-22_4,huge(0_4)-5_4)
67 CHECK(0_8,0,0_8,0_8,0_8)
68 CHECK(11_8,0,11_8,11_8,11_8)
69 CHECK(-11_8,0,-11_8,-11_8,-11_8)
70 CHECK(0_8,1,0_8,0_8,0_8)
71 CHECK(11_8,1,5_8,22_8,5_8)
72 CHECK(11_8,2,2_8,44_8,2_8)
73 CHECK(-11_8,1,-6_8,-22_8,huge(0_8)-5_8)
77 function shifta_1 (i, shift) result(res)
78 integer(kind=1) :: i, res
82 function shiftl_1 (i, shift) result(res)
83 integer(kind=1) :: i, res
87 function shiftr_1 (i, shift) result(res)
88 integer(kind=1) :: i, res
93 function shifta_2 (i, shift) result(res)
94 integer(kind=2) :: i, res
98 function shiftl_2 (i, shift) result(res)
99 integer(kind=2) :: i, res
101 res = shiftl(i,shift)
103 function shiftr_2 (i, shift) result(res)
104 integer(kind=2) :: i, res
106 res = shiftr(i,shift)
109 function shifta_4 (i, shift) result(res)
110 integer(kind=4) :: i, res
112 res = shifta(i,shift)
114 function shiftl_4 (i, shift) result(res)
115 integer(kind=4) :: i, res
117 res = shiftl(i,shift)
119 function shiftr_4 (i, shift) result(res)
120 integer(kind=4) :: i, res
122 res = shiftr(i,shift)
125 function shifta_8 (i, shift) result(res)
126 integer(kind=8) :: i, res
128 res = shifta(i,shift)
130 function shiftl_8 (i, shift) result(res)
131 integer(kind=8) :: i, res
133 res = shiftl(i,shift)
135 function shiftr_8 (i, shift) result(res)
136 integer(kind=8) :: i, res
138 res = shiftr(i,shift)
141 function ishft_1 (i, shift) result(res)
142 integer(kind=1) :: i, res
146 function ishft_2 (i, shift) result(res)
147 integer(kind=2) :: i, res
151 function ishft_4 (i, shift) result(res)
152 integer(kind=4) :: i, res
156 function ishft_8 (i, shift) result(res)
157 integer(kind=8) :: i, res