1** Copyright (c) 1989, NVIDIA CORPORATION. All rights reserved. 2** 3** Licensed under the Apache License, Version 2.0 (the "License"); 4** you may not use this file except in compliance with the License. 5** You may obtain a copy of the License at 6** 7** http://www.apache.org/licenses/LICENSE-2.0 8** 9** Unless required by applicable law or agreed to in writing, software 10** distributed under the License is distributed on an "AS IS" BASIS, 11** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12** See the License for the specific language governing permissions and 13** limitations under the License. 14 15* Optimizer tests of converting while loops to "do while" 16 17 program ka01 18 parameter(N=7) 19 common iresult(N), iexpect(N) 20 data iresult /N*0/ 21 call test1_2 22 call test3_7 23 call check(iresult, iexpect, N) 24 data iexpect / 25 + 4, 5, ! tests 1-2 26 + 4, 4, 4, 4, 4 ! tests 3-7 27 + / 28 end 29 30 subroutine incr(i) 31 parameter(N=7) 32 common iresult(N), iexpect(N) 33 iresult(i) = iresult(i) + 1 34 end 35 36 subroutine test1_2() 37 i = 1 38 do 100 while (i .le. 4) 39 call incr(1) 40 i = i + 1 41100 continue 42 do while (i .gt. 0) 43 call incr(2) 44 i = i - 1 45 enddo 46 end 47 48 subroutine test3_7() 49 i = 4 50 do 100 while (i .ge. 1) 51 k = 4 52 call incr(3) 53 do while (k .gt. 0) 54 j = k 55 call incr(3 + j) 56 k = k - 1 57 enddo 58 i = i - 1 59100 continue 60 end 61