On 9/7/2021 3:42 AM, Martin Liška wrote:
On 9/6/21 14:16, Richard Biener wrote:
On Mon, Sep 6, 2021 at 1:46 PM Jakub Jelinek <ja...@redhat.com> wrote:
On Mon, Sep 06, 2021 at 01:37:46PM +0200, Martin Liška wrote:
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1323,6 +1323,14 @@ finish_options (struct gcc_options *opts,
struct gcc_options *opts_set,
= (opts->x_flag_unroll_loops
|| opts->x_flag_peel_loops
|| opts->x_optimize >= 3);
+
+ /* With -fcx-limited-range, we do cheap and quick complex
arithmetic. */
+ if (opts->x_flag_cx_limited_range)
+ flag_complex_method = 0;
+
+ /* With -fcx-fortran-rules, we do something in-between cheap and
C99. */
+ if (opts->x_flag_cx_fortran_rules)
+ flag_complex_method = 1;
That should then be opts->x_flag_complex_method instead of
flag_complex_method.
Ok with that change.
But the C/C++ langhooks also set flag_complex_method so I fail to see
how
this helps? As said I was referring to -fcx-limited-range on the
command-line
and -fno-cx-limited-range in the optimize node to undo this which should
get you the langhook setting of flag_complex_method = 2.
You are right, it's even more complicated as -fno-cx-limited-range is
target specific.
Option handling has been introducing surprises every time ...
The following tested patch should handle it.
Ready to be installed?
Thanks,
Martin
Note, I think we want to do much more in finish_options and less in
process_options, anything that is about Optimization options rather
than
just the global ones. Though one needs to be careful with the cases
where
the code diagnoses something.
Jakub
0001-flag_complex_method-support-optimize-attribute.patch
From e88ae14be7c5609a969897b5d09f40709fea8a34 Mon Sep 17 00:00:00 2001
From: Martin Liska <mli...@suse.cz>
Date: Fri, 3 Sep 2021 10:53:00 +0200
Subject: [PATCH] flag_complex_method: support optimize attribute
gcc/c-family/ChangeLog:
* c-opts.c (c_common_init_options_struct): Set also
x_flag_default_complex_method.
gcc/ChangeLog:
* common.opt: Add new variable flag_default_complex_method.
* opts.c (finish_options): Handle flags related to
x_flag_complex_method.
* toplev.c (process_options): Remove option handling related
to flag_complex_method.
gcc/go/ChangeLog:
* go-lang.c (go_langhook_init_options_struct): Set also
x_flag_default_complex_method.
gcc/lto/ChangeLog:
* lto-lang.c (lto_init_options_struct): Set also
x_flag_default_complex_method.
gcc/testsuite/ChangeLog:
* gcc.c-torture/compile/attr-complex-method-2.c: New test.
* gcc.c-torture/compile/attr-complex-method.c: New test.
OK
jeff