Common Var(flag_jump_tables) Init(1) Optimization
Use jump tables for sufficiently large switch statements.
+fbit-tests
+Common Var(flag_bit_tests) Init(1) Optimization
+Use bit tests for sufficiently large switch statements.
+
fkeep-inline-functions
Common Report Var(flag_keep_inline_functions)
Generate code for functions even if they are fully inlined.
-fno-gnu-unique @gol
-finhibit-size-directive -fcommon -fno-ident @gol
-fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt @gol
--fno-jump-tables @gol
+-fno-jump-tables -fno-bit-tests @gol
-frecord-gcc-switches @gol
-freg-struct-return -fshort-enums -fshort-wchar @gol
-fverbose-asm -fpack-struct[=@var{n}] @gol
reference the address of a jump table. On some targets, jump tables
do not require a GOT and this option is not needed.
+@item -fno-bit-tests
+@opindex fno-bit-tests
+@opindex fbit-tests
+Do not use bit tests for switch statements even where it would be
+more efficient than other code generation strategies.
+
@item -ffixed-@var{reg}
@opindex ffixed
Treat the register named @var{reg} as a fixed register; generated code
--- /dev/null
+/* { dg-do compile { target { { x86_64-*-* aarch64-*-* ia64-*-* powerpc64-*-* } && lp64 } } } */
+/* { dg-options "-O2 -fno-bit-tests -fdump-tree-switchlower1" } */
+
+int global;
+
+int foo (int x)
+{
+ switch (x) {
+ case 0:
+ case 10:
+ return 1;
+ case 20:
+ case 30:
+ case 62:
+ return 2;
+ case 1000:
+ case 1010:
+ case 1025 ... 1030:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+/* { dg-final { scan-tree-dump-not "BT:" "switchlower1" } } */
vec<cluster *>
bit_test_cluster::find_bit_tests (vec<cluster *> &clusters)
{
+ if (!is_enabled ())
+ return clusters.copy ();
+
unsigned l = clusters.length ();
auto_vec<min_cluster_item> min;
min.reserve (l + 1);
basic_block case_bb,
profile_probability prob);
+ /* Return whether bit test expansion is allowed. */
+ static inline bool is_enabled (void)
+ {
+ return flag_bit_tests;
+ }
+
/* True when the jump table handles an entire switch statement. */
bool m_handles_entire_switch;