Add params for jump-table expansion params (PR middle-end/90340).
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-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. From-SVN: r271053
This commit is contained in:
parent
38613b9baa
commit
26f36b50ea
|
@ -1,3 +1,14 @@
|
|||
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.
|
||||
|
|
|
@ -11889,6 +11889,16 @@ The smallest number of different values for which it is best to use a
|
|||
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
|
||||
|
|
|
@ -1175,6 +1175,20 @@ DEFPARAM (PARAM_CASE_VALUES_THRESHOLD,
|
|||
"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",
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
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.
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/* { 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" } } */
|
|
@ -0,0 +1,31 @@
|
|||
/* { 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" } } */
|
|
@ -1268,7 +1268,9 @@ jump_table_cluster::can_be_handled (const vec<cluster *> &clusters,
|
|||
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. */
|
||||
|
@ -1282,7 +1284,7 @@ jump_table_cluster::can_be_handled (const vec<cluster *> &clusters,
|
|||
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)
|
||||
|
@ -1299,11 +1301,6 @@ jump_table_cluster::is_beneficial (const vec<cluster *> &,
|
|||
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. */
|
||||
|
||||
|
|
|
@ -269,12 +269,6 @@ struct jump_table_cluster: public group_cluster
|
|||
|
||||
/* 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
|
||||
|
|
Loading…
Reference in New Issue