public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/101925] [10/11/12 Regression] reversed storage order when compiling with -O3 only since r10-4742-g9b75f56d4b7951c6
Date: Mon, 16 Aug 2021 10:45:14 +0000	[thread overview]
Message-ID: <bug-101925-4-mrnx3DGJvP@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101925-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101925

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
So surprisingly the following is not enough to fix it.  We still get some
vectorizations but those are obviously not with reverse storage accesses.

Forcing be_net_addr to be -O0 works around the issue so it's vectorizing
of this function.  Likewise not inlining be_ip6_addr fixes it as well.

Disabling SRA fixes it also, and I think that SRA drops the rev storage order
access attribute.  Oddly enough for be_ip6_addr I see the rc.u.addr8[]
accesses do _not_ result in reverse_storage_order_for_component_p being true.
Why's that so?  How should I detect this is subject to re-ordering?

diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index d594c0a1b1e..9591d8b9d1a 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -4291,6 +4291,27 @@ vect_analyze_data_refs (vec_info *vinfo, poly_uint64
*min_vf, bool *fatal)
       stmt_info->dr_aux.dr = dr;
       stmt_info->dr_aux.stmt = stmt_info;

+      /* We cannot preserve reverse storage order accesses when
+         vectorizing.  */
+      if (reverse_storage_order_for_component_p (DR_REF (dr)))
+       {
+         if (dump_enabled_p ())
+           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                            "not vectorized: ref with reverse storage "
+                            "order in %G", stmt_info->stmt);
+         if (is_a <bb_vec_info> (vinfo))
+           {
+             /* In BB vectorization the ref can still participate
+                in dependence analysis, we just can't vectorize it.  */
+             STMT_VINFO_VECTORIZABLE (stmt_info) = false;
+             continue;
+           }
+         return opt_result::failure_at (stmt_info->stmt,
+                                        "not vectorized:"
+                                        " ref with reverse storage order: %G",
+                                        stmt_info->stmt);
+       }
+
       /* Check that analysis of the data-ref succeeded.  */
       if (!DR_BASE_ADDRESS (dr) || !DR_OFFSET (dr) || !DR_INIT 


I've used for debuggging

diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index d6e63d6e57f..ac5d760efeb 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -665,6 +665,9 @@ dump_gimple_assign (pretty_printer *buffer, const gassign
*gs, int spc,
        {
          dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags,
false);
          pp_space (buffer);
+
+         if (reverse_storage_order_for_component_p (gimple_assign_lhs (gs)))
+           pp_string (buffer, "{rev}");
          pp_equal (buffer);

          if (gimple_assign_nontemporal_move_p (gs))
@@ -673,6 +676,8 @@ dump_gimple_assign (pretty_printer *buffer, const gassign
*gs, int spc,
          if (gimple_has_volatile_ops (gs))
            pp_string (buffer, "{v}");

+         if (reverse_storage_order_for_component_p (gimple_assign_rhs1 (gs)))
+           pp_string (buffer, "{rev}");
          pp_space (buffer);
        }

  parent reply	other threads:[~2021-08-16 10:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-15 23:43 [Bug c/101925] New: reversed storage order when compiling with -O3 only george.thopas at gmail dot com
2021-08-15 23:50 ` [Bug tree-optimization/101925] " pinskia at gcc dot gnu.org
2021-08-16  8:08 ` [Bug tree-optimization/101925] [10/11/12 Regression] " marxin at gcc dot gnu.org
2021-08-16  8:22 ` [Bug tree-optimization/101925] [10/11/12 Regression] reversed storage order when compiling with -O3 only since r10-4742-g9b75f56d4b7951c6 rguenth at gcc dot gnu.org
2021-08-16  9:27 ` ebotcazou at gcc dot gnu.org
2021-08-16 10:45 ` rguenth at gcc dot gnu.org [this message]
2021-08-16 11:20 ` rguenth at gcc dot gnu.org
2021-08-16 12:20 ` ebotcazou at gcc dot gnu.org
2021-08-16 13:16 ` rguenther at suse dot de
2021-08-16 13:21 ` rguenth at gcc dot gnu.org
2021-08-17  7:25 ` cvs-commit at gcc dot gnu.org
2021-09-06  8:50 ` [Bug tree-optimization/101925] [10/11 " cvs-commit at gcc dot gnu.org
2021-10-13 11:09 ` [Bug tree-optimization/101925] [10 " cvs-commit at gcc dot gnu.org
2021-10-13 11:10 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-101925-4-mrnx3DGJvP@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).