public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/complex-method-optimize-opt)] flag_complex_method: support optimize attribute
@ 2021-09-03  8:58 Martin Liska
  0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2021-09-03  8:58 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:787b85ed40997f1876174340e6b1c7c057ff1551

commit 787b85ed40997f1876174340e6b1c7c057ff1551
Author: Martin Liska <mliska@suse.cz>
Date:   Fri Sep 3 10:53:00 2021 +0200

    flag_complex_method: support optimize attribute
    
    gcc/ChangeLog:
    
            * opts.c (finish_options): Move flag_complex_method setting
            from ...
            * toplev.c (process_options): ... here.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.c-torture/compile/attr-complex-method.c: New test.

Diff:
---
 gcc/opts.c                                                |  8 ++++++++
 gcc/testsuite/gcc.c-torture/compile/attr-complex-method.c | 10 ++++++++++
 gcc/toplev.c                                              |  8 --------
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/gcc/opts.c b/gcc/opts.c
index e0501551ef5..2ac1a932f38 100644
--- 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;
 }
 
 #define LEFT_COLUMN	27
diff --git a/gcc/testsuite/gcc.c-torture/compile/attr-complex-method.c b/gcc/testsuite/gcc.c-torture/compile/attr-complex-method.c
new file mode 100644
index 00000000000..f08b72e273f
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/attr-complex-method.c
@@ -0,0 +1,10 @@
+/* { dg-additional-options "-fdump-tree-optimized" } */
+
+#pragma GCC optimize "-fcx-limited-range"
+
+void do_div (_Complex double *a, _Complex double *b)
+{
+  *a = *b / (4.0 - 5.0fi);
+}
+
+/* { dg-final { scan-tree-dump-not "__divdc3" "optimized" } } */
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 14d1335e79e..e1688aae724 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1695,14 +1695,6 @@ process_options (void)
       flag_stack_check = NO_STACK_CHECK;
     }
 
-  /* With -fcx-limited-range, we do cheap and quick complex arithmetic.  */
-  if (flag_cx_limited_range)
-    flag_complex_method = 0;
-
-  /* With -fcx-fortran-rules, we do something in-between cheap and C99.  */
-  if (flag_cx_fortran_rules)
-    flag_complex_method = 1;
-
   /* Targets must be able to place spill slots at lower addresses.  If the
      target already uses a soft frame pointer, the transition is trivial.  */
   if (!FRAME_GROWS_DOWNWARD && flag_stack_protect)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-03  8:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03  8:58 [gcc(refs/users/marxin/heads/complex-method-optimize-opt)] flag_complex_method: support optimize attribute Martin Liska

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).