Add PRED_FORTRAN_LOOP_PREHEADER to DO loops with step
authorMartin Liska <mliska@suse.cz>
Thu, 7 Jul 2016 13:11:05 +0000 (15:11 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Thu, 7 Jul 2016 13:11:05 +0000 (13:11 +0000)
* 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

gcc/fortran/ChangeLog
gcc/fortran/trans-stmt.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/predict-1.f90
gcc/testsuite/gfortran.dg/predict-2.f90

index ed6b40b1408209fdd508b80e31b0a137116d3096..983e75f5f6d558ae412e5cc06fccbf07fa6a70e6 100644 (file)
@@ -1,3 +1,8 @@
+2016-07-07  Martin Liska  <mliska@suse.cz>
+
+       * trans-stmt.c (gfc_trans_do): Add expect builtin for DO
+       loops with step bigger than +-1.
+
 2016-07-05  Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>
 
        * array.c (gfc_match_array_ref): Add parsing support for
index 5aa77789b1490c7d897984a1e440f2a54631e3d5..ad88273c8762c719e2742651dca0b7c94576d66d 100644 (file)
@@ -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));
 
index f5bf6b137b6bc463d71daf6885ec2f997486a3a7..cdc7c06ecbe9f7f3896c11ab885d6edb1ccdff9c 100644 (file)
@@ -1,3 +1,8 @@
+2016-07-07  Martin Liska  <mliska@suse.cz>
+
+       * gfortran.dg/predict-1.f90: Ammend the test.
+       * gfortran.dg/predict-2.f90: Likewise.
+
 2016-07-07  Ilya Enkovich  <ilya.enkovich@intel.com>
 
        PR ipa/71624
index 81f0436fba4b449bfe249e574a14adfd45d77a7f..a3feea9b12383d6dff0781be3b783c92aca29cf0 100644 (file)
@@ -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" } }
index 4ae5c3a298ee312f989ede695bd260d35816d112..11a9ec5fd4b37e9ca76140da424102df6e73a532 100644 (file)
@@ -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" } }