The following patch reverted r173158 from google/main -- -fstrict-enums provides a better implementation. The test cases are kept with slight modification.
Bootstrap and tested with related test cases. Ok for google/main? 2011-05-06 David Li <davi...@google.com> Revert r173158. Index: tree-vrp.c =================================================================== --- tree-vrp.c (revision 173415) +++ tree-vrp.c (working copy) @@ -5553,9 +5553,7 @@ stmt_interesting_for_vrp (gimple stmt) && ((is_gimple_call (stmt) && gimple_call_fndecl (stmt) != NULL_TREE && DECL_IS_BUILTIN (gimple_call_fndecl (stmt))) - || !gimple_vuse (stmt)) - && (flag_strict_enum_precision - || TREE_CODE (TREE_TYPE (lhs)) != ENUMERAL_TYPE)) + || !gimple_vuse (stmt))) return true; } else if (gimple_code (stmt) == GIMPLE_COND Index: doc/invoke.texi =================================================================== --- doc/invoke.texi (revision 173415) +++ doc/invoke.texi (working copy) @@ -395,8 +395,8 @@ Objective-C and Objective-C++ Dialects}. -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops @gol -fsignaling-nans -fsingle-precision-constant -fsplit-ivs-in-unroller @gol -fsplit-wide-types -fstack-protector -fstack-protector-all @gol --fstrict-aliasing -fstrict-overflow -fno-strict-enum-precision -fthread-jumps --ftracer -ftree-bit-ccp @gol +-fstrict-aliasing -fstrict-overflow -fthread-jumps -ftracer @gol +-ftree-bit-ccp @gol -ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-copy-prop @gol -ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse @gol -ftree-forwprop -ftree-fre -ftree-loop-if-convert @gol @@ -2075,11 +2075,6 @@ represented in the minimum number of bit enumerators). This assumption may not be valid if the program uses a cast to convert an arbitrary integer value to the enumeration type. -@item -fno-strict-enum-precision -@opindex fno-strict-enum-precision -Do not perform optimizations of switch() statements based on the -precision of enum types. - @item -ftemplate-depth=@var{n} @opindex ftemplate-depth Set the maximum instantiation depth for template classes to @var{n}. Index: testsuite/g++.dg/other/no-strict-enum-precision-3.C =================================================================== --- testsuite/g++.dg/other/no-strict-enum-precision-3.C (revision 173415) +++ testsuite/g++.dg/other/no-strict-enum-precision-3.C (working copy) @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-O2 -fno-strict-enum-precision" } */ +/* { dg-options "-O2 -fno-strict-enums" } */ extern "C" void abort (void); Index: testsuite/g++.dg/other/no-strict-enum-precision-1.C =================================================================== --- testsuite/g++.dg/other/no-strict-enum-precision-1.C (revision 173415) +++ testsuite/g++.dg/other/no-strict-enum-precision-1.C (working copy) @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-fno-strict-enum-precision" } */ +/* { dg-options "-fno-strict-enums" } */ extern "C" void abort (void); Index: testsuite/g++.dg/other/no-strict-enum-precision-2.C =================================================================== --- testsuite/g++.dg/other/no-strict-enum-precision-2.C (revision 173415) +++ testsuite/g++.dg/other/no-strict-enum-precision-2.C (working copy) @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-O2 -fno-strict-enum-precision" } */ +/* { dg-options "-O2 -fno-strict-enums" } */ extern "C" void abort (void); Index: gimplify.c =================================================================== --- gimplify.c (revision 173415) +++ gimplify.c (working copy) @@ -1602,8 +1602,6 @@ gimplify_switch_expr (tree *expr_p, gimp type = TREE_TYPE (SWITCH_COND (switch_expr)); if (len && INTEGRAL_TYPE_P (type) - && (flag_strict_enum_precision - || TREE_CODE (type) != ENUMERAL_TYPE) && TYPE_MIN_VALUE (type) && TYPE_MAX_VALUE (type) && tree_int_cst_equal (CASE_LOW (VEC_index (tree, labels, 0)), -- This patch is available for review at http://codereview.appspot.com/4503041