From d1fcc2bdef93fa453b326749888275c80e39cefc Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Tue, 7 Jun 2016 23:34:27 +0200 Subject: [PATCH] predict.c (predict_iv_comparison): Mention that heuristics is broken. * predict.c (predict_iv_comparison): Mention that heuristics is broken. (return_prediction): PRED_CONST_RETURN predict return as not taken. * predict.def (PRED_CONTINUE): Change hitrate 50->67 (PRED_LOOP_BRANCH): Document predictor as broken. (PRED_LOOP_EXIT): Change hitrate 91->92. (PRED_LOOP_EXTRA_EXIT): Change hitrate 91->83. (PRED_POINTER, PRED_TREE_POINTER): Change hitrate 85->70. (PRED_OPCODE_POSITIVE): Change hitrate 79->64. (PRED_OPCODE_NONEQUAL): Change hitrate 91->66. (PRED_TREE_OPCODE_POSITIVE): Change hitrate 73->64 (PRED_TREE_OPCODE_NONEQUAL): Chnage hitrate 72->66 (PRED_CALL): Chane hitrate 71->67. (PRED_TREE_EARLY_RETURN): Document issues, change hitrate 61->54. (PRED_GOTO): Document as unused right now. (PRED_CONST_RETURN): Change hitrate 67->69 (PRED_NEGATIVE_RETURN): Change hitrate 96->98 (PRED_NULL_RETURN): Change hitrate 91->90. (PRED_LOOP_IV_COMPARE_GUESS): Change hitrate to 98. (PRED_FORTRAN_FAIL_ALLOC): Change hitrate to 62; document issues. (PRED_FORTRAN_SIZE_ZERO): Change hitrate to 99. * gcc.dg/ipa/inlinehint-4.c: Disable partial inlining. * gcc.dg/predict-1.c: Update template for new predictor hitrates. * gcc.dg/predict-3.c: Update template. * gcc.dg/predict-5.c: Update template. * gcc.dg/predict-6.c: Update template. * gcc.dg/predict-9.c: Update template. * gcc.dg/predict-9.c: Update template. * gcc.dg/tree-ssa/attr-hotcold-2.c: Update template. From-SVN: r237185 --- gcc/ChangeLog | 23 +++++++ gcc/predict.c | 3 +- gcc/predict.def | 64 +++++++++++-------- gcc/testsuite/ChangeLog | 10 +++ gcc/testsuite/gcc.dg/ipa/inlinehint-4.c | 2 +- gcc/testsuite/gcc.dg/predict-1.c | 2 +- gcc/testsuite/gcc.dg/predict-3.c | 2 +- gcc/testsuite/gcc.dg/predict-5.c | 2 +- gcc/testsuite/gcc.dg/predict-6.c | 2 +- gcc/testsuite/gcc.dg/predict-9.c | 2 +- .../gcc.dg/tree-ssa/attr-hotcold-2.c | 8 ++- 11 files changed, 85 insertions(+), 35 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 917669ffcee..ac812db67ee 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,26 @@ +2016-06-07 Jan Hubicka + + * predict.c (predict_iv_comparison): Mention that heuristics is broken. + (return_prediction): PRED_CONST_RETURN predict return as not taken. + * predict.def (PRED_CONTINUE): Change hitrate 50->67 + (PRED_LOOP_BRANCH): Document predictor as broken. + (PRED_LOOP_EXIT): Change hitrate 91->92. + (PRED_LOOP_EXTRA_EXIT): Change hitrate 91->83. + (PRED_POINTER, PRED_TREE_POINTER): Change hitrate 85->70. + (PRED_OPCODE_POSITIVE): Change hitrate 79->64. + (PRED_OPCODE_NONEQUAL): Change hitrate 91->66. + (PRED_TREE_OPCODE_POSITIVE): Change hitrate 73->64 + (PRED_TREE_OPCODE_NONEQUAL): Chnage hitrate 72->66 + (PRED_CALL): Chane hitrate 71->67. + (PRED_TREE_EARLY_RETURN): Document issues, change hitrate 61->54. + (PRED_GOTO): Document as unused right now. + (PRED_CONST_RETURN): Change hitrate 67->69 + (PRED_NEGATIVE_RETURN): Change hitrate 96->98 + (PRED_NULL_RETURN): Change hitrate 91->90. + (PRED_LOOP_IV_COMPARE_GUESS): Change hitrate to 98. + (PRED_FORTRAN_FAIL_ALLOC): Change hitrate to 62; document issues. + (PRED_FORTRAN_SIZE_ZERO): Change hitrate to 99. + 2016-06-07 Bill Seurer * config/rs6000/altivec.h: Add __builtin_vec_mul. diff --git a/gcc/predict.c b/gcc/predict.c index 32d45678f25..6f81b537989 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -1357,6 +1357,7 @@ predict_iv_comparison (struct loop *loop, basic_block bb, probability = tem.to_uhwi (); } + /* FIXME: The branch prediction seems broken. It has only 20% hitrate. */ if (!overall_overflow) predict_edge (then_edge, PRED_LOOP_IV_COMPARE, probability); @@ -2159,7 +2160,7 @@ return_prediction (tree val, enum prediction *prediction) if (TREE_CONSTANT (val) && (!integer_zerop (val) && !integer_onep (val))) { - *prediction = TAKEN; + *prediction = NOT_TAKEN; return PRED_CONST_RETURN; } } diff --git a/gcc/predict.def b/gcc/predict.def index 9c7db7ab072..e1c5faee258 100644 --- a/gcc/predict.def +++ b/gcc/predict.def @@ -78,7 +78,7 @@ DEF_PREDICTOR (PRED_LOOP_ITERATIONS_MAX, "guessed loop iterations", PROB_ALWAYS, PRED_FLAG_FIRST_MATCH) /* Branch containing goto is probably not taken. */ -DEF_PREDICTOR (PRED_CONTINUE, "continue", HITRATE (50), 0) +DEF_PREDICTOR (PRED_CONTINUE, "continue", HITRATE (67), 0) /* Branch to basic block containing call marked by noreturn attribute. */ DEF_PREDICTOR (PRED_NORETURN, "noreturn call", PROB_VERY_LIKELY, @@ -88,53 +88,66 @@ DEF_PREDICTOR (PRED_NORETURN, "noreturn call", PROB_VERY_LIKELY, DEF_PREDICTOR (PRED_COLD_FUNCTION, "cold function call", PROB_VERY_LIKELY, PRED_FLAG_FIRST_MATCH) -/* Loopback edge is taken. */ +/* Loopback edge is taken. + FIXME: This is currently disabled because loop_optimizer_init force + loops to have simple latches. */ DEF_PREDICTOR (PRED_LOOP_BRANCH, "loop branch", HITRATE (86), PRED_FLAG_FIRST_MATCH) /* Edge causing loop to terminate is probably not taken. */ -DEF_PREDICTOR (PRED_LOOP_EXIT, "loop exit", HITRATE (91), +DEF_PREDICTOR (PRED_LOOP_EXIT, "loop exit", HITRATE (92), PRED_FLAG_FIRST_MATCH) -/* Edge causing loop to terminate by computing value used by later conditional. - */ -DEF_PREDICTOR (PRED_LOOP_EXTRA_EXIT, "extra loop exit", HITRATE (91), +/* Edge causing loop to terminate by computing value used by later + conditional. */ +DEF_PREDICTOR (PRED_LOOP_EXTRA_EXIT, "extra loop exit", HITRATE (83), PRED_FLAG_FIRST_MATCH) /* Pointers are usually not NULL. */ -DEF_PREDICTOR (PRED_POINTER, "pointer", HITRATE (85), 0) -DEF_PREDICTOR (PRED_TREE_POINTER, "pointer (on trees)", HITRATE (85), 0) +DEF_PREDICTOR (PRED_POINTER, "pointer", HITRATE (70), 0) +DEF_PREDICTOR (PRED_TREE_POINTER, "pointer (on trees)", HITRATE (70), 0) /* NE is probable, EQ not etc... */ -DEF_PREDICTOR (PRED_OPCODE_POSITIVE, "opcode values positive", HITRATE (79), 0) -DEF_PREDICTOR (PRED_OPCODE_NONEQUAL, "opcode values nonequal", HITRATE (71), 0) +DEF_PREDICTOR (PRED_OPCODE_POSITIVE, "opcode values positive", HITRATE (64), 0) +DEF_PREDICTOR (PRED_OPCODE_NONEQUAL, "opcode values nonequal", HITRATE (66), 0) DEF_PREDICTOR (PRED_FPOPCODE, "fp_opcode", HITRATE (90), 0) -DEF_PREDICTOR (PRED_TREE_OPCODE_POSITIVE, "opcode values positive (on trees)", HITRATE (73), 0) -DEF_PREDICTOR (PRED_TREE_OPCODE_NONEQUAL, "opcode values nonequal (on trees)", HITRATE (72), 0) +DEF_PREDICTOR (PRED_TREE_OPCODE_POSITIVE, "opcode values positive (on trees)", HITRATE (64), 0) +DEF_PREDICTOR (PRED_TREE_OPCODE_NONEQUAL, "opcode values nonequal (on trees)", HITRATE (66), 0) DEF_PREDICTOR (PRED_TREE_FPOPCODE, "fp_opcode (on trees)", HITRATE (90), 0) /* Branch guarding call is probably taken. */ -DEF_PREDICTOR (PRED_CALL, "call", HITRATE (71), 0) - -/* Branch causing function to terminate is probably not taken. */ -DEF_PREDICTOR (PRED_TREE_EARLY_RETURN, "early return (on trees)", HITRATE (61), 0) - -/* Branch containing goto is probably not taken. */ +DEF_PREDICTOR (PRED_CALL, "call", HITRATE (67), 0) + +/* Branch causing function to terminate is probably not taken. + FIXME: early return currently predicts code: + int foo (int a) + { + if (a) + bar(); + else + bar2(); + } + even though there is no return statement involved. We probably want to track + this from FE or retire the predictor. */ +DEF_PREDICTOR (PRED_TREE_EARLY_RETURN, "early return (on trees)", HITRATE (54), 0) + +/* Branch containing goto is probably not taken. + FIXME: Currently not used. */ DEF_PREDICTOR (PRED_GOTO, "goto", HITRATE (70), 0) /* Branch ending with return constant is probably not taken. */ -DEF_PREDICTOR (PRED_CONST_RETURN, "const return", HITRATE (67), 0) +DEF_PREDICTOR (PRED_CONST_RETURN, "const return", HITRATE (69), 0) /* Branch ending with return negative constant is probably not taken. */ -DEF_PREDICTOR (PRED_NEGATIVE_RETURN, "negative return", HITRATE (96), 0) +DEF_PREDICTOR (PRED_NEGATIVE_RETURN, "negative return", HITRATE (98), 0) /* Branch ending with return; is probably not taken */ -DEF_PREDICTOR (PRED_NULL_RETURN, "null return", HITRATE (90), 0) +DEF_PREDICTOR (PRED_NULL_RETURN, "null return", HITRATE (91), 0) /* Branches to compare induction variable to a loop bound is extremely likely. */ DEF_PREDICTOR (PRED_LOOP_IV_COMPARE_GUESS, "guess loop iv compare", - PROB_VERY_LIKELY, 0) + HITRATE (98), 0) /* Use number of loop iterations determined by # of iterations analysis to set probability of branches that compares IV to loop bound variable. */ @@ -159,8 +172,9 @@ DEF_PREDICTOR (PRED_FORTRAN_OVERFLOW, "overflow", PROB_ALWAYS, of memory or when trying to allocate an already allocated allocated or deallocating an already deallocated allocatable. This predictor only occurs when the user explicitly asked for a return status. By default, - the code aborts, which is handled via PRED_NORETURN. */ -DEF_PREDICTOR (PRED_FORTRAN_FAIL_ALLOC, "fail alloc", PROB_VERY_LIKELY, 0) + the code aborts, which is handled via PRED_NORETURN. + FIXME: the hitrate really ought to be close to 100%. */ +DEF_PREDICTOR (PRED_FORTRAN_FAIL_ALLOC, "fail alloc", HITRATE (62), 0) /* Branch leading to an I/O failure status are unlikely. This predictor is used for I/O failures such as for invalid unit numbers. This predictor @@ -173,7 +187,7 @@ DEF_PREDICTOR (PRED_FORTRAN_FAIL_IO, "fail IO", HITRATE (85), 0) DEF_PREDICTOR (PRED_FORTRAN_WARN_ONCE, "warn once", HITRATE (75), 0) /* Branch belonging to a zero-sized array. */ -DEF_PREDICTOR (PRED_FORTRAN_SIZE_ZERO, "zero-sized array", HITRATE(70), 0) +DEF_PREDICTOR (PRED_FORTRAN_SIZE_ZERO, "zero-sized array", HITRATE(99), 0) /* Branch belonging to an invalid bound index, in a context where it is standard conform and well defined but rather pointless and, hence, rather diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 837d408b4cc..406cc039bf1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2016-06-07 Jan Hubicka + + * gcc.dg/ipa/inlinehint-4.c: Disable partial inlining. + * gcc.dg/predict-1.c: Update template for new predictor hitrates. + * gcc.dg/predict-3.c: Update template. + * gcc.dg/predict-5.c: Update template. + * gcc.dg/predict-6.c: Update template. + * gcc.dg/predict-9.c: Update template. + * gcc.dg/tree-ssa/attr-hotcold-2.c: Update template. + 2016-06-07 Bill Seurer * gcc.target/powerpc/vec-mul.c: New test. diff --git a/gcc/testsuite/gcc.dg/ipa/inlinehint-4.c b/gcc/testsuite/gcc.dg/ipa/inlinehint-4.c index 1939bb68f83..441a0c70855 100644 --- a/gcc/testsuite/gcc.dg/ipa/inlinehint-4.c +++ b/gcc/testsuite/gcc.dg/ipa/inlinehint-4.c @@ -1,4 +1,4 @@ -/* { dg-options "-O3 -fdump-ipa-inline-details -fno-early-inlining --param large-unit-insns=1" } */ +/* { dg-options "-O3 -fdump-ipa-inline-details -fno-early-inlining --param large-unit-insns=1 -fno-partial-inlining" } */ /* { dg-add-options bind_pic_locally } */ int *hashval; int *hash; diff --git a/gcc/testsuite/gcc.dg/predict-1.c b/gcc/testsuite/gcc.dg/predict-1.c index a2a06044384..94f6b0190a1 100644 --- a/gcc/testsuite/gcc.dg/predict-1.c +++ b/gcc/testsuite/gcc.dg/predict-1.c @@ -23,4 +23,4 @@ void foo (int bound) } } -/* { dg-final { scan-tree-dump-times "loop iv compare heuristics: 0.0%" 5 "profile_estimate"} } */ +/* { dg-final { scan-tree-dump-times "loop iv compare heuristics: 2.0%" 5 "profile_estimate"} } */ diff --git a/gcc/testsuite/gcc.dg/predict-3.c b/gcc/testsuite/gcc.dg/predict-3.c index e1be7cc3c95..08db59a559f 100644 --- a/gcc/testsuite/gcc.dg/predict-3.c +++ b/gcc/testsuite/gcc.dg/predict-3.c @@ -25,4 +25,4 @@ void foo (int bound) } } -/* { dg-final { scan-tree-dump-times "loop iv compare heuristics: 100.0%" 3 "profile_estimate"} } */ +/* { dg-final { scan-tree-dump-times "loop iv compare heuristics: 98.0%" 3 "profile_estimate"} } */ diff --git a/gcc/testsuite/gcc.dg/predict-5.c b/gcc/testsuite/gcc.dg/predict-5.c index 3e7cc6fdfc0..32178a8ea5f 100644 --- a/gcc/testsuite/gcc.dg/predict-5.c +++ b/gcc/testsuite/gcc.dg/predict-5.c @@ -21,4 +21,4 @@ void foo (int base, int bound) } } -/* { dg-final { scan-tree-dump-times "loop iv compare heuristics: 100.0%" 4 "profile_estimate"} } */ +/* { dg-final { scan-tree-dump-times "loop iv compare heuristics: 98.0%" 4 "profile_estimate"} } */ diff --git a/gcc/testsuite/gcc.dg/predict-6.c b/gcc/testsuite/gcc.dg/predict-6.c index cda30e26e30..16ad16fdb25 100644 --- a/gcc/testsuite/gcc.dg/predict-6.c +++ b/gcc/testsuite/gcc.dg/predict-6.c @@ -21,4 +21,4 @@ void foo (int base, int bound) } } -/* { dg-final { scan-tree-dump-times "loop iv compare heuristics: 0.0%" 4 "profile_estimate"} } */ +/* { dg-final { scan-tree-dump-times "loop iv compare heuristics: 2.0%" 4 "profile_estimate"} } */ diff --git a/gcc/testsuite/gcc.dg/predict-9.c b/gcc/testsuite/gcc.dg/predict-9.c index 3cba9f9da2b..a613961091d 100644 --- a/gcc/testsuite/gcc.dg/predict-9.c +++ b/gcc/testsuite/gcc.dg/predict-9.c @@ -20,4 +20,4 @@ void foo (int base) } /* { dg-final { scan-tree-dump-times "first match heuristics: 2.0%" 3 "profile_estimate"} } */ -/* { dg-final { scan-tree-dump-times "first match heuristics: 4.5%" 1 "profile_estimate"} } */ +/* { dg-final { scan-tree-dump-times "first match heuristics: 4.0%" 1 "profile_estimate"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c b/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c index 10b8f0edb19..6623d9ee61e 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-ipa-profile_estimate-blocks-details" } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate-blocks-details" } */ void g(void); void h(void); @@ -18,10 +18,12 @@ void f(int x, int y) return; } -/* { dg-final { scan-ipa-dump-times "block 4, loop depth 0, count 0, freq 1\[^0-9\]" 1 "profile_estimate" } } */ +/* { dg-final { scan-tree-dump-times 1 "hot label heuristics" 1 "profile_estimate" } } */ +/* { dg-final { scan-tree-dump-times 1 "cold label heuristics" 1 "profile_estimate" } } */ +/* { dg-final { scan-tree-dump-times "block 4, loop depth 0, count 0, freq \[1-4\]\[^0-9\]" 1 "profile_estimate" } } */ /* Note: we're attempting to match some number > 6000, i.e. > 60%. The exact number ought to be tweekable without having to juggle the testcase around too much. */ -/* { dg-final { scan-ipa-dump-times "block 5, loop depth 0, count 0, freq \[6-9\]\[0-9\]\[0-9\]\[0-9\]" 1 "profile_estimate" } } */ +/* { dg-final { scan-tree-dump-times "block 5, loop depth 0, count 0, freq \[6-9\]\[0-9\]\[0-9\]\[0-9\]" 1 "profile_estimate" } } */ -- 2.30.2