diff options
author | Zack Weinberg <zack@wolery.cumb.org> | 2000-04-21 16:19:20 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2000-04-21 16:19:20 +0000 |
commit | 152897b1529264336677bc782f882a5b09041ac3 (patch) | |
tree | 35203b209db18c9660d4be98dfd9a892e8804de4 /gcc | |
parent | 93bc735f86f93c55499225f3cbe0ba828d31b126 (diff) | |
download | gcc-152897b1529264336677bc782f882a5b09041ac3.zip gcc-152897b1529264336677bc782f882a5b09041ac3.tar.gz gcc-152897b1529264336677bc782f882a5b09041ac3.tar.bz2 |
predict.c (estimate_probability): New heuristic...
* predict.c (estimate_probability): New heuristic: if a jump
branches around a block with no successors, predict it taken.
Disentangle control flow.
From-SVN: r33308
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/predict.c | 33 |
2 files changed, 33 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 99659e9..733d02d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2000-04-21 Zack Weinberg <zack@wolery.cumb.org> + + * predict.c (estimate_probability): New heuristic: if a jump + branches around a block with no successors, predict it taken. + Disentangle control flow. + 2000-04-20 Richard Henderson <rth@cygnus.com> * loop.c (emit_iv_add_mult): Revert last change. diff --git a/gcc/predict.c b/gcc/predict.c index 958dbf9..7ed4709 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -104,18 +104,37 @@ estimate_probability (loops_info) rtx last_insn = BLOCK_END (i); rtx cond, earliest; int prob = 0; + edge e; if (GET_CODE (last_insn) != JUMP_INSN || ! condjump_p (last_insn) || simplejump_p (last_insn)) continue; + if (find_reg_note (last_insn, REG_BR_PROB, 0)) + continue; cond = get_condition (last_insn, &earliest); if (! cond) continue; + /* If the jump branches around a block with no successors, + predict it to be taken. */ + prob = 0; + for (e = BASIC_BLOCK (i)->succ; e; e = e->succ_next) + if ((e->flags & EDGE_FALLTHRU) && e->dest->succ == NULL) + { + prob = REG_BR_PROB_BASE; + break; + } + if (prob) + { + REG_NOTES (last_insn) + = gen_rtx_EXPR_LIST (REG_BR_PROB, GEN_INT (prob), + REG_NOTES (last_insn)); + continue; + } + /* Try "pointer heuristic." A comparison ptr == 0 is predicted as false. Similarly, a comparison ptr1 == ptr2 is predicted as false. */ - prob = 0; switch (GET_CODE (cond)) { case EQ: @@ -137,10 +156,13 @@ estimate_probability (loops_info) default: prob = 0; } - if (prob && ! find_reg_note (last_insn, REG_BR_PROB, 0)) + if (prob) + { REG_NOTES (last_insn) = gen_rtx_EXPR_LIST (REG_BR_PROB, GEN_INT (prob), REG_NOTES (last_insn)); + continue; + } /* Try "opcode heuristic." EQ tests are usually false and NE tests are usually true. Also, @@ -174,10 +196,9 @@ estimate_probability (loops_info) default: prob = 0; } - if (! find_reg_note (last_insn, REG_BR_PROB, 0)) - REG_NOTES (last_insn) - = gen_rtx_EXPR_LIST (REG_BR_PROB, GEN_INT (prob), - REG_NOTES (last_insn)); + REG_NOTES (last_insn) + = gen_rtx_EXPR_LIST (REG_BR_PROB, GEN_INT (prob), + REG_NOTES (last_insn)); } } |