summaryrefslogtreecommitdiff
path: root/gcc/stmt.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2001-06-18 15:35:47 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2001-06-18 15:35:47 +0000
commitf6664feec514b2e3b3f36fb59c9b1b14dc5a52fc (patch)
tree0803743d2349ea46ce205c05df7cae76a3374b1f /gcc/stmt.c
parent55af5e57a6fa3e4016d3723e03c3a1926ea9e9ee (diff)
downloadgcc-f6664feec514b2e3b3f36fb59c9b1b14dc5a52fc.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@43441 138bc75d-0d04-0410-961f-82ee72b054a4
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 3cefc7ce3ee..ee4523c33c5 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));
}