Commit 9312aecc by John David Anglin Committed by John David Anglin

stmt.c (emit_case_nodes): Widen high and low instead of new_bound and low to get…

stmt.c (emit_case_nodes): Widen high and low instead of new_bound and low to get correct sign extension...

	* stmt.c (emit_case_nodes): Widen high and low instead of new_bound
	and low to get correct sign extension in low+high test.

From-SVN: r43945
parent 4b9664e2
2001-07-11 John David Anglin <dave@hiauly1.hia.nrc.ca>
* stmt.c (emit_case_nodes): Widen high and low instead of new_bound
and low to get correct sign extension in low+high test.
2001-07-11 Janis Johnson <janis@us.ibm.com> 2001-07-11 Janis Johnson <janis@us.ibm.com>
* gcov.c (arcdata): Use gcov_type to fix branch percentage * gcov.c (arcdata): Use gcov_type to fix branch percentage
......
...@@ -6370,26 +6370,23 @@ emit_case_nodes (index, node, default_label, index_type) ...@@ -6370,26 +6370,23 @@ emit_case_nodes (index, node, default_label, index_type)
} }
else if (!low_bound && !high_bound) else if (!low_bound && !high_bound)
{ {
/* Instead of doing two branches, emit /* Widen LOW and HIGH to the same width as INDEX. */
(index-low) <= (high-low). */ tree type = type_for_mode (mode, unsignedp);
tree new_bound = fold (build (MINUS_EXPR, index_type, node->high, tree low = build1 (CONVERT_EXPR, type, node->low);
node->low)); tree high = build1 (CONVERT_EXPR, type, node->high);
rtx new_index; rtx new_index, new_bound;
/* Instead of doing two branches, emit one unsigned branch for
(index-low) > (high-low). */
new_index = expand_binop (mode, sub_optab, index, new_index = expand_binop (mode, sub_optab, index,
convert_modes (mode, imode, expand_expr (low, NULL_RTX, mode, 0),
expand_expr (node->low, NULL_RTX,
mode, 0),
unsignedp),
NULL_RTX, unsignedp, OPTAB_WIDEN); NULL_RTX, unsignedp, OPTAB_WIDEN);
new_bound = expand_expr (fold (build (MINUS_EXPR, type,
high, low)),
NULL_RTX, mode, 0);
emit_cmp_and_jump_insns (new_index, emit_cmp_and_jump_insns (new_index, new_bound, GT, NULL_RTX,
convert_modes (mode, imode, mode, 1, 0, default_label);
expand_expr (new_bound, NULL_RTX,
mode, 0),
unsignedp),
GT, NULL_RTX, mode, 1, 0,
default_label);
} }
emit_jump (label_rtx (node->code_label)); emit_jump (label_rtx (node->code_label));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment