summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/leadz_trailz_1.f90
blob: a0cd19792255d21b826952f73d1a936200b6dd35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
! { dg-do run }

  integer(kind=1) :: i1
  integer(kind=2) :: i2
  integer(kind=4) :: i4
  integer(kind=8) :: i8

  i1 = -1
  i2 = -1
  i4 = -1
  i8 = -1

  if (leadz(i1) /= 0) call abort
  if (leadz(i2) /= 0) call abort
  if (leadz(i4) /= 0) call abort
  if (leadz(i8) /= 0) call abort

  if (trailz(i1) /= 0) call abort
  if (trailz(i2) /= 0) call abort
  if (trailz(i4) /= 0) call abort
  if (trailz(i8) /= 0) call abort

  if (leadz(-1_1) /= 0) call abort
  if (leadz(-1_2) /= 0) call abort
  if (leadz(-1_4) /= 0) call abort
  if (leadz(-1_8) /= 0) call abort

  if (trailz(-1_1) /= 0) call abort
  if (trailz(-1_2) /= 0) call abort
  if (trailz(-1_4) /= 0) call abort
  if (trailz(-1_8) /= 0) call abort

  i1 = -64
  i2 = -64
  i4 = -64
  i8 = -64

  if (leadz(i1) /= 0) call abort
  if (leadz(i2) /= 0) call abort
  if (leadz(i4) /= 0) call abort
  if (leadz(i8) /= 0) call abort

  if (trailz(i1) /= 6) call abort
  if (trailz(i2) /= 6) call abort
  if (trailz(i4) /= 6) call abort
  if (trailz(i8) /= 6) call abort

  if (leadz(-64_1) /= 0) call abort
  if (leadz(-64_2) /= 0) call abort
  if (leadz(-64_4) /= 0) call abort
  if (leadz(-64_8) /= 0) call abort

  if (trailz(-64_1) /= 6) call abort
  if (trailz(-64_2) /= 6) call abort
  if (trailz(-64_4) /= 6) call abort
  if (trailz(-64_8) /= 6) call abort

  i1 = -108
  i2 = -108
  i4 = -108
  i8 = -108

  if (leadz(i1) /= 0) call abort
  if (leadz(i2) /= 0) call abort
  if (leadz(i4) /= 0) call abort
  if (leadz(i8) /= 0) call abort

  if (trailz(i1) /= 2) call abort
  if (trailz(i2) /= 2) call abort
  if (trailz(i4) /= 2) call abort
  if (trailz(i8) /= 2) call abort

  if (leadz(-108_1) /= 0) call abort
  if (leadz(-108_2) /= 0) call abort
  if (leadz(-108_4) /= 0) call abort
  if (leadz(-108_8) /= 0) call abort

  if (trailz(-108_1) /= 2) call abort
  if (trailz(-108_2) /= 2) call abort
  if (trailz(-108_4) /= 2) call abort
  if (trailz(-108_8) /= 2) call abort

  i1 = 1
  i2 = 1
  i4 = 1
  i8 = 1

  if (leadz(i1) /= bit_size(i1) - 1) call abort
  if (leadz(i2) /= bit_size(i2) - 1) call abort
  if (leadz(i4) /= bit_size(i4) - 1) call abort
  if (leadz(i8) /= bit_size(i8) - 1) call abort

  if (trailz(i1) /= 0) call abort
  if (trailz(i2) /= 0) call abort
  if (trailz(i4) /= 0) call abort
  if (trailz(i8) /= 0) call abort

  if (leadz(1_1) /= bit_size(1_1) - 1) call abort
  if (leadz(1_2) /= bit_size(1_2) - 1) call abort
  if (leadz(1_4) /= bit_size(1_4) - 1) call abort
  if (leadz(1_8) /= bit_size(1_8) - 1) call abort

  if (trailz(1_1) /= 0) call abort
  if (trailz(1_2) /= 0) call abort
  if (trailz(1_4) /= 0) call abort
  if (trailz(1_8) /= 0) call abort

  i1 = 64
  i2 = 64
  i4 = 64
  i8 = 64

  if (leadz(i1) /= 1) call abort
  if (leadz(i2) /= 9) call abort
  if (leadz(i4) /= 25) call abort
  if (leadz(i8) /= 57) call abort

  if (trailz(i1) /= 6) call abort
  if (trailz(i2) /= 6) call abort
  if (trailz(i4) /= 6) call abort
  if (trailz(i8) /= 6) call abort

  if (leadz(64_1) /= 1) call abort
  if (leadz(64_2) /= 9) call abort
  if (leadz(64_4) /= 25) call abort
  if (leadz(64_8) /= 57) call abort

  if (trailz(64_1) /= 6) call abort
  if (trailz(64_2) /= 6) call abort
  if (trailz(64_4) /= 6) call abort
  if (trailz(64_8) /= 6) call abort

end