On 06/20/2018 05:16 PM, Jeff Law wrote:
> On 06/20/2018 05:25 AM, Steven Bosscher wrote:
>> On Tue, Jun 12, 2018 at 10:44 PM, Jeff Law wrote:
>>> On 06/05/2018 01:15 AM, marxin wrote:
>>>>
>>>> +     The definition of "much bigger" depends on whether we are
>>>> +     optimizing for size or for speed.  If the former, the maximum
>>>> +     ratio range/count = 3, because this was found to be the optimal
>>>> +     ratio for size on i686-pc-linux-gnu, see PR11823.  The ratio
>>>> +     10 is much older, and was probably selected after an extensive
>>>> +     benchmarking investigation on numerous platforms.  Or maybe it
>>>> +     just made sense to someone at some point in the history of GCC,
>>>> +     who knows...  */
>>> "much older" is an understatement.  I believe the magic "10" pre-dates
>>> my involvement in GCC.  You can find evidence of it as far back as
>>> gcc-0.9.  I doubt it was extensively benchmarked, and even if it was,
>>> the targets on which it was benchmarked don't reflect modern target
>>> reality in terms of importance.
>>
>> When I added this comment
>> (https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/stmt.c?r1=189284&r2=189285&;)
>> it as an attempt at humor. I should have turned the number into a
>> PARAM at the time. Maybe that's something Martin could still do now?
> A PARAM feels like overkill, but I certainly wouldn't object.    I'd be
> happy with that, a const member in the class or even the adjusted
> constant.
> 
> jeff
> 

Hi.

Agree with Jeff, there's a patch that does that.
Ready after it finishes tests?

Martin
>From 27d7c87720dc464b6ed998bc7344cf2226d5f9ea Mon Sep 17 00:00:00 2001
From: marxin <mli...@suse.cz>
Date: Fri, 22 Jun 2018 12:24:13 +0200
Subject: [PATCH] Come up with jump_table ratio constants used in
 jump_table_cluster.

gcc/ChangeLog:

2018-06-22  Martin Liska  <mli...@suse.cz>

	* tree-switch-conversion.c (jump_table_cluster::can_be_handled):
        Use newly introduced constants.
	* tree-switch-conversion.h (struct jump_table_cluster):
        Define max_ratio_for_size and max_ratio_for_speed.
---
 gcc/tree-switch-conversion.c | 3 ++-
 gcc/tree-switch-conversion.h | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index ddd8cba7b98..b79f2fdb6e6 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -1180,7 +1180,8 @@ jump_table_cluster::can_be_handled (const vec<cluster *> &clusters,
   if (start == end)
     return true;
 
-  unsigned HOST_WIDE_INT max_ratio = optimize_insn_for_size_p () ? 3 : 8;
+  unsigned HOST_WIDE_INT max_ratio
+    = optimize_insn_for_size_p () ? max_ratio_for_size : max_ratio_for_speed;
   unsigned HOST_WIDE_INT range = get_range (clusters[start]->get_low (),
 					    clusters[end]->get_high ());
   /* Check overflow.  */
diff --git a/gcc/tree-switch-conversion.h b/gcc/tree-switch-conversion.h
index 79a1320c448..4beac785f05 100644
--- a/gcc/tree-switch-conversion.h
+++ b/gcc/tree-switch-conversion.h
@@ -257,6 +257,12 @@ 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
-- 
2.17.1

Reply via email to