summaryrefslogtreecommitdiff
path: root/gcc/stmt.c
diff options
context:
space:
mode:
authorkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>2004-03-25 16:16:41 +0000
committerkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>2004-03-25 16:16:41 +0000
commit84e90d04fcb32a07a99ddbdc7d913181cd902738 (patch)
treeb8180448c0f7c82d4935723ff1e395c1211301e7 /gcc/stmt.c
parent03e3a723257e49661df9511a349b6b2f2f0747a9 (diff)
downloadgcc-84e90d04fcb32a07a99ddbdc7d913181cd902738.tar.gz
PR optimization/9707.
* stmt.c (emit_case_nodes): Emit equality comparisons instead of recursing if both children are single-valued cases with no children. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@79954 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/stmt.c')
-rw-r--r--gcc/stmt.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 3d5da37e8cc..a28a01484d7 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -6200,6 +6200,42 @@ emit_case_nodes (rtx index, case_node_ptr node, rtx default_label,
emit_case_nodes (index, node->right, default_label, index_type);
}
+ /* If both children are single-valued cases with no
+ children, finish up all the work. This way, we can save
+ one ordered comparison. */
+ else if (tree_int_cst_equal (node->right->low, node->right->high)
+ && node->right->left == 0
+ && node->right->right == 0
+ && tree_int_cst_equal (node->left->low, node->left->high)
+ && node->left->left == 0
+ && node->left->right == 0)
+ {
+ /* Neither node is bounded. First distinguish the two sides;
+ then emit the code for one side at a time. */
+
+ /* See if the value matches what the right hand side
+ wants. */
+ do_jump_if_equal (index,
+ convert_modes (mode, imode,
+ expand_expr (node->right->low,
+ NULL_RTX,
+ VOIDmode, 0),
+ unsignedp),
+ label_rtx (node->right->code_label),
+ unsignedp);
+
+ /* See if the value matches what the left hand side
+ wants. */
+ do_jump_if_equal (index,
+ convert_modes (mode, imode,
+ expand_expr (node->left->low,
+ NULL_RTX,
+ VOIDmode, 0),
+ unsignedp),
+ label_rtx (node->left->code_label),
+ unsignedp);
+ }
+
else
{
/* Neither node is bounded. First distinguish the two sides;