aboutsummaryrefslogtreecommitdiff
path: root/gcc/stmt.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2001-06-18 17:35:47 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2001-06-18 15:35:47 +0000
commit923cbdc322ee080c02b94a95eece0618a2a78b47 (patch)
tree0803743d2349ea46ce205c05df7cae76a3374b1f /gcc/stmt.c
parent049d2def48689b21149b6a7ad19c865e1d393627 (diff)
downloadgcc-923cbdc322ee080c02b94a95eece0618a2a78b47.zip
gcc-923cbdc322ee080c02b94a95eece0618a2a78b47.tar.gz
gcc-923cbdc322ee080c02b94a95eece0618a2a78b47.tar.bz2
unroll.c: Include predict.h.
* unroll.c: Include predict.h. (unroll_loop): Drop prediction notes on preconditioning. * predict.def (PRED_LOOP_PRECONDITIONG, PRED_LOOP_CONDITION): New; add comments on the others. * Makefile.in: (unroll.o): Add dependancy on predict.h. * loop.c (strength_reduce): Fix branch prediction. * stmt.c (emit_case_nodes): Optimize test whether index is in given interval. * predict.c (estimate_probability): Do not bail out early when note is present. (combine_predictions_for_insn): Fix note removal code. From-SVN: r43441
Diffstat (limited to 'gcc/stmt.c')
-rw-r--r--gcc/stmt.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 3cefc7c..ee4523c 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -6293,8 +6293,10 @@ emit_case_nodes (index, node, default_label, index_type)
/* Node has no children so we check low and high bounds to remove
redundant tests. Only one of the bounds can exist,
since otherwise this node is bounded--a case tested already. */
+ int high_bound = node_has_high_bound (node, index_type);
+ int low_bound = node_has_low_bound (node, index_type);
- if (!node_has_high_bound (node, index_type))
+ if (!high_bound && low_bound)
{
emit_cmp_and_jump_insns (index,
convert_modes
@@ -6306,7 +6308,7 @@ emit_case_nodes (index, node, default_label, index_type)
default_label);
}
- if (!node_has_low_bound (node, index_type))
+ else if (!low_bound && high_bound)
{
emit_cmp_and_jump_insns (index,
convert_modes
@@ -6317,6 +6319,24 @@ emit_case_nodes (index, node, default_label, index_type)
LT, NULL_RTX, mode, unsignedp, 0,
default_label);
}
+ else if (!low_bound && !high_bound)
+ {
+ /* Instead of doing two branches emit test (index-low) <= (high-low). */
+ tree new_bound = fold (build (MINUS_EXPR, index_type, node->high,
+ node->low));
+ rtx new_index;
+
+ new_index = expand_binop (mode, sub_optab, index,
+ expand_expr (node->low, NULL_RTX,
+ VOIDmode, 0),
+ NULL_RTX, 0, OPTAB_WIDEN);
+
+ emit_cmp_and_jump_insns (new_index,
+ expand_expr (new_bound, NULL_RTX,
+ VOIDmode, 0),
+ GT, NULL_RTX, mode, 1, 0,
+ default_label);
+ }
emit_jump (label_rtx (node->code_label));
}