From: Martin Liska Date: Thu, 7 Jul 2016 13:11:05 +0000 (+0200) Subject: Add PRED_FORTRAN_LOOP_PREHEADER to DO loops with step X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7119f1b1a43b6721cd95fe381378f92f699e967a;p=gcc.git Add PRED_FORTRAN_LOOP_PREHEADER to DO loops with step * trans-stmt.c (gfc_trans_do): Add expect builtin for DO loops with step bigger than +-1. * gfortran.dg/predict-1.f90: Ammend the test. * gfortran.dg/predict-2.f90: Likewise. From-SVN: r238112 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ed6b40b1408..983e75f5f6d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2016-07-07 Martin Liska + + * trans-stmt.c (gfc_trans_do): Add expect builtin for DO + loops with step bigger than +-1. + 2016-07-05 Alessandro Fanfarillo * array.c (gfc_match_array_ref): Add parsing support for diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 5aa77789b14..ad88273c876 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -2109,7 +2109,8 @@ gfc_trans_do (gfc_code * code, tree exit_cond) pos = build2 (COMPOUND_EXPR, void_type_node, fold_build2 (MODIFY_EXPR, void_type_node, countm1, tmp2), - build3_loc (loc, COND_EXPR, void_type_node, tmp, + build3_loc (loc, COND_EXPR, void_type_node, + gfc_unlikely (tmp, PRED_FORTRAN_LOOP_PREHEADER), build1_loc (loc, GOTO_EXPR, void_type_node, exit_label), NULL_TREE)); @@ -2123,7 +2124,8 @@ gfc_trans_do (gfc_code * code, tree exit_cond) neg = build2 (COMPOUND_EXPR, void_type_node, fold_build2 (MODIFY_EXPR, void_type_node, countm1, tmp2), - build3_loc (loc, COND_EXPR, void_type_node, tmp, + build3_loc (loc, COND_EXPR, void_type_node, + gfc_unlikely (tmp, PRED_FORTRAN_LOOP_PREHEADER), build1_loc (loc, GOTO_EXPR, void_type_node, exit_label), NULL_TREE)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f5bf6b137b6..cdc7c06ecbe 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-07-07 Martin Liska + + * gfortran.dg/predict-1.f90: Ammend the test. + * gfortran.dg/predict-2.f90: Likewise. + 2016-07-07 Ilya Enkovich PR ipa/71624 diff --git a/gcc/testsuite/gfortran.dg/predict-1.f90 b/gcc/testsuite/gfortran.dg/predict-1.f90 index 81f0436fba4..a3feea9b123 100644 --- a/gcc/testsuite/gfortran.dg/predict-1.f90 +++ b/gcc/testsuite/gfortran.dg/predict-1.f90 @@ -4,9 +4,14 @@ subroutine test(block, array) integer :: i, block(9), array(2) -do i = array(1), array(2) +do i = array(1), array(2), 2 block(i) = i end do + +do i = array(1), array(2), -2 + block(i) = block(i) + i +end do + end subroutine test -! { dg-final { scan-tree-dump-times "Fortran loop preheader heuristics of edge\[^:\]*: 99.0%" 1 "profile_estimate" } } +! { dg-final { scan-tree-dump-times "Fortran loop preheader heuristics of edge\[^:\]*: 1.0%" 2 "profile_estimate" } } diff --git a/gcc/testsuite/gfortran.dg/predict-2.f90 b/gcc/testsuite/gfortran.dg/predict-2.f90 index 4ae5c3a298e..11a9ec5fd4b 100644 --- a/gcc/testsuite/gfortran.dg/predict-2.f90 +++ b/gcc/testsuite/gfortran.dg/predict-2.f90 @@ -4,12 +4,12 @@ subroutine test(block, array) integer :: i,j, block(9), array(2) -do i = array(1), array(2) - do j = array(1), array(2) +do i = array(1), array(2), 2 + do j = array(1), array(2), 3 block(i) = j end do end do end subroutine test ! { dg-final { scan-tree-dump-times "Fortran loop preheader heuristics of edge" 2 "profile_estimate" } } -! { dg-final { scan-tree-dump-times "loop gueard" 0 "profile_estimate" } } +! { dg-final { scan-tree-dump-times "loop guard" 0 "profile_estimate" } }