public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-6924] tree-ssa-math-opts: Move PROP_gimple_opt_math from sincos pass to powcabs [PR109301]
@ 2023-03-29  6:37 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2023-03-29  6:37 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:8dd57939c20b5e218404a838f514429f8e414dea

commit r13-6924-g8dd57939c20b5e218404a838f514429f8e414dea
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Mar 29 08:33:30 2023 +0200

    tree-ssa-math-opts: Move PROP_gimple_opt_math from sincos pass to powcabs [PR109301]
    
    The following testcase ICEs since the sincos and vect pass order has
    been swapped.  It is not valid to replace vector sqrt (sqrt (x)) with
    pow (x, 0.25) because build_real on vector type is invalid (could be
    handled by using build_uniform_cst and adjusting type passed to
    build_real) but more importantly because nothing checks if we can
    actually do vector pow.
    While we have pow_optab, apparently no target defines it, so it doesn't
    seem to be worth bothering with for now and the patch just punts on
    non-scalar sqrts.
    I think the other simplifications next to it are fine, as they mostly
    use CBRT which doesn't even have internal function (so is a builtin
    only and therefore always scalar), or have already pow in the IL (which
    doesn't have optab and shouldn't be thus vector either).
    It is true that with <bits/math-vector.h> we do vectorize some calls to
    pow or cbrt (but don't handle others strangely), but those aren't using
    internal functions but simd clones and so match.pd doesn't know anything
    about those (at least for now).
    
    The following patch fixes it by mostly restoring the state before
    r13-1763 where canonicalize_math_p () was true only until the end of the
    pass which transformed pow or pow-like calls before vectorization (formerly
    sincos pass, now it is powcabs pass).
    powcabs is a pass in the spot sincos was happening before, so the
    only change was defer the sin+cos simplification into cexpi to a later
    new pass (except for the name moving with it) and none of the
    canonicalize_math_p () guarded simplification in match.pd seem to rely
    on those sin+cos -> cexpi simplifications and canonicalize_math_p is
    the only user of this property.
    
    2023-03-29  Jakub Jelinek  <jakub@redhat.com>
                Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/109301
            * tree-ssa-math-opts.cc (pass_data_cse_sincos): Change
            properties_provided from PROP_gimple_opt_math to 0.
            (pass_data_expand_powcabs): Change properties_provided from 0 to
            PROP_gimple_opt_math.
    
            * gcc.dg/pr109301.c: New test.

Diff:
---
 gcc/testsuite/gcc.dg/pr109301.c | 13 +++++++++++++
 gcc/tree-ssa-math-opts.cc       |  4 ++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/pr109301.c b/gcc/testsuite/gcc.dg/pr109301.c
new file mode 100644
index 00000000000..ab26ea6b6aa
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109301.c
@@ -0,0 +1,13 @@
+/* PR tree-optimization/109301 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -ffast-math" } */
+
+double x[256];
+
+void
+foo (void)
+{
+  for (int i = 0; i < 256; ++i)
+    for (int j = 0; j < 8; ++j)
+      x[i] = __builtin_pow (x[i], 0.5);
+}
diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc
index 26ed91d58fa..15eed3e960c 100644
--- a/gcc/tree-ssa-math-opts.cc
+++ b/gcc/tree-ssa-math-opts.cc
@@ -2237,7 +2237,7 @@ const pass_data pass_data_cse_sincos =
   OPTGROUP_NONE, /* optinfo_flags */
   TV_TREE_SINCOS, /* tv_id */
   PROP_ssa, /* properties_required */
-  PROP_gimple_opt_math, /* properties_provided */
+  0, /* properties_provided */
   0, /* properties_destroyed */
   0, /* todo_flags_start */
   TODO_update_ssa, /* todo_flags_finish */
@@ -2331,7 +2331,7 @@ const pass_data pass_data_expand_powcabs =
   OPTGROUP_NONE, /* optinfo_flags */
   TV_TREE_POWCABS, /* tv_id */
   PROP_ssa, /* properties_required */
-  0, /* properties_provided */
+  PROP_gimple_opt_math, /* properties_provided */
   0, /* properties_destroyed */
   0, /* todo_flags_start */
   TODO_update_ssa, /* todo_flags_finish */

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

only message in thread, other threads:[~2023-03-29  6:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-29  6:37 [gcc r13-6924] tree-ssa-math-opts: Move PROP_gimple_opt_math from sincos pass to powcabs [PR109301] Jakub Jelinek

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).