Introduce fortran loop preheader

* predict.def: Add fortran loop preheader predictor.
	* gimple-fold.c (gimple_fold_stmt_to_constant_1): Properly
	fold IFN_BUILTIN_EXPECT with a known constant argument.
	* trans-stmt.c (gfc_trans_simple_do): Predict the edge.
	* gfortran.dg/predict-1.f90: New test.

From-SVN: r237533
This commit is contained in:
Martin Liska 2016-06-16 18:05:25 +02:00 committed by Martin Liska
parent 8b051d2e6c
commit 68fa96d625
7 changed files with 43 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2016-06-16 Martin Liska <mliska@suse.cz>
* predict.def: Add fortran loop preheader predictor.
* gimple-fold.c (gimple_fold_stmt_to_constant_1): Properly
fold IFN_BUILTIN_EXPECT with a known constant argument.
2016-06-16 Martin Liska <mliska@suse.cz>
* predict.def: Add 'Fortran' to display text of all

View File

@ -1,3 +1,7 @@
2016-06-16 Martin Liska <mliska@suse.cz>
* trans-stmt.c (gfc_trans_simple_do): Predict the edge.
2016-06-16 Martin Liska <mliska@suse.cz>
* trans-array.c (gfc_array_allocate): Do not generate expect

View File

@ -1938,7 +1938,9 @@ gfc_trans_simple_do (gfc_code * code, stmtblock_t *pblock, tree dovar,
else
cond = fold_build2_loc (loc, GE_EXPR, boolean_type_node, dovar,
to);
tmp = fold_build3_loc (loc, COND_EXPR, void_type_node, cond, tmp,
tmp = fold_build3_loc (loc, COND_EXPR, void_type_node,
gfc_likely (cond, PRED_FORTRAN_LOOP_PREHEADER), tmp,
build_empty_stmt (loc));
gfc_add_expr_to_block (pblock, tmp);

View File

@ -5250,6 +5250,14 @@ gimple_fold_stmt_to_constant_1 (gimple *stmt, tree (*valueize) (tree),
case IFN_UBSAN_CHECK_MUL:
subcode = MULT_EXPR;
break;
case IFN_BUILTIN_EXPECT:
{
tree arg0 = gimple_call_arg (stmt, 0);
tree op0 = (*valueize) (arg0);
if (TREE_CODE (op0) == INTEGER_CST)
return op0;
return NULL_TREE;
}
default:
return NULL_TREE;
}

View File

@ -199,3 +199,9 @@ DEF_PREDICTOR (PRED_FORTRAN_INVALID_BOUND, "Fortran invalid bound", \
which in turn has an optional argument. */
DEF_PREDICTOR (PRED_FORTRAN_ABSENT_DUMMY, "Fortran absent dummy", \
HITRATE (60), 0)
/* Fortran DO statement generates a pre-header guard:
empty = (step > 0 ? to < from : to > from), which can be predicted
to be very likely. */
DEF_PREDICTOR (PRED_FORTRAN_LOOP_PREHEADER, "Fortran loop preheader", \
HITRATE (99), 0)

View File

@ -1,3 +1,7 @@
2016-06-16 Martin Liska <mliska@suse.cz>
* gfortran.dg/predict-1.f90: New test.
2016-06-16 Uros Bizjak <ubizjak@gmail.com>
PR target/71242

View File

@ -0,0 +1,12 @@
! { dg-do compile }
! { dg-options "-O2 -fdump-tree-profile_estimate" }
subroutine test(block, array)
integer :: i, block(9), array(2)
do i = array(1), array(2)
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" } }