https://gcc.gnu.org/bugzilla/show_bug.cgi?id=18046
--- Comment #20 from Patrick Palka <ppalka at gcc dot gnu.org> --- Author: ppalka Date: Fri Aug 5 23:29:53 2016 New Revision: 239181 URL: https://gcc.gnu.org/viewcvs?rev=239181&root=gcc&view=rev Log: Improve forward jump threading of switch statements (PR18046) gcc/ChangeLog: PR tree-optimization/18046 * tree-ssa-threadedge.c: Include cfganal.h. (simplify_control_statement_condition): If simplifying a GIMPLE_SWITCH, replace the index operand of the GIMPLE_SWITCH with the dominating ASSERT_EXPR before handing it off to VRP. Mention that a CASE_LABEL_EXPR may be returned. (thread_around_empty_blocks): Adjust to handle simplify_control_statement_condition() returning a CASE_LABEL_EXPR. (thread_through_normal_block): Likewise. * tree-vrp.c (simplify_stmt_for_jump_threading): Simplify a switch statement by trying to determine which case label will be taken. gcc/testsuite/ChangeLog: PR tree-optimization/18046 * gcc.dg/tree-ssa/vrp105.c: New test. * gcc.dg/tree-ssa/vrp106.c: New test. Added: trunk/gcc/testsuite/gcc.dg/tree-ssa/vrp105.c trunk/gcc/testsuite/gcc.dg/tree-ssa/vrp106.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-threadedge.c trunk/gcc/tree-vrp.c