public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/114566] [11/12/13/14 Regression] Misaligned vmovaps when compiling with stack-protector-strong for znver4
Date: Thu, 04 Apr 2024 17:08:16 +0000	[thread overview]
Message-ID: <bug-114566-4-hAZngANRPZ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114566-4@http.gcc.gnu.org/bugzilla/>

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |avieira at gcc dot gnu.org
            Summary|[11/12/13 Regression]       |[11/12/13/14 Regression]
                   |Misaligned vmovaps when     |Misaligned vmovaps when
                   |compiling with              |compiling with
                   |stack-protector-strong for  |stack-protector-strong for
                   |znver4                      |znver4

--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Ah, it is the
10753         /* The vector size of the epilogue is smaller than that of the
main loop
10754            so the alignment is either the same or lower. This means the
dr will
10755            thus by definition be aligned.  */
10756         STMT_VINFO_DR_INFO (stmt_vinfo)->base_misaligned = false;
that clears base_misaligned, but somehow nothing forced the higher alignment on
the var before.
And the assumption is just wrong.
In the main loop it is using 512-bit vectors and we have base_alignment 16,
offset_alignment 32, so for V16SFmode accesses in the main vectorized loop as
the earlier one in the vectorized epilogue, so vect_compute_data_ref_alignment
in that
case gave up already earlier:
  if (drb->offset_alignment < vect_align_c
      || !step_preserves_misalignment_p
      /* We need to know whether the step wrt the vectorized loop is
         negative when computing the starting misalignment below.  */
      || TREE_CODE (drb->step) != INTEGER_CST)
    {
      if (dump_enabled_p ())
        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
                         "Unknown alignment for access: %T\n", ref);
      return;
    }
and just in the V8SFmode case in the epilogue, because vect_align_c is there 32
rather than 64, goes further and triggers
  if (base_alignment < vect_align_c)
    {
      unsigned int max_alignment;
      tree base = get_base_for_alignment (drb->base_address, &max_alignment);
      if (max_alignment < vect_align_c
          || !vect_can_force_dr_alignment_p (base,
                                             vect_align_c * BITS_PER_UNIT))
        {
          if (dump_enabled_p ())
            dump_printf_loc (MSG_NOTE, vect_location,
                             "can't force alignment of ref: %T\n", ref);
          return;
        }

      /* Force the alignment of the decl.
         NOTE: This is the only change to the code we make during
         the analysis phase, before deciding to vectorize the loop.  */
      if (dump_enabled_p ())
        dump_printf_loc (MSG_NOTE, vect_location,
                         "force alignment of %T\n", ref);

      dr_info->base_decl = base;
      dr_info->base_misaligned = true;
      base_misalignment = 0;
    }

So, if we don't want to force higher base alignment just because of some
accesses in vectorizable epilogue, I think we need to recompute the
alignment/misalignment there as well.
Marking for 14 as well because I believe the trunk commit just made it latent
there rather than fixed.

  parent reply	other threads:[~2024-04-04 17:08 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-02 18:19 [Bug c/114566] New: Misaligned vmovaps when compiling libvorbis " yshuiv7 at gmail dot com
2024-04-02 18:28 ` [Bug target/114566] " pinskia at gcc dot gnu.org
2024-04-02 19:33 ` yshuiv7 at gmail dot com
2024-04-02 20:15 ` yshuiv7 at gmail dot com
2024-04-02 20:22 ` yshuiv7 at gmail dot com
2024-04-02 20:28 ` yshuiv7 at gmail dot com
2024-04-02 20:37 ` pinskia at gcc dot gnu.org
2024-04-02 20:40 ` yshuiv7 at gmail dot com
2024-04-02 20:44 ` [Bug target/114566] Misaligned vmovaps when compiling with stack-protector-strong " pinskia at gcc dot gnu.org
2024-04-04 15:22 ` jakub at gcc dot gnu.org
2024-04-04 15:23 ` [Bug target/114566] [11/12/13 Regression] " jakub at gcc dot gnu.org
2024-04-04 15:40 ` jakub at gcc dot gnu.org
2024-04-04 15:46 ` jakub at gcc dot gnu.org
2024-04-04 16:33 ` jakub at gcc dot gnu.org
2024-04-04 16:57 ` jakub at gcc dot gnu.org
2024-04-04 17:08 ` jakub at gcc dot gnu.org [this message]
2024-04-04 17:14 ` [Bug target/114566] [11/12/13/14 " pinskia at gcc dot gnu.org
2024-04-05 10:30 ` [Bug tree-optimization/114566] " jakub at gcc dot gnu.org
2024-04-05 12:56 ` cvs-commit at gcc dot gnu.org
2024-04-05 12:57 ` [Bug tree-optimization/114566] [11/12/13 " jakub at gcc dot gnu.org
2024-04-21  4:08 ` cvs-commit at gcc dot gnu.org
2024-04-23  6:45 ` [Bug tree-optimization/114566] [11/12 " jakub 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-114566-4-hAZngANRPZ@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).