On Tue, Oct 26, 2021 at 5:11 PM Martin Liška <mli...@suse.cz> wrote:
>
> Hello.
>
> We should not allow a negative IntegerRange for UInteger options.
> The negative ranges for the 2 params are default and does not make sense.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?

OK.  (btw, can we use opts_set.param_... now instead of -1?)

Thanks,
Richard.

> Thanks,
> Martin
>
> gcc/ChangeLog:
>
>         * opt-functions.awk: Add new sanity checking.
>         * optc-gen.awk: Add new argument to integer_range_info.
>         * params.opt: Update 2 params which have negative IntegerRange.
> ---
>   gcc/opt-functions.awk | 4 +++-
>   gcc/optc-gen.awk      | 2 +-
>   gcc/params.opt        | 4 ++--
>   3 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk
> index be9255064d7..9bc85604066 100644
> --- a/gcc/opt-functions.awk
> +++ b/gcc/opt-functions.awk
> @@ -356,7 +356,7 @@ function search_var_name(name, opt_numbers, opts, flags, 
> n_opts)
>       return ""
>   }
>
> -function integer_range_info(range_option, init, option)
> +function integer_range_info(range_option, init, option, uinteger_used)
>   {
>       if (range_option != "") {
>         ival = init + 0;
> @@ -364,6 +364,8 @@ function integer_range_info(range_option, init, option)
>         end = nth_arg(1, range_option) + 0;
>         if (init != "" && init != "-1" && (ival < start || ival > end))
>           print "#error initial value " init " of '" option "' must be in 
> range [" start "," end "]"
> +       if (uinteger_used && start < 0)
> +         print "#error '" option"': negative IntegerRange (" start ", " end 
> ") cannot be combined with UInteger"
>         return start ", " end
>       }
>       else
> diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk
> index 77e598efd60..ebc1a02fa36 100644
> --- a/gcc/optc-gen.awk
> +++ b/gcc/optc-gen.awk
> @@ -422,7 +422,7 @@ for (i = 0; i < n_opts; i++) {
>                        cl_flags, cl_bit_fields)
>         printf("    %s, %s, %s }%s\n", var_ref(opts[i], flags[i]),
>                var_set(flags[i]), integer_range_info(opt_args("IntegerRange", 
> flags[i]),
> -                   opt_args("Init", flags[i]), opts[i]), comma)
> +                   opt_args("Init", flags[i]), opts[i], 
> flag_set_p("UInteger", flags[i])), comma)
>
>         # Bump up the informational option index.
>         ++optindex
> diff --git a/gcc/params.opt b/gcc/params.opt
> index 393d52bc660..1bad2b51df0 100644
> --- a/gcc/params.opt
> +++ b/gcc/params.opt
> @@ -398,7 +398,7 @@ Common Joined UInteger Var(param_lim_expensive) Init(20) 
> Param Optimization
>   The minimum cost of an expensive expression in the loop invariant motion.
>
>   -param=logical-op-non-short-circuit=
> -Common Joined UInteger Var(param_logical_op_non_short_circuit) Init(-1) 
> IntegerRange(-1, 1) Param
> +Common Joined UInteger Var(param_logical_op_non_short_circuit) Init(-1) 
> IntegerRange(0, 1) Param
>   True if a non-short-circuit operation is optimal.
>
>   -param=loop-block-tile-size=
> @@ -1128,7 +1128,7 @@ Common Joined UInteger Var(param_vect_epilogues_nomask) 
> Init(1) IntegerRange(0,
>   Enable loop epilogue vectorization using smaller vector size.
>
>   -param=vect-max-peeling-for-alignment=
> -Common Joined UInteger Var(param_vect_max_peeling_for_alignment) Init(-1) 
> IntegerRange(-1, 64) Param Optimization
> +Common Joined UInteger Var(param_vect_max_peeling_for_alignment) Init(-1) 
> IntegerRange(0, 64) Param Optimization
>   Maximum number of loop peels to enhance alignment of data references in a 
> loop.
>
>   -param=vect-max-version-for-alias-checks=
> --
> 2.33.1
>

Reply via email to