+2019-05-10 Martin Liska <mliska@suse.cz>
+
+ PR middle-end/90340
+ * doc/invoke.texi: New params.
+ * params.def (PARAM_JUMP_TABLE_MAX_GROWTH_RATIO_FOR_SIZE): New.
+ (PARAM_JUMP_TABLE_MAX_GROWTH_RATIO_FOR_SPEED): Likewise.
+ * tree-switch-conversion.c (jump_table_cluster::can_be_handled):
+ Use it.
+ * tree-switch-conversion.h (struct jump_table_cluster):
+ Likewise.
+
2019-05-09 Segher Boessenkool <segher@kernel.crashing.org>
* combine.c (combine_simplify_rtx): Don't make IF_THEN_ELSE RTL.
jump-table instead of a tree of conditional branches. If the value is
0, use the default for the machine.
+@item jump-table-max-growth-ratio-for-size
+The maximum code size growth ratio when expanding
+into a jump table (in percent). The parameter is used when
+optimizing for size.
+
+@item jump-table-max-growth-ratio-for-speed
+The maximum code size growth ratio when expanding
+into a jump table (in percent). The parameter is used when
+optimizing for speed.
+
@item tree-reassoc-width
Set the maximum number of instructions executed in parallel in
reassociated tree. This parameter overrides target dependent
"if 0, use the default for the machine.",
0, 0, 0)
+DEFPARAM (PARAM_JUMP_TABLE_MAX_GROWTH_RATIO_FOR_SIZE,
+ "jump-table-max-growth-ratio-for-size",
+ "The maximum code size growth ratio when expanding "
+ "into a jump table (in percent). The parameter is used when "
+ "optimizing for size.",
+ 300, 0, 0)
+
+DEFPARAM (PARAM_JUMP_TABLE_MAX_GROWTH_RATIO_FOR_SPEED,
+ "jump-table-max-growth-ratio-for-speed",
+ "The maximum code size growth ratio when expanding "
+ "into a jump table (in percent). The parameter is used when "
+ "optimizing for speed.",
+ 800, 0, 0)
+
/* Data race flags for C++0x memory model compliance. */
DEFPARAM (PARAM_ALLOW_STORE_DATA_RACES,
"allow-store-data-races",
+2019-05-10 Martin Liska <mliska@suse.cz>
+
+ PR middle-end/90340
+ * gcc.dg/tree-ssa/pr90340-2.c: New test.
+ * gcc.dg/tree-ssa/pr90340.c: New test.
+
2019-05-09 Cherry Zhang <cherryyz@google.com>
* go.dg/mapstring.go: New test.
--- /dev/null
+/* { dg-do compile { target { { x86_64-*-* aarch64-*-* ia64-*-* powerpc64-*-* } && lp64 } } } */
+/* { dg-options "-Os --param jump-table-max-growth-ratio-for-size=200 -fdump-tree-switchlower1" } */
+
+int a;
+
+int foo(char c) {
+ switch (c) {
+ case 'c':
+ return a;
+ case 's':
+ return 3;
+ case 'n':
+ return 1;
+ case '%':
+ return -2;
+ case 'o':
+ return a + 2;
+ break;
+ case 'X':
+ case 'x':
+ return 2222;
+ case 'd':
+ case 'i':
+ case 'u':
+ return 3333;
+ default:
+ return 0;
+ }
+}
+
+/* { dg-final { scan-tree-dump ";; GIMPLE switch case clusters: 37 88 99 100 105 110 111 115 117 120" "switchlower1" } } */
--- /dev/null
+/* { dg-do compile { target { { x86_64-*-* aarch64-*-* ia64-*-* powerpc64-*-* } && lp64 } } } */
+/* { dg-options "-Os -fdump-tree-switchlower1" } */
+
+int a;
+
+int foo(char c) {
+ switch (c) {
+ case 'c':
+ return a;
+ case 's':
+ return 3;
+ case 'n':
+ return 1;
+ case '%':
+ return -2;
+ case 'o':
+ return a + 2;
+ break;
+ case 'X':
+ case 'x':
+ return 2222;
+ case 'd':
+ case 'i':
+ case 'u':
+ return 3333;
+ default:
+ return 0;
+ }
+}
+
+/* { dg-final { scan-tree-dump ";; GIMPLE switch case clusters: 37 88 JT:99-120" "switchlower1" } } */
return true;
unsigned HOST_WIDE_INT max_ratio
- = optimize_insn_for_size_p () ? max_ratio_for_size : max_ratio_for_speed;
+ = (optimize_insn_for_size_p ()
+ ? PARAM_VALUE (PARAM_JUMP_TABLE_MAX_GROWTH_RATIO_FOR_SIZE)
+ : PARAM_VALUE (PARAM_JUMP_TABLE_MAX_GROWTH_RATIO_FOR_SPEED));
unsigned HOST_WIDE_INT range = get_range (clusters[start]->get_low (),
clusters[end]->get_high ());
/* Check overflow. */
comparison_count += sc->m_range_p ? 2 : 1;
}
- return range <= max_ratio * comparison_count;
+ return 100 * range <= max_ratio * comparison_count;
}
/* Return true if cluster starting at START and ending at END (inclusive)
return end - start + 1 >= case_values_threshold ();
}
-/* Definition of jump_table_cluster constants. */
-
-const unsigned HOST_WIDE_INT jump_table_cluster::max_ratio_for_size;
-const unsigned HOST_WIDE_INT jump_table_cluster::max_ratio_for_speed;
-
/* Find bit tests of given CLUSTERS, where all members of the vector
are of type simple_cluster. New clusters are returned. */
/* Return whether jump table expansion is allowed. */
static bool is_enabled (void);
-
- /* Max growth ratio for code that is optimized for size. */
- static const unsigned HOST_WIDE_INT max_ratio_for_size = 3;
-
- /* Max growth ratio for code that is optimized for speed. */
- static const unsigned HOST_WIDE_INT max_ratio_for_speed = 8;
};
/* A GIMPLE switch statement can be expanded to a short sequence of bit-wise