diff mbox

Disable compact casesi patterns for arcv2

Message ID 20160929192616.GF18222@embecosm.com
State New
Headers show

Commit Message

Andrew Burgess Sept. 29, 2016, 7:26 p.m. UTC
* Claudiu Zissulescu <Claudiu.Zissulescu@synopsys.com> [2016-09-29 10:41:02 +0200]:

> Here it is.  The previous version had more mods which should be in a different patch.
> 
> Please let me know if you still have issues with it,
> Claudiu
> 
> gcc/
> 2016-05-09  Claudiu Zissulescu  <claziss@synopsys.com>
> 
> 	* common/config/arc/arc-common.c (arc_option_optimization_table):
> 	Remove compact casesi option.
> 	* config/arc/arc.c (arc_override_options): Use compact casesi
> 	option only for pre-ARCv2 cores.
> ---
>  gcc/common/config/arc/arc-common.c | 1 -
>  gcc/config/arc/arc.c               | 7 +++++++
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/gcc/common/config/arc/arc-common.c b/gcc/common/config/arc/arc-common.c
> index f5b9c6d..5b687fb 100644
> --- a/gcc/common/config/arc/arc-common.c
> +++ b/gcc/common/config/arc/arc-common.c
> @@ -56,7 +56,6 @@ static const struct default_options arc_option_optimization_table[] =
>      { OPT_LEVELS_ALL, OPT_mbbit_peephole, NULL, 1 },
>      { OPT_LEVELS_SIZE, OPT_mq_class, NULL, 1 },
>      { OPT_LEVELS_SIZE, OPT_mcase_vector_pcrel, NULL, 1 },
> -    { OPT_LEVELS_SIZE, OPT_mcompact_casesi, NULL, 1 },
>      { OPT_LEVELS_NONE, 0, NULL, 0 }
>    };
>  
> diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
> index 2b25b0b..825bccf 100644
> --- a/gcc/config/arc/arc.c
> +++ b/gcc/config/arc/arc.c
> @@ -858,6 +858,13 @@ arc_override_options (void)
>    if (arc_size_opt_level == 3)
>      optimize_size = 1;
>  
> +  /* Compact casesi is not a valid option for ARCv2 family, disable
> +     it.  */
> +  if (TARGET_V2)
> +    TARGET_COMPACT_CASESI = 0;
> +  else if (optimize_size == 1)
> +    TARGET_COMPACT_CASESI = 1;
> +
>    if (flag_pic)
>      target_flags |= MASK_NO_SDATA_SET;

I wonder if we should warn for the TARGET_V2 case?  Currently if the
option is supplied on an ARCv2 (-mcompact-casesi) then the option is
silently ignored.  This might confuse some users.

In the non TARGET_V2 case I notice that the option is _always_
enabled, with no option of disabling the option.  If we add a check of
global_options_set then we can make this smarter, default on, but can
still be tuned off if a user ever wants to.  The alternative would be
to entirely remove the TARGET_COMPACT_CASESI flag altogether?

While I was thinking about this I wrote the code below, it probably
needs polishing, but gives an idea of what I have in mind.  What do
you think?

Thanks,
Andrew

---

Comments

Claudiu Zissulescu Sept. 30, 2016, 8:35 a.m. UTC | #1
> I wonder if we should warn for the TARGET_V2 case?  Currently if the
> option is supplied on an ARCv2 (-mcompact-casesi) then the option is
> silently ignored.  This might confuse some users.

Good idea, I will update the docs accordingly.

> 
> In the non TARGET_V2 case I notice that the option is _always_
> enabled, with no option of disabling the option.  If we add a check of
> global_options_set then we can make this smarter, default on, but can
> still be tuned off if a user ever wants to.  The alternative would be
> to entirely remove the TARGET_COMPACT_CASESI flag altogether?

I would prefer to remove compact_casesi feature entirely as it is a trouble maker rather than a helper. 

> 
> While I was thinking about this I wrote the code below, it probably
> needs polishing, but gives an idea of what I have in mind.  What do
> you think?

It looks good, I will add the docs update. Coming back to u asap.
Claudiu
diff mbox

Patch

diff --git a/gcc/common/config/arc/arc-common.c b/gcc/common/config/arc/arc-common.c
index f5b9c6d..5b687fb 100644
--- a/gcc/common/config/arc/arc-common.c
+++ b/gcc/common/config/arc/arc-common.c
@@ -56,7 +56,6 @@  static const struct default_options arc_option_optimization_table[] =
     { OPT_LEVELS_ALL, OPT_mbbit_peephole, NULL, 1 },
     { OPT_LEVELS_SIZE, OPT_mq_class, NULL, 1 },
     { OPT_LEVELS_SIZE, OPT_mcase_vector_pcrel, NULL, 1 },
-    { OPT_LEVELS_SIZE, OPT_mcompact_casesi, NULL, 1 },
     { OPT_LEVELS_NONE, 0, NULL, 0 }
   };
 
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index 2b25b0b..65a5c10 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -858,6 +858,18 @@  arc_override_options (void)
   if (arc_size_opt_level == 3)
     optimize_size = 1;
 
+  /* Compact casesi is not a valid option for ARCv2 family.  */
+  if (TARGET_V2
+      && global_options_set.x_TARGET_COMPACT_CASESI
+      && global_options.x_TARGET_COMPACT_CASESI)
+    {
+      warning (0, "compact-casesi is not applicable to arc-v2");
+      TARGET_COMPACT_CASESI = 0;
+    }
+  else if (optimize_size == 1
+	   && !global_options_set.x_TARGET_COMPACT_CASESI)
+    TARGET_COMPACT_CASESI = 1;
+
   if (flag_pic)
     target_flags |= MASK_NO_SDATA_SET;