Re: [PATCH][PR67476] Add param parloops-schedule

2015-09-14 Thread Tom de Vries

On 14/09/15 11:09, Jakub Jelinek wrote:

On Fri, Sep 11, 2015 at 03:28:01PM +0200, Tom de Vries wrote:

On 11/09/15 12:57, Jakub Jelinek wrote:

On Fri, Sep 11, 2015 at 12:55:00PM +0200, Tom de Vries wrote:

Hi,

this patch adds a param parloops-schedule=<0-4>, which sets the omp schedule
for loops paralellized by parloops.

The <0-4> maps onto .

Bootstrapped and reg-tested on x86_64.

OK for trunk?

I don't really like it, the mapping of the integers to the enum values
is non-obvious and hard to remember.
Perhaps add support for enumeration params if you want this instead?



This patch adds handling of a DEFPARAMENUM macro, which is similar to the
DEFPARAM macro, but allows the values to be named.

So the definition of param parloop-schedule becomes:
...
DEFPARAMENUM PARAM_PARLOOPS_SCHEDULE,
  "parloops-schedule",
  "Schedule type of omp schedule for loops parallelized by "
  "parloops (static, dynamic, guided, auto, runtime)",
  0, 0, 4, "static", "dynamic", "guided", "auto", "runtime")
...
[ I'll repost the original patch containing this update. ]

OK for trunk if x86_64 bootstrap and reg-test succeeds?


That still allows numeric arguments for the param, which is IMHO
undesirable.  If it is enum kind, only the enum values should be accepted.


Fixed.


Also, it would be nice if params.h in that case would define an enum with
the values like
PARAM_PARLOOPS_SCHEDULE_KIND_{static,dynamic,guided,auto,runtime}, so use
values not wrapped in ""s and only in a macro or generator make both
enums and string array out of that.


Done, there's now a file params-enum.h containing these enums.


There is also the question if we can use __VA_ARGS__, isn't that C99 or
C++11 and later feature?  I see gengtype.h and ipa-icf-gimple.h use
that too, so maybe yes, but am not sure.



I've removed the use of variadic macros, meaning we now use 
DEFPARAMENUM5 instead of DEFPARAMENUM.


Also, I've remove the min/max arguments in DEFPARAMENUM5.

And I've ensured that the default is now specified as a string rather 
than an integer.


So the new definition of PARAM_PARLOOPS_SCHEDULE looks like:

DEFPARAMENUM5 (PARAM_PARLOOPS_SCHEDULE,
  "parloops-schedule",
  "Schedule type of omp schedule for loops parallelized by "
  "parloops (static, dynamic, guided, auto, runtime)",
  static,
  static, dynamic, guided, auto, runtime)

[ Again, I'll repost the original patch containing this update. ]

This patch adds support for DEFPARAMENUM5.

OK for trunk, if bootstrap and reg-test on x86_64 succeeds?

Thanks,
- Tom

Support DEFPARAMENUM in params.def

2015-09-11  Tom de Vries  

	* Makefile.in (PARAMS_H, PLUGIN_HEADERS): Add params-enum.h.
	* params-enum.h: New file.
	* opts.c (handle_param): Handle case that param arg is a string.
	* params-list.h: Handle DEFPARAMENUM5 in params.def.
	* params.c (find_param): New function, factored out of ...
	(set_param_value): ... here.
	(param_string_value_p): New function.
	* params.h (struct param_info): Add value_names field.
	(find_param, param_string_value_p): Declare.
---
 gcc/Makefile.in   |  6 ++--
 gcc/opts.c| 19 +++
 gcc/params-enum.h | 39 ++
 gcc/params-list.h |  3 ++
 gcc/params.c  | 97 ++-
 gcc/params.h  |  6 
 6 files changed, 138 insertions(+), 32 deletions(-)
 create mode 100644 gcc/params-enum.h

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index b495bd2..b825785 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -890,7 +890,7 @@ RTL_BASE_H = coretypes.h rtl.h rtl.def $(MACHMODE_H) reg-notes.def \
 FIXED_VALUE_H = fixed-value.h $(MACHMODE_H) double-int.h
 RTL_H = $(RTL_BASE_H) $(FLAGS_H) genrtl.h
 READ_MD_H = $(OBSTACK_H) $(HASHTAB_H) read-md.h
-PARAMS_H = params.h params.def
+PARAMS_H = params.h params-enum.h params.def
 BUILTINS_DEF = builtins.def sync-builtins.def omp-builtins.def \
 	gtm-builtins.def sanitizer.def cilkplus.def cilk-builtins.def
 INTERNAL_FN_DEF = internal-fn.def
@@ -3254,8 +3254,8 @@ PLUGIN_HEADERS = $(TREE_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
   tree-iterator.h $(PLUGIN_H) $(TREE_SSA_H) langhooks.h incpath.h debug.h \
   $(EXCEPT_H) tree-ssa-sccvn.h real.h output.h $(IPA_UTILS_H) \
   $(C_PRAGMA_H)  $(CPPLIB_H)  $(FUNCTION_H) \
-  cppdefault.h flags.h $(MD5_H) params.def params.h prefix.h tree-inline.h \
-  $(GIMPLE_PRETTY_PRINT_H) realmpfr.h \
+  cppdefault.h flags.h $(MD5_H) params.def params.h params-enum.h \
+  prefix.h tree-inline.h $(GIMPLE_PRETTY_PRINT_H) realmpfr.h \
   $(IPA_PROP_H) $(TARGET_H) $(RTL_H) $(TM_P_H) $(CFGLOOP_H) $(EMIT_RTL_H) \
   version.h stringpool.h gimplify.h gimple-iterator.h gimple-ssa.h \
   fold-const.h tree-cfg.h tree-into-ssa.h tree-ssanames.h print-tree.h \
diff --git a/gcc/opts.c b/gcc/opts.c
index f1a9acd..3349aaf 100644
--- a/gcc/opts.c
+++ 

Re: [PATCH][PR67476] Add param parloops-schedule

2015-09-14 Thread Tom de Vries

On 14/09/15 16:28, Tom de Vries wrote:

On 14/09/15 11:09, Jakub Jelinek wrote:

On Fri, Sep 11, 2015 at 03:28:01PM +0200, Tom de Vries wrote:

On 11/09/15 12:57, Jakub Jelinek wrote:

On Fri, Sep 11, 2015 at 12:55:00PM +0200, Tom de Vries wrote:

Hi,

this patch adds a param parloops-schedule=<0-4>, which sets the
omp schedule
for loops paralellized by parloops.

The <0-4> maps onto .

Bootstrapped and reg-tested on x86_64.

OK for trunk?

I don't really like it, the mapping of the integers to the enum values
is non-obvious and hard to remember.
Perhaps add support for enumeration params if you want this instead?



This patch adds handling of a DEFPARAMENUM macro, which is similar to
the
DEFPARAM macro, but allows the values to be named.

So the definition of param parloop-schedule becomes:
...
DEFPARAMENUM PARAM_PARLOOPS_SCHEDULE,
  "parloops-schedule",
  "Schedule type of omp schedule for loops parallelized by "
  "parloops (static, dynamic, guided, auto, runtime)",
  0, 0, 4, "static", "dynamic", "guided", "auto", "runtime")
...
[ I'll repost the original patch containing this update. ]

OK for trunk if x86_64 bootstrap and reg-test succeeds?


That still allows numeric arguments for the param, which is IMHO
undesirable.  If it is enum kind, only the enum values should be
accepted.


Fixed.


Also, it would be nice if params.h in that case would define an enum with
the values like
PARAM_PARLOOPS_SCHEDULE_KIND_{static,dynamic,guided,auto,runtime}, so use
values not wrapped in ""s and only in a macro or generator make both
enums and string array out of that.


Done, there's now a file params-enum.h containing these enums.


There is also the question if we can use __VA_ARGS__, isn't that C99 or
C++11 and later feature?  I see gengtype.h and ipa-icf-gimple.h use
that too, so maybe yes, but am not sure.



I've removed the use of variadic macros, meaning we now use
DEFPARAMENUM5 instead of DEFPARAMENUM.

Also, I've remove the min/max arguments in DEFPARAMENUM5.

And I've ensured that the default is now specified as a string rather
than an integer.

So the new definition of PARAM_PARLOOPS_SCHEDULE looks like:

DEFPARAMENUM5 (PARAM_PARLOOPS_SCHEDULE,
   "parloops-schedule",
   "Schedule type of omp schedule for loops parallelized by "
   "parloops (static, dynamic, guided, auto, runtime)",
   static,
   static, dynamic, guided, auto, runtime)

[ Again, I'll repost the original patch containing this update. ]


This patch adds param parloops-schedule (and now uses the enum 
associated with the param).


OK for trunk, if bootstrap and reg-test on x86_64 succeeds?

Thanks,
- Tom

Add param parloops-schedule

2015-09-10  Tom de Vries  

	PR tree-optimization/67476
	* doc/invoke.texi (@item parloops-schedule): New item.
	* omp-low.c (expand_omp_for_generic): Handle simple latch.  Add missing
	phis.  Handle original loop.
	* params.def (PARAM_PARLOOPS_SCHEDULE): New DEFPARAMENUM5.
	* tree-parloops.c: Include params-enum.h.
	(create_parallel_loop): Handle PARAM_PARLOOPS_SCHEDULE.

	* testsuite/libgomp.c/autopar-3.c: New test.
	* testsuite/libgomp.c/autopar-4.c: New test.
	* testsuite/libgomp.c/autopar-5.c: New test.
	* testsuite/libgomp.c/autopar-6.c: New test.
	* testsuite/libgomp.c/autopar-7.c: New test.
	* testsuite/libgomp.c/autopar-8.c: New test.
---
 gcc/doc/invoke.texi |  4 +++
 gcc/omp-low.c   | 57 +++--
 gcc/params.def  | 12 +++
 gcc/tree-parloops.c | 26 ++-
 libgomp/testsuite/libgomp.c/autopar-3.c |  4 +++
 libgomp/testsuite/libgomp.c/autopar-4.c |  4 +++
 libgomp/testsuite/libgomp.c/autopar-5.c |  4 +++
 libgomp/testsuite/libgomp.c/autopar-6.c |  4 +++
 libgomp/testsuite/libgomp.c/autopar-7.c |  4 +++
 libgomp/testsuite/libgomp.c/autopar-8.c |  4 +++
 10 files changed, 119 insertions(+), 4 deletions(-)
 create mode 100644 libgomp/testsuite/libgomp.c/autopar-3.c
 create mode 100644 libgomp/testsuite/libgomp.c/autopar-4.c
 create mode 100644 libgomp/testsuite/libgomp.c/autopar-5.c
 create mode 100644 libgomp/testsuite/libgomp.c/autopar-6.c
 create mode 100644 libgomp/testsuite/libgomp.c/autopar-7.c
 create mode 100644 libgomp/testsuite/libgomp.c/autopar-8.c

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 76e5e29..2221795 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -11005,6 +11005,10 @@ automaton.  The default is 50.
 Chunk size of omp schedule for loops parallelized by parloops.  The default
 is 0.
 
+@item parloops-schedule
+Schedule type of omp schedule for loops parallelized by parloops (static,
+dynamic, guided, auto, runtime).  The default is static.
+
 @end table
 @end table
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 88a5149..4f0498b 100644
--- a/gcc/omp-low.c
+++ 

Re: [PATCH][PR67476] Add param parloops-schedule

2015-09-14 Thread Tom de Vries

On 14/09/15 10:52, Bernd Schmidt wrote:

I'm curious why
this would be a param rather than a -f option.


Hi Bernd,

parloops-chunk-size is also a param, so I think it would make sense to 
have parloops-schedule as a param as well.

[ So, in order for parloops to generate:
#pragma omp for schedule(dynamic,100)
  we specify on the command line:
--param parloops-schedule=dynamic --param parloops-chunk-size=100 ]

But in general, I don't really know how I should choose between:
* --param parm=, and
* -fparm=.

Thanks,
- Tom


Re: [PATCH][PR67476] Add param parloops-schedule

2015-09-14 Thread Jakub Jelinek
On Fri, Sep 11, 2015 at 03:28:01PM +0200, Tom de Vries wrote:
> On 11/09/15 12:57, Jakub Jelinek wrote:
> >On Fri, Sep 11, 2015 at 12:55:00PM +0200, Tom de Vries wrote:
> >>>Hi,
> >>>
> >>>this patch adds a param parloops-schedule=<0-4>, which sets the omp 
> >>>schedule
> >>>for loops paralellized by parloops.
> >>>
> >>>The <0-4> maps onto .
> >>>
> >>>Bootstrapped and reg-tested on x86_64.
> >>>
> >>>OK for trunk?
> >I don't really like it, the mapping of the integers to the enum values
> >is non-obvious and hard to remember.
> >Perhaps add support for enumeration params if you want this instead?
> >
> 
> This patch adds handling of a DEFPARAMENUM macro, which is similar to the
> DEFPARAM macro, but allows the values to be named.
> 
> So the definition of param parloop-schedule becomes:
> ...
> DEFPARAMENUM PARAM_PARLOOPS_SCHEDULE,
>  "parloops-schedule",
>  "Schedule type of omp schedule for loops parallelized by "
>  "parloops (static, dynamic, guided, auto, runtime)",
>  0, 0, 4, "static", "dynamic", "guided", "auto", "runtime")
> ...
> [ I'll repost the original patch containing this update. ]
> 
> OK for trunk if x86_64 bootstrap and reg-test succeeds?

That still allows numeric arguments for the param, which is IMHO
undesirable.  If it is enum kind, only the enum values should be accepted.
Also, it would be nice if params.h in that case would define an enum with
the values like
PARAM_PARLOOPS_SCHEDULE_KIND_{static,dynamic,guided,auto,runtime}, so use
values not wrapped in ""s and only in a macro or generator make both
enums and string array out of that.

There is also the question if we can use __VA_ARGS__, isn't that C99 or
C++11 and later feature?  I see gengtype.h and ipa-icf-gimple.h use
that too, so maybe yes, but am not sure.

Jakub


Re: [PATCH][PR67476] Add param parloops-schedule

2015-09-14 Thread Bernd Schmidt

On 09/11/2015 03:28 PM, Tom de Vries wrote:


This patch adds handling of a DEFPARAMENUM macro, which is similar to
the DEFPARAM macro, but allows the values to be named.

So the definition of param parloop-schedule becomes:
...
DEFPARAMENUM PARAM_PARLOOPS_SCHEDULE,
  "parloops-schedule",
  "Schedule type of omp schedule for loops parallelized by "
  "parloops (static, dynamic, guided, auto, runtime)",
  0, 0, 4, "static", "dynamic", "guided", "auto", "runtime")


So in principle I like this, but there's one oddity:

+  switch (schedule_type)
+{
+case 0:
+  OMP_CLAUSE_SCHEDULE_KIND (t) = OMP_CLAUSE_SCHEDULE_STATIC;
+  break;

The code using the param is using integers rather than enum values. Can 
that be fixed?



...
[ I'll repost the original patch containing this update. ]


I'll let Jakub and/or Richard handle the rest of that. I'm curious why 
this would be a param rather than a -f option.



Bernd


Re: [PATCH][PR67476] Add param parloops-schedule

2015-09-11 Thread Jakub Jelinek
On Fri, Sep 11, 2015 at 12:55:00PM +0200, Tom de Vries wrote:
> Hi,
> 
> this patch adds a param parloops-schedule=<0-4>, which sets the omp schedule
> for loops paralellized by parloops.
> 
> The <0-4> maps onto .
> 
> Bootstrapped and reg-tested on x86_64.
> 
> OK for trunk?

I don't really like it, the mapping of the integers to the enum values
is non-obvious and hard to remember.
Perhaps add support for enumeration params if you want this instead?

Jakub


Re: [PATCH][PR67476] Add param parloops-schedule

2015-09-11 Thread Tom de Vries

On 11/09/15 15:28, Tom de Vries wrote:

So the definition of param parloop-schedule becomes:
...
DEFPARAMENUM PARAM_PARLOOPS_SCHEDULE,
  "parloops-schedule",
  "Schedule type of omp schedule for loops parallelized by "
  "parloops (static, dynamic, guided, auto, runtime)",
  0, 0, 4, "static", "dynamic", "guided", "auto", "runtime")
...
[ I'll repost the original patch containing this update. ]



This is the patch adding param parloops-schedule, containing the update 
to use DEFPARAMENUM.


OK for trunk if x86_64 bootstrap and reg-test succeeds?

Thanks,
- Tom

Add param parloops-schedule

2015-09-10  Tom de Vries  

	PR tree-optimization/67476
	* doc/invoke.texi (@item parloops-schedule): New item.
	* omp-low.c (expand_omp_for_generic): Handle simple latch.  Add missing
	phis.  Handle original loop.
	* params.def (PARAM_PARLOOPS_SCHEDULE): New DEFPARAMENUM.
	* tree-parloops.c (create_parallel_loop): Handle
	PARAM_PARLOOPS_SCHEDULE.

	* testsuite/libgomp.c/autopar-3.c: New test.
	* testsuite/libgomp.c/autopar-4.c: New test.
	* testsuite/libgomp.c/autopar-5.c: New test.
	* testsuite/libgomp.c/autopar-6.c: New test.
	* testsuite/libgomp.c/autopar-7.c: New test.
	* testsuite/libgomp.c/autopar-8.c: New test.
---
 gcc/doc/invoke.texi |  4 +++
 gcc/omp-low.c   | 57 +++--
 gcc/params.def  |  6 
 gcc/tree-parloops.c | 24 +-
 libgomp/testsuite/libgomp.c/autopar-3.c |  4 +++
 libgomp/testsuite/libgomp.c/autopar-4.c |  4 +++
 libgomp/testsuite/libgomp.c/autopar-5.c |  4 +++
 libgomp/testsuite/libgomp.c/autopar-6.c |  4 +++
 libgomp/testsuite/libgomp.c/autopar-7.c |  4 +++
 libgomp/testsuite/libgomp.c/autopar-8.c |  4 +++
 10 files changed, 111 insertions(+), 4 deletions(-)
 create mode 100644 libgomp/testsuite/libgomp.c/autopar-3.c
 create mode 100644 libgomp/testsuite/libgomp.c/autopar-4.c
 create mode 100644 libgomp/testsuite/libgomp.c/autopar-5.c
 create mode 100644 libgomp/testsuite/libgomp.c/autopar-6.c
 create mode 100644 libgomp/testsuite/libgomp.c/autopar-7.c
 create mode 100644 libgomp/testsuite/libgomp.c/autopar-8.c

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 76e5e29..2221795 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -11005,6 +11005,10 @@ automaton.  The default is 50.
 Chunk size of omp schedule for loops parallelized by parloops.  The default
 is 0.
 
+@item parloops-schedule
+Schedule type of omp schedule for loops parallelized by parloops (static,
+dynamic, guided, auto, runtime).  The default is static.
+
 @end table
 @end table
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 88a5149..4f0498b 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -239,6 +239,7 @@ static vec taskreg_contexts;
 
 static void scan_omp (gimple_seq *, omp_context *);
 static tree scan_omp_1_op (tree *, int *, void *);
+static gphi *find_phi_with_arg_on_edge (tree, edge);
 
 #define WALK_SUBSTMTS  \
 case GIMPLE_BIND: \
@@ -6155,7 +6156,9 @@ expand_omp_for_generic (struct omp_region *region,
   if (!broken_loop)
 {
   l2_bb = create_empty_bb (cont_bb);
-  gcc_assert (BRANCH_EDGE (cont_bb)->dest == l1_bb);
+  gcc_assert (BRANCH_EDGE (cont_bb)->dest == l1_bb
+		  || (single_succ_edge (BRANCH_EDGE (cont_bb)->dest)->dest
+		  == l1_bb));
   gcc_assert (EDGE_COUNT (cont_bb->succs) == 2);
 }
   else
@@ -6429,8 +6432,12 @@ expand_omp_for_generic (struct omp_region *region,
   remove_edge (e);
 
   make_edge (cont_bb, l2_bb, EDGE_FALSE_VALUE);
-  add_bb_to_loop (l2_bb, cont_bb->loop_father);
   e = find_edge (cont_bb, l1_bb);
+  if (e == NULL)
+	{
+	  e = BRANCH_EDGE (cont_bb);
+	  gcc_assert (single_succ (e->dest) == l1_bb);
+	}
   if (gimple_omp_for_combined_p (fd->for_stmt))
 	{
 	  remove_edge (e);
@@ -6454,7 +6461,45 @@ expand_omp_for_generic (struct omp_region *region,
 	  e->flags = EDGE_FALLTHRU;
 	}
   make_edge (l2_bb, l0_bb, EDGE_TRUE_VALUE);
+}
+
+
+  if (gimple_in_ssa_p (cfun))
+{
+  gphi_iterator psi;
+
+  for (psi = gsi_start_phis (l3_bb); !gsi_end_p (psi); gsi_next ())
+	{
+	  source_location locus;
+	  gphi *nphi;
+	  gphi *exit_phi = psi.phi ();
+
+	  edge l2_to_l3 = find_edge (l2_bb, l3_bb);
+	  tree exit_res = PHI_ARG_DEF_FROM_EDGE (exit_phi, l2_to_l3);
 
+	  basic_block latch = BRANCH_EDGE (cont_bb)->dest;
+	  edge latch_to_l1 = find_edge (latch, l1_bb);
+	  gphi *inner_phi = find_phi_with_arg_on_edge (exit_res, latch_to_l1);
+
+	  tree t = gimple_phi_result (exit_phi);
+	  tree new_res = copy_ssa_name (t, NULL);
+	  nphi = create_phi_node (new_res, l0_bb);
+
+	  edge l0_to_l1 = find_edge (l0_bb, l1_bb);
+	  t = PHI_ARG_DEF_FROM_EDGE (inner_phi, l0_to_l1);
+	  locus = gimple_phi_arg_location_from_edge (inner_phi, l0_to_l1);
+	  edge entry_to_l0 = find_edge (entry_bb, l0_bb);
+	  add_phi_arg (nphi, t, 

Re: [PATCH][PR67476] Add param parloops-schedule

2015-09-11 Thread Tom de Vries

On 11/09/15 12:57, Jakub Jelinek wrote:

On Fri, Sep 11, 2015 at 12:55:00PM +0200, Tom de Vries wrote:

>Hi,
>
>this patch adds a param parloops-schedule=<0-4>, which sets the omp schedule
>for loops paralellized by parloops.
>
>The <0-4> maps onto .
>
>Bootstrapped and reg-tested on x86_64.
>
>OK for trunk?

I don't really like it, the mapping of the integers to the enum values
is non-obvious and hard to remember.
Perhaps add support for enumeration params if you want this instead?



This patch adds handling of a DEFPARAMENUM macro, which is similar to 
the DEFPARAM macro, but allows the values to be named.


So the definition of param parloop-schedule becomes:
...
DEFPARAMENUM PARAM_PARLOOPS_SCHEDULE,
 "parloops-schedule",
 "Schedule type of omp schedule for loops parallelized by "
 "parloops (static, dynamic, guided, auto, runtime)",
 0, 0, 4, "static", "dynamic", "guided", "auto", "runtime")
...
[ I'll repost the original patch containing this update. ]

OK for trunk if x86_64 bootstrap and reg-test succeeds?

Thanks,
- Tom

Support DEFPARAMENUM in params.def

2015-09-11  Tom de Vries  

	* opts.c (handle_param): Handle case that param arg is a string.
	* params-list.h: Handle DEFPARAMENUM in params.def.
	* params.c (find_param): New function, factored out of ...
	(set_param_value): ... here.
	(get_param_string_value): New function.
	* params.h (struct param_info): Add values field.
	(get_param_string_value): Declare.
---
 gcc/opts.c| 12 ---
 gcc/params-list.h |  3 ++
 gcc/params.c  | 93 +--
 gcc/params.h  |  5 +++
 4 files changed, 85 insertions(+), 28 deletions(-)

diff --git a/gcc/opts.c b/gcc/opts.c
index f1a9acd..47b8b86 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -2116,15 +2116,17 @@ handle_param (struct gcc_options *opts, struct gcc_options *opts_set,
 	  arg);
   else
 {
+  *equal = '\0';
+
   value = integral_argument (equal + 1);
   if (value == -1)
+	value = get_param_string_value (arg, equal + 1);
+
+  if (value == -1)
 	error_at (loc, "invalid --param value %qs", equal + 1);
   else
-	{
-	  *equal = '\0';
-	  set_param_value (arg, value,
-			   opts->x_param_values, opts_set->x_param_values);
-	}
+	set_param_value (arg, value,
+			 opts->x_param_values, opts_set->x_param_values);
 }
 
   free (arg);
diff --git a/gcc/params-list.h b/gcc/params-list.h
index ee33ef5..8a19919 100644
--- a/gcc/params-list.h
+++ b/gcc/params-list.h
@@ -19,5 +19,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #define DEFPARAM(enumerator, option, nocmsgid, default, min, max) \
   enumerator,
+#define DEFPARAMENUM(enumerator, option, nocmsgid, default, min, max, ...) \
+  enumerator,
 #include "params.def"
 #undef DEFPARAM
+#undef DEFPARAMENUM
diff --git a/gcc/params.c b/gcc/params.c
index b0bc80b..7eedab8 100644
--- a/gcc/params.c
+++ b/gcc/params.c
@@ -37,12 +37,22 @@ static size_t num_compiler_params;
default values determined.  */
 static bool params_finished;
 
+#define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX)
+#define DEFPARAMENUM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX, ...)	\
+  static const char *values_ ## ENUM [] = { __VA_ARGS__ };
+#include "params.def"
+#undef DEFPARAMENUM
+#undef DEFPARAM
+
 static const param_info lang_independent_params[] = {
 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX) \
-  { OPTION, DEFAULT, MIN, MAX, HELP },
+  { OPTION, DEFAULT, MIN, MAX, HELP, NULL },
+#define DEFPARAMENUM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX, ...)	\
+  { OPTION, DEFAULT, MIN, MAX, HELP, values_ ## ENUM },
 #include "params.def"
 #undef DEFPARAM
-  { NULL, 0, 0, 0, NULL }
+#undef DEFPARAMENUM
+  { NULL, 0, 0, 0, NULL, NULL }
 };
 
 /* Add the N PARAMS to the current list of compiler parameters.  */
@@ -114,6 +124,45 @@ set_param_value_internal (compiler_param num, int value,
 params_set[i] = true;
 }
 
+/* Return true if it can find the matching entry for NAME in the parameter
+   table, and assign the entry index to INDEX.  Return false otherwise.  */
+
+bool
+find_param (const char *name, size_t *index)
+{
+  for (size_t i = 0; i < num_compiler_params; ++i)
+if (strcmp (compiler_params[i].option, name) == 0)
+  {
+	*index = i;
+	return true;
+  }
+
+  return false;
+}
+
+/* Return the param value for param name VALUE_NAME belonging to param NAME.
+   Return -1 if there no corresponding param value.  */
+
+int
+get_param_string_value (const char *name, const char *value_name)
+{
+  size_t index;
+  if (!find_param (name, ))
+return -1;
+
+  param_info *entry = _params[index];
+  if (entry->value_names == NULL)
+return -1;
+
+  int n = entry->max_value - entry->min_value + 1;
+  int value = entry->min_value;
+  for (int i = 0; i < n ; ++i, ++value)
+if (strcmp (entry->value_names[i], value_name) == 0)
+  return value;
+
+  return -1;
+}