From: Ulrich Weigand Date: Mon, 21 Oct 2002 20:21:00 +0000 (+0000) Subject: profopt.exp (profopt-cleanup): New argument TESTCASE. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aaee784acf0a3a5817e35b70ba930c625ce8057e;p=gcc.git profopt.exp (profopt-cleanup): New argument TESTCASE. * lib/profopt.exp (profopt-cleanup): New argument TESTCASE. Remove only files with the same base name as the test case. (profopt-perf-value): Pass TESTCASE to profopt-cleanup. (profopt-execute): Likewise. Also, remove old profiling and performance data files before running the tests. * gcc.misc-tests/bprob.exp: Remove profopt-cleanup calls. * g++.dg/bprob/bprob.exp: Likewise. * g77.dg/bprob/bprob.exp: Likewise. Also, relax regexp to allow more general test case names. * g++.dg/bprob/bprob-1.C: Rename to ... * g++.dg/bprob/g++-bprob-1.C: ... this. * g77.dg/bprob/bprob-1.f: Rename to ... * g77.dg/bprob/g77-bprob-1.f: ... this. From-SVN: r58380 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4d6ffd5c5ab..fba76762f97 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,22 @@ +2002-10-21 Ulrich Weigand + + * lib/profopt.exp (profopt-cleanup): New argument TESTCASE. + Remove only files with the same base name as the test case. + (profopt-perf-value): Pass TESTCASE to profopt-cleanup. + (profopt-execute): Likewise. Also, remove old profiling + and performance data files before running the tests. + + * gcc.misc-tests/bprob.exp: Remove profopt-cleanup calls. + * g++.dg/bprob/bprob.exp: Likewise. + * g77.dg/bprob/bprob.exp: Likewise. Also, relax regexp + to allow more general test case names. + + * g++.dg/bprob/bprob-1.C: Rename to ... + * g++.dg/bprob/g++-bprob-1.C: ... this. + + * g77.dg/bprob/bprob-1.f: Rename to ... + * g77.dg/bprob/g77-bprob-1.f: ... this. + 2002-10-21 Zack Weinberg * gcc.dg/noncompile/920923-1.c: Prevent spurious regressions with diff --git a/gcc/testsuite/g++.dg/bprob/bprob-1.C b/gcc/testsuite/g++.dg/bprob/bprob-1.C deleted file mode 100644 index b1a1de77e98..00000000000 --- a/gcc/testsuite/g++.dg/bprob/bprob-1.C +++ /dev/null @@ -1,234 +0,0 @@ -/* Check that various C constructs (in C++) don't cause problems for - * profile-directed block ordering. - - Most of this test is the same as bprob-1.c and gcov-4.c in - gcc.misc-tests. The "count" comments are left in to make comparisons - easier; they are ignored for this test. */ - -extern "C" void abort (void); - -/* Check for loops. */ - -int for_val1; -int for_val2; -int for_temp; - -int -test_for1 (int n) -{ - int i; - for_temp = 1; /* count(3) */ - for (i = 0; i < n; i++) - for_temp++; /* count(9) */ - return for_temp; /* count(3) */ -} - -int -test_for2 (int m, int n, int o) -{ - int i, j, k; - for_temp = 1; /* count(6) */ - for (i = 0; i < n; i++) - for (j = 0; j < m; j++) - for (k = 0; k < o; k++) - for_temp++; /* count(81) */ - return for_temp; /* count(6) */ -} - -int -call_for () -{ - for_val1 += test_for1 (0); - for_val1 += test_for1 (2); - for_val1 += test_for1 (7); - - for_val2 += test_for2 (0, 0, 0); - for_val2 += test_for2 (1, 0, 0); - for_val2 += test_for2 (1, 3, 0); - for_val2 += test_for2 (1, 3, 1); - for_val2 += test_for2 (3, 1, 5); - for_val2 += test_for2 (3, 7, 3); -} - -/* Check the use of goto. */ - -int goto_val; - -int -test_goto1 (int f) -{ - if (f) /* count(2) */ - goto lab1; /* count(1) */ - return 1; /* count(1) */ -lab1: - return 2; /* count(1) */ -} - -int -test_goto2 (int f) -{ - int i; - for (i = 0; i < 10; i++) /* count(15) */ - if (i == f) goto lab2; /* count(14) */ - return 4; /* count(1) */ -lab2: - return 8; /* count(1) */ -} - -void -call_goto () -{ - goto_val += test_goto1 (0); - goto_val += test_goto1 (1); - goto_val += test_goto2 (3); - goto_val += test_goto2 (30); -} - -/* Check nested if-then-else statements. */ - -int ifelse_val1; -int ifelse_val2; -int ifelse_val3; - -int -test_ifelse1 (int i, int j) -{ - int result = 0; - if (i) /* count(5) */ - if (j) /* count(3) */ - result = 4; /* count(3) */ - else - result = 1024; - else - if (j) /* count(2) */ - result = 1; /* count(1) */ - else - result = 2; /* count(1) */ - if (i > j) /* count(5) */ - result *= 2; /* count(1) */ - if (i > 10) /* count(5) */ - if (j > 10) /* count(1) */ - result *= 4; /* count(1) */ - return result; /* count(5) */ -} - -int -test_ifelse2 (int i) -{ - int result = 0; - if (!i) /* count(6) */ - result = 1; /* count(1) */ - if (i == 1) /* count(6) */ - result = 1024; - if (i == 2) /* count(6) */ - result = 2; /* count(3) */ - if (i == 3) /* count(6) */ - return 8; /* count(2) */ - if (i == 4) /* count(4) */ - return 2048; - return result; /* count(4) */ -} - -int -test_ifelse3 (int i, int j) -{ - int result = 1; - if (i > 10 && j > i && j < 20) /* count(11) */ - result = 16; /* count(1) */ - if (i > 20) /* count(11) */ - if (j > i) /* count(5) */ - if (j < 30) /* count(2) */ - result = 32; /* count(1) */ - if (i == 3 || j == 47 || i == j) /* count(11) */ - result = 64; /* count(3) */ - return result; /* count(11) */ -} - -void -call_ifelse () -{ - ifelse_val1 += test_ifelse1 (0, 2); - ifelse_val1 += test_ifelse1 (0, 0); - ifelse_val1 += test_ifelse1 (1, 2); - ifelse_val1 += test_ifelse1 (10, 2); - ifelse_val1 += test_ifelse1 (11, 11); - - ifelse_val2 += test_ifelse2 (0); - ifelse_val2 += test_ifelse2 (2); - ifelse_val2 += test_ifelse2 (2); - ifelse_val2 += test_ifelse2 (2); - ifelse_val2 += test_ifelse2 (3); - ifelse_val2 += test_ifelse2 (3); - - ifelse_val3 += test_ifelse3 (11, 19); - ifelse_val3 += test_ifelse3 (25, 27); - ifelse_val3 += test_ifelse3 (11, 22); - ifelse_val3 += test_ifelse3 (11, 10); - ifelse_val3 += test_ifelse3 (21, 32); - ifelse_val3 += test_ifelse3 (21, 20); - ifelse_val3 += test_ifelse3 (1, 2); - ifelse_val3 += test_ifelse3 (32, 31); - ifelse_val3 += test_ifelse3 (3, 0); - ifelse_val3 += test_ifelse3 (0, 47); /* count(1) */ - ifelse_val3 += test_ifelse3 (65, 65); /* count(1) */ -} - -/* Check switch statements. */ - -int switch_val, switch_m; - -int -test_switch (int i, int j) -{ - int result = 0; /* count(5) */ - - switch (i) /* count(5) */ - { - case 1: - result = 2; /* count(1) */ - break; - case 2: - result = 1024; - break; - case 3: - case 4: - if (j == 2) /* count(3) */ - return 4; /* count(1) */ - result = 8; /* count(2) */ - break; - default: - result = 32; /* count(1) */ - switch_m++; /* count(1) */ - break; - } - return result; /* count(4) */ -} - -void -call_switch () -{ - switch_val += test_switch (1, 0); - switch_val += test_switch (3, 0); - switch_val += test_switch (3, 2); - switch_val += test_switch (4, 0); - switch_val += test_switch (16, 0); - switch_val += switch_m; -} - -int -main() -{ - call_for (); - call_goto (); - call_ifelse (); - call_switch (); - if ((for_val1 != 12) - || (for_val2 != 87) - || (goto_val != 15) - || (ifelse_val1 != 31) - || (ifelse_val2 != 23) - || (ifelse_val3 != 246) - || (switch_val != 55)) - abort (); - return 0; -} diff --git a/gcc/testsuite/g++.dg/bprob/bprob.exp b/gcc/testsuite/g++.dg/bprob/bprob.exp index 724954039aa..d19e341b1ea 100644 --- a/gcc/testsuite/g++.dg/bprob/bprob.exp +++ b/gcc/testsuite/g++.dg/bprob/bprob.exp @@ -51,9 +51,6 @@ if $tracelevel then { # Load support procs. load_lib profopt.exp -# Clean up existing .da files. -profopt-cleanup da - # Main loop. foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.C]] { # If we're only testing specific files and this isn't one of them, skip it. diff --git a/gcc/testsuite/g++.dg/bprob/g++-bprob-1.C b/gcc/testsuite/g++.dg/bprob/g++-bprob-1.C new file mode 100644 index 00000000000..b1a1de77e98 --- /dev/null +++ b/gcc/testsuite/g++.dg/bprob/g++-bprob-1.C @@ -0,0 +1,234 @@ +/* Check that various C constructs (in C++) don't cause problems for + * profile-directed block ordering. + + Most of this test is the same as bprob-1.c and gcov-4.c in + gcc.misc-tests. The "count" comments are left in to make comparisons + easier; they are ignored for this test. */ + +extern "C" void abort (void); + +/* Check for loops. */ + +int for_val1; +int for_val2; +int for_temp; + +int +test_for1 (int n) +{ + int i; + for_temp = 1; /* count(3) */ + for (i = 0; i < n; i++) + for_temp++; /* count(9) */ + return for_temp; /* count(3) */ +} + +int +test_for2 (int m, int n, int o) +{ + int i, j, k; + for_temp = 1; /* count(6) */ + for (i = 0; i < n; i++) + for (j = 0; j < m; j++) + for (k = 0; k < o; k++) + for_temp++; /* count(81) */ + return for_temp; /* count(6) */ +} + +int +call_for () +{ + for_val1 += test_for1 (0); + for_val1 += test_for1 (2); + for_val1 += test_for1 (7); + + for_val2 += test_for2 (0, 0, 0); + for_val2 += test_for2 (1, 0, 0); + for_val2 += test_for2 (1, 3, 0); + for_val2 += test_for2 (1, 3, 1); + for_val2 += test_for2 (3, 1, 5); + for_val2 += test_for2 (3, 7, 3); +} + +/* Check the use of goto. */ + +int goto_val; + +int +test_goto1 (int f) +{ + if (f) /* count(2) */ + goto lab1; /* count(1) */ + return 1; /* count(1) */ +lab1: + return 2; /* count(1) */ +} + +int +test_goto2 (int f) +{ + int i; + for (i = 0; i < 10; i++) /* count(15) */ + if (i == f) goto lab2; /* count(14) */ + return 4; /* count(1) */ +lab2: + return 8; /* count(1) */ +} + +void +call_goto () +{ + goto_val += test_goto1 (0); + goto_val += test_goto1 (1); + goto_val += test_goto2 (3); + goto_val += test_goto2 (30); +} + +/* Check nested if-then-else statements. */ + +int ifelse_val1; +int ifelse_val2; +int ifelse_val3; + +int +test_ifelse1 (int i, int j) +{ + int result = 0; + if (i) /* count(5) */ + if (j) /* count(3) */ + result = 4; /* count(3) */ + else + result = 1024; + else + if (j) /* count(2) */ + result = 1; /* count(1) */ + else + result = 2; /* count(1) */ + if (i > j) /* count(5) */ + result *= 2; /* count(1) */ + if (i > 10) /* count(5) */ + if (j > 10) /* count(1) */ + result *= 4; /* count(1) */ + return result; /* count(5) */ +} + +int +test_ifelse2 (int i) +{ + int result = 0; + if (!i) /* count(6) */ + result = 1; /* count(1) */ + if (i == 1) /* count(6) */ + result = 1024; + if (i == 2) /* count(6) */ + result = 2; /* count(3) */ + if (i == 3) /* count(6) */ + return 8; /* count(2) */ + if (i == 4) /* count(4) */ + return 2048; + return result; /* count(4) */ +} + +int +test_ifelse3 (int i, int j) +{ + int result = 1; + if (i > 10 && j > i && j < 20) /* count(11) */ + result = 16; /* count(1) */ + if (i > 20) /* count(11) */ + if (j > i) /* count(5) */ + if (j < 30) /* count(2) */ + result = 32; /* count(1) */ + if (i == 3 || j == 47 || i == j) /* count(11) */ + result = 64; /* count(3) */ + return result; /* count(11) */ +} + +void +call_ifelse () +{ + ifelse_val1 += test_ifelse1 (0, 2); + ifelse_val1 += test_ifelse1 (0, 0); + ifelse_val1 += test_ifelse1 (1, 2); + ifelse_val1 += test_ifelse1 (10, 2); + ifelse_val1 += test_ifelse1 (11, 11); + + ifelse_val2 += test_ifelse2 (0); + ifelse_val2 += test_ifelse2 (2); + ifelse_val2 += test_ifelse2 (2); + ifelse_val2 += test_ifelse2 (2); + ifelse_val2 += test_ifelse2 (3); + ifelse_val2 += test_ifelse2 (3); + + ifelse_val3 += test_ifelse3 (11, 19); + ifelse_val3 += test_ifelse3 (25, 27); + ifelse_val3 += test_ifelse3 (11, 22); + ifelse_val3 += test_ifelse3 (11, 10); + ifelse_val3 += test_ifelse3 (21, 32); + ifelse_val3 += test_ifelse3 (21, 20); + ifelse_val3 += test_ifelse3 (1, 2); + ifelse_val3 += test_ifelse3 (32, 31); + ifelse_val3 += test_ifelse3 (3, 0); + ifelse_val3 += test_ifelse3 (0, 47); /* count(1) */ + ifelse_val3 += test_ifelse3 (65, 65); /* count(1) */ +} + +/* Check switch statements. */ + +int switch_val, switch_m; + +int +test_switch (int i, int j) +{ + int result = 0; /* count(5) */ + + switch (i) /* count(5) */ + { + case 1: + result = 2; /* count(1) */ + break; + case 2: + result = 1024; + break; + case 3: + case 4: + if (j == 2) /* count(3) */ + return 4; /* count(1) */ + result = 8; /* count(2) */ + break; + default: + result = 32; /* count(1) */ + switch_m++; /* count(1) */ + break; + } + return result; /* count(4) */ +} + +void +call_switch () +{ + switch_val += test_switch (1, 0); + switch_val += test_switch (3, 0); + switch_val += test_switch (3, 2); + switch_val += test_switch (4, 0); + switch_val += test_switch (16, 0); + switch_val += switch_m; +} + +int +main() +{ + call_for (); + call_goto (); + call_ifelse (); + call_switch (); + if ((for_val1 != 12) + || (for_val2 != 87) + || (goto_val != 15) + || (ifelse_val1 != 31) + || (ifelse_val2 != 23) + || (ifelse_val3 != 246) + || (switch_val != 55)) + abort (); + return 0; +} diff --git a/gcc/testsuite/g77.dg/bprob/bprob-1.f b/gcc/testsuite/g77.dg/bprob/bprob-1.f deleted file mode 100644 index 73f04405b9b..00000000000 --- a/gcc/testsuite/g77.dg/bprob/bprob-1.f +++ /dev/null @@ -1,330 +0,0 @@ -C Test profile-directed block ordering with various Fortran 77 constructs -C to catch basic regressions in the functionality. - - program bprob1 - implicit none - integer i,j,k,n - integer result - integer lpall, ieall, gtall - integer lpval, ieval, gtval - - lpval = lpall() - ieval = ieall() - gtval = gtall() - if ((lpval .ne. 1) .or. (ieval .ne. 1) .or. (gtval .ne. 1)) then - call abort - end if - - end - -C Pass a value through a function to thwart optimization. - integer function foo(i) - implicit none - integer i - foo = i - end - -C Test various flavors of GOTO and compare results against expected values. - integer function gtall() - implicit none - integer gt1, gt2, gt3, gt4, gt5 - integer gtval - - gtall = 1 - gtval = 0 - gtval = gtval + gt1(0) - gtval = gtval + gt1(1) - if (gtval .ne. 3) then - print *,"gtall part 1: ", gtval, 3 - gtall = 0 - end if - - gtval = 0 - gtval = gtval + gt2(3) - gtval = gtval + gt2(30) - if (gtval .ne. 12) then - print *,"gtall part 2: ", gtval, 12 - gtall = 0 - end if - - gtval = 0 - gtval = gtval + gt3(0) - gtval = gtval + gt3(3) - if (gtval .ne. 48) then - print *,"gtall part 3: ", gtval, 48 - gtall = 0 - end if - - gtval = 0 - gtval = gtval + gt4(1) - gtval = gtval + gt4(2) - gtval = gtval + gt4(3) - if (gtval .ne. 14) then - print *,"gtall part 4: ", gtval, 14 - gtall = 0 - end if - - gtval = 0 - gtval = gtval + gt5(0) - gtval = gtval + gt5(-1) - gtval = gtval + gt5(5) - if (gtval .ne. 14) then - print *,"gtall part 5: ", gtval, 14 - gtall = 0 - end if - end - -C Test simple GOTO. - integer function gt1(f) - implicit none - integer f - if (f .ne. 0) goto 100 - gt1 = 1 - goto 101 - 100 gt1 = 2 - 101 continue - end - -C Test simple GOTO again, this time out of a DO loop. - integer function gt2(f) - implicit none - integer f - integer i - do i=1,10 - if (i .eq. f) goto 100 - end do - gt2 = 4 - goto 101 - 100 gt2 = 8 - 101 continue - end - -C Test computed GOTO. - integer function gt3(i) - implicit none - integer i - gt3 = 8 - goto (101, 102, 103, 104), i - goto 105 - 101 gt3 = 1024 - goto 105 - 102 gt3 = 2048 - goto 105 - 103 gt3 = 16 - goto 105 - 104 gt3 = 4096 - goto 105 - 105 gt3 = gt3 * 2 - end - -C Test assigned GOTO. - integer function gt4(i) - implicit none - integer i - integer label - assign 101 to label - if (i .eq. 2) assign 102 to label - if (i .eq. 3) assign 103 to label - goto label, (101, 102, 103) - 101 gt4 = 1 - goto 104 - 102 gt4 = 2 - goto 104 - 103 gt4 = 4 - 104 gt4 = gt4 * 2 - end - -C Test arithmetic IF (bundled with the GOTO variants). - integer function gt5(i) - implicit none - integer i - gt5 = 1 - if (i) 101, 102, 103 - 101 gt5 = 2 - goto 104 - 102 gt5 = 4 - goto 104 - 103 gt5 = 8 - 104 continue - end - -C Run all of the loop tests and check results against expected values. - integer function lpall() - implicit none - integer loop1, loop2 - integer loopval - - lpall = 1 - loopval = 0 - loopval = loopval + loop1(1,0) - loopval = loopval + loop1(1,2) - loopval = loopval + loop1(1,7) - if (loopval .ne. 12) then - print *,"lpall part 1: ", loopval, 12 - lpall = 0 - end if - - loopval = 0 - loopval = loopval + loop2(1,0,0,0) - loopval = loopval + loop2(1,1,0,0) - loopval = loopval + loop2(1,1,3,0) - loopval = loopval + loop2(1,1,3,1) - loopval = loopval + loop2(1,3,1,5) - loopval = loopval + loop2(1,3,7,3) - if (loopval .ne. 87) then - print *,"lpall part 2: ", loopval, 87 - lpall = 0 - end if - end - -C Test a simple DO loop. - integer function loop1(r,n) - implicit none - integer r,n,i - - loop1 = r - do i=1,n - loop1 = loop1 + 1 - end do - end - -C Test nested DO loops. - integer function loop2(r, l, m, n) - implicit none - integer r,l,m,n - integer i,j,k - loop2 = r - do i=1,l - do j=1,m - do k=1,n - loop2 = loop2 + 1 - end do - end do - end do - end - -C Test various combinations of IF-THEN-ELSE and check results against -C expected values. - integer function ieall() - implicit none - integer ie1, ie2, ie3 - integer ieval - ieall = 1 - ieval = 0 - - ieval = ieval + ie1(0,2) - ieval = ieval + ie1(0,0) - ieval = ieval + ie1(1,2) - ieval = ieval + ie1(10,2) - ieval = ieval + ie1(11,11) - if (ieval .ne. 31) then - print *,"ieall part 1: ", ieval, 31 - ieall = 0 - end if - - ieval = 0 - ieval = ieval + ie2(0) - ieval = ieval + ie2(2) - ieval = ieval + ie2(2) - ieval = ieval + ie2(2) - ieval = ieval + ie2(3) - ieval = ieval + ie2(3) - if (ieval .ne. 23) then - print *,"ieall part 2: ", ieval, 23 - ieall = 0 - end if - - ieval = 0 - ieval = ieval + ie3(11,19) - ieval = ieval + ie3(25,27) - ieval = ieval + ie3(11,22) - ieval = ieval + ie3(11,10) - ieval = ieval + ie3(21,32) - ieval = ieval + ie3(21,20) - ieval = ieval + ie3(1,2) - ieval = ieval + ie3(32,31) - ieval = ieval + ie3(3,0) - ieval = ieval + ie3(0,47) - ieval = ieval + ie3(65,65) - if (ieval .ne. 246) then - print *,"ieall part 3: ", ieval, 246 - ieall = 0 - end if - end - -C Test IF-THEN-ELSE. - integer function ie1(i,j) - implicit none - integer i,j - integer foo - - ie1 = 0 - if (i .ne. 0) then - if (j .ne. 0) then - ie1 = foo(4) - else - ie1 = foo(1024) - end if - else - if (j .ne. 0) then - ie1 = foo(1) - else - ie1 = foo(2) - end if - end if - if (i .gt. j) then - ie1 = foo(ie1*2) - end if - if (i .gt. 10) then - if (j .gt. 10) then - ie1 = foo(ie1*4) - end if - end if - end - -C Test a series of simple IF-THEN statements. - integer function ie2(i) - implicit none - integer i - integer foo - ie2 = 0 - - if (i .eq. 0) then - ie2 = foo(1) - end if - if (i .eq. 1) then - ie2 = foo(1024) - end if - if (i .eq. 2) then - ie2 = foo(2) - end if - if (i .eq. 3) then - ie2 = foo(8) - end if - if (i .eq. 4) then - ie2 = foo(2048) - end if - - end - -C Test nested IF statements and IF with compound expressions. - integer function ie3(i,j) - implicit none - integer i,j - integer foo - - ie3 = 1 - if ((i .gt. 10) .and. (j .gt. i) .and. (j .lt. 20)) then - ie3 = foo(16) - end if - if (i .gt. 20) then - if (j .gt. i) then - if (j .lt. 30) then - ie3 = foo(32) - end if - end if - end if - if ((i .eq. 3) .or. (j .eq. 47) .or. (i .eq.j)) then - ie3 = foo(64) - end if - end diff --git a/gcc/testsuite/g77.dg/bprob/bprob.exp b/gcc/testsuite/g77.dg/bprob/bprob.exp index 7e5629d85d4..8ca9e9ea951 100644 --- a/gcc/testsuite/g77.dg/bprob/bprob.exp +++ b/gcc/testsuite/g77.dg/bprob/bprob.exp @@ -48,11 +48,7 @@ if $tracelevel then { # Load support procs. load_lib profopt.exp -# Clean up existing .da and .tim files. -profopt-cleanup da -profopt-cleanup tim - -foreach src [lsort [glob -nocomplain $srcdir/$subdir/bprob-*.f]] { +foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.f]] { # If we're only testing specific files and this isn't one of them, skip it. if ![runtest_file_p $runtests $src] then { continue diff --git a/gcc/testsuite/g77.dg/bprob/g77-bprob-1.f b/gcc/testsuite/g77.dg/bprob/g77-bprob-1.f new file mode 100644 index 00000000000..73f04405b9b --- /dev/null +++ b/gcc/testsuite/g77.dg/bprob/g77-bprob-1.f @@ -0,0 +1,330 @@ +C Test profile-directed block ordering with various Fortran 77 constructs +C to catch basic regressions in the functionality. + + program bprob1 + implicit none + integer i,j,k,n + integer result + integer lpall, ieall, gtall + integer lpval, ieval, gtval + + lpval = lpall() + ieval = ieall() + gtval = gtall() + if ((lpval .ne. 1) .or. (ieval .ne. 1) .or. (gtval .ne. 1)) then + call abort + end if + + end + +C Pass a value through a function to thwart optimization. + integer function foo(i) + implicit none + integer i + foo = i + end + +C Test various flavors of GOTO and compare results against expected values. + integer function gtall() + implicit none + integer gt1, gt2, gt3, gt4, gt5 + integer gtval + + gtall = 1 + gtval = 0 + gtval = gtval + gt1(0) + gtval = gtval + gt1(1) + if (gtval .ne. 3) then + print *,"gtall part 1: ", gtval, 3 + gtall = 0 + end if + + gtval = 0 + gtval = gtval + gt2(3) + gtval = gtval + gt2(30) + if (gtval .ne. 12) then + print *,"gtall part 2: ", gtval, 12 + gtall = 0 + end if + + gtval = 0 + gtval = gtval + gt3(0) + gtval = gtval + gt3(3) + if (gtval .ne. 48) then + print *,"gtall part 3: ", gtval, 48 + gtall = 0 + end if + + gtval = 0 + gtval = gtval + gt4(1) + gtval = gtval + gt4(2) + gtval = gtval + gt4(3) + if (gtval .ne. 14) then + print *,"gtall part 4: ", gtval, 14 + gtall = 0 + end if + + gtval = 0 + gtval = gtval + gt5(0) + gtval = gtval + gt5(-1) + gtval = gtval + gt5(5) + if (gtval .ne. 14) then + print *,"gtall part 5: ", gtval, 14 + gtall = 0 + end if + end + +C Test simple GOTO. + integer function gt1(f) + implicit none + integer f + if (f .ne. 0) goto 100 + gt1 = 1 + goto 101 + 100 gt1 = 2 + 101 continue + end + +C Test simple GOTO again, this time out of a DO loop. + integer function gt2(f) + implicit none + integer f + integer i + do i=1,10 + if (i .eq. f) goto 100 + end do + gt2 = 4 + goto 101 + 100 gt2 = 8 + 101 continue + end + +C Test computed GOTO. + integer function gt3(i) + implicit none + integer i + gt3 = 8 + goto (101, 102, 103, 104), i + goto 105 + 101 gt3 = 1024 + goto 105 + 102 gt3 = 2048 + goto 105 + 103 gt3 = 16 + goto 105 + 104 gt3 = 4096 + goto 105 + 105 gt3 = gt3 * 2 + end + +C Test assigned GOTO. + integer function gt4(i) + implicit none + integer i + integer label + assign 101 to label + if (i .eq. 2) assign 102 to label + if (i .eq. 3) assign 103 to label + goto label, (101, 102, 103) + 101 gt4 = 1 + goto 104 + 102 gt4 = 2 + goto 104 + 103 gt4 = 4 + 104 gt4 = gt4 * 2 + end + +C Test arithmetic IF (bundled with the GOTO variants). + integer function gt5(i) + implicit none + integer i + gt5 = 1 + if (i) 101, 102, 103 + 101 gt5 = 2 + goto 104 + 102 gt5 = 4 + goto 104 + 103 gt5 = 8 + 104 continue + end + +C Run all of the loop tests and check results against expected values. + integer function lpall() + implicit none + integer loop1, loop2 + integer loopval + + lpall = 1 + loopval = 0 + loopval = loopval + loop1(1,0) + loopval = loopval + loop1(1,2) + loopval = loopval + loop1(1,7) + if (loopval .ne. 12) then + print *,"lpall part 1: ", loopval, 12 + lpall = 0 + end if + + loopval = 0 + loopval = loopval + loop2(1,0,0,0) + loopval = loopval + loop2(1,1,0,0) + loopval = loopval + loop2(1,1,3,0) + loopval = loopval + loop2(1,1,3,1) + loopval = loopval + loop2(1,3,1,5) + loopval = loopval + loop2(1,3,7,3) + if (loopval .ne. 87) then + print *,"lpall part 2: ", loopval, 87 + lpall = 0 + end if + end + +C Test a simple DO loop. + integer function loop1(r,n) + implicit none + integer r,n,i + + loop1 = r + do i=1,n + loop1 = loop1 + 1 + end do + end + +C Test nested DO loops. + integer function loop2(r, l, m, n) + implicit none + integer r,l,m,n + integer i,j,k + loop2 = r + do i=1,l + do j=1,m + do k=1,n + loop2 = loop2 + 1 + end do + end do + end do + end + +C Test various combinations of IF-THEN-ELSE and check results against +C expected values. + integer function ieall() + implicit none + integer ie1, ie2, ie3 + integer ieval + ieall = 1 + ieval = 0 + + ieval = ieval + ie1(0,2) + ieval = ieval + ie1(0,0) + ieval = ieval + ie1(1,2) + ieval = ieval + ie1(10,2) + ieval = ieval + ie1(11,11) + if (ieval .ne. 31) then + print *,"ieall part 1: ", ieval, 31 + ieall = 0 + end if + + ieval = 0 + ieval = ieval + ie2(0) + ieval = ieval + ie2(2) + ieval = ieval + ie2(2) + ieval = ieval + ie2(2) + ieval = ieval + ie2(3) + ieval = ieval + ie2(3) + if (ieval .ne. 23) then + print *,"ieall part 2: ", ieval, 23 + ieall = 0 + end if + + ieval = 0 + ieval = ieval + ie3(11,19) + ieval = ieval + ie3(25,27) + ieval = ieval + ie3(11,22) + ieval = ieval + ie3(11,10) + ieval = ieval + ie3(21,32) + ieval = ieval + ie3(21,20) + ieval = ieval + ie3(1,2) + ieval = ieval + ie3(32,31) + ieval = ieval + ie3(3,0) + ieval = ieval + ie3(0,47) + ieval = ieval + ie3(65,65) + if (ieval .ne. 246) then + print *,"ieall part 3: ", ieval, 246 + ieall = 0 + end if + end + +C Test IF-THEN-ELSE. + integer function ie1(i,j) + implicit none + integer i,j + integer foo + + ie1 = 0 + if (i .ne. 0) then + if (j .ne. 0) then + ie1 = foo(4) + else + ie1 = foo(1024) + end if + else + if (j .ne. 0) then + ie1 = foo(1) + else + ie1 = foo(2) + end if + end if + if (i .gt. j) then + ie1 = foo(ie1*2) + end if + if (i .gt. 10) then + if (j .gt. 10) then + ie1 = foo(ie1*4) + end if + end if + end + +C Test a series of simple IF-THEN statements. + integer function ie2(i) + implicit none + integer i + integer foo + ie2 = 0 + + if (i .eq. 0) then + ie2 = foo(1) + end if + if (i .eq. 1) then + ie2 = foo(1024) + end if + if (i .eq. 2) then + ie2 = foo(2) + end if + if (i .eq. 3) then + ie2 = foo(8) + end if + if (i .eq. 4) then + ie2 = foo(2048) + end if + + end + +C Test nested IF statements and IF with compound expressions. + integer function ie3(i,j) + implicit none + integer i,j + integer foo + + ie3 = 1 + if ((i .gt. 10) .and. (j .gt. i) .and. (j .lt. 20)) then + ie3 = foo(16) + end if + if (i .gt. 20) then + if (j .gt. i) then + if (j .lt. 30) then + ie3 = foo(32) + end if + end if + end if + if ((i .eq. 3) .or. (j .eq. 47) .or. (i .eq.j)) then + ie3 = foo(64) + end if + end diff --git a/gcc/testsuite/gcc.misc-tests/bprob.exp b/gcc/testsuite/gcc.misc-tests/bprob.exp index d6c5d17d802..5f370682a53 100644 --- a/gcc/testsuite/gcc.misc-tests/bprob.exp +++ b/gcc/testsuite/gcc.misc-tests/bprob.exp @@ -48,10 +48,6 @@ if $tracelevel then { # Load support procs. load_lib profopt.exp -# Clean up existing .da and .tim files. -profopt-cleanup da -profopt-cleanup tim - foreach src [lsort [glob -nocomplain $srcdir/$subdir/bprob-*.c]] { # If we're only testing specific files and this isn't one of them, skip it. if ![runtest_file_p $runtests $src] then { diff --git a/gcc/testsuite/lib/profopt.exp b/gcc/testsuite/lib/profopt.exp index 57d79e956b3..5ecf314977f 100644 --- a/gcc/testsuite/lib/profopt.exp +++ b/gcc/testsuite/lib/profopt.exp @@ -71,10 +71,13 @@ set option_list $PROFOPT_OPTIONS # # profopt-cleanup -- remove profiling or performance results files. # -# EXT is the extension of files to remove +# TESTCASE is the name of the test +# EXT is the extension of file to remove # -proc profopt-cleanup { ext } { - set files [glob -nocomplain *.$ext] +proc profopt-cleanup { testcase ext } { + set basename [file tail $testcase] + set base [file rootname $basename] + set files [glob -nocomplain $base.$ext] if { $files != "" } { eval "remote_file build delete $files" } @@ -112,7 +115,7 @@ proc profopt-perf-value { testcase perf_ext optstr } { fail "$testcase perf check: file $base.$perf_ext has wrong format, $optstr" } close $fd - profopt-cleanup $perf_ext + profopt-cleanup $testcase $perf_ext return $val } @@ -150,6 +153,12 @@ proc profopt-execute { src } { remote_file build delete $execname3 verbose "Testing $testcase, $option" 1 + # Remove old profiling and performance data files. + profopt-cleanup $testcase $prof_ext + if [info exists perf_ext] { + profopt-cleanup $testcase $perf_ext + } + # Compile for profiling. set options "" @@ -210,7 +219,7 @@ proc profopt-execute { src } { } # Remove the profiling data files. - profopt-cleanup $prof_ext + profopt-cleanup $testcase $prof_ext # If the test is not expected to produce performance data then # we're done now.