This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] Improve dominator optimizer's case label handling
- From: law at redhat dot com
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 23 Sep 2003 07:40:01 -0600
- Subject: [tree-ssa] Improve dominator optimizer's case label handling
- Reply-to: law at redhat dot com
We keep the toplevel type conversion within SWITCH_EXPR_COND to
avoid confusing stmt.c about the range values in a switch statement
might take.
However, those type conversions get in the way of creating equivalences
at case labels.
This patch allows us to enter equivalences created by case labels even
when the switch condition has a useless type conversion in it -- without
actually changing SWITCH_EXPR_COND, to keep stmt.c happy :-)
This fixes 20030922-1.c.
* tree-ssa-dom.c (optimize_block): Ignore "useless" type
conversions in SWITCH_COND when creating equivalenecs at
case labels.
Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dom.c,v
retrieving revision 1.1.2.44
diff -c -3 -p -r1.1.2.44 tree-ssa-dom.c
*** tree-ssa-dom.c 23 Sep 2003 07:21:56 -0000 1.1.2.44
--- tree-ssa-dom.c 23 Sep 2003 13:32:47 -0000
*************** optimize_block (basic_block bb, tree par
*** 382,387 ****
--- 382,391 ----
tree case_value = NULL_TREE;
tree switch_cond = SWITCH_COND (parent_block_last_stmt);
+ /* Strip away any useless type conversions. */
+ while (tree_ssa_useless_type_conversion (switch_cond))
+ switch_cond = TREE_OPERAND (switch_cond, 0);
+
/* If the switch's condition is an SSA variable, then we may
know its value at each of the case labels. */
if (TREE_CODE (switch_cond) == SSA_NAME)