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/111779] Fail to vectorize the struct include struct
Date: Thu, 12 Oct 2023 08:45:51 +0000	[thread overview]
Message-ID: <bug-111779-4-0gXy4Tvgtg@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111779-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |tree-optimization
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
                 CC|                            |jamborm at gcc dot gnu.org
   Last reconfirmed|                            |2023-10-12

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue is the aggregate copy:

t.c:26:22: missed:  not vectorized: more than one data ref in stmt: a = *_3;

which SRA fails to scalarize:

  <bb 3> [local count: 955630224]:
  # s_23 = PHI <s_18(3), 0(2)>
  # i_25 = PHI <i_20(3), 0(2)>
  _1 = (long unsigned int) i_25;
  _2 = _1 * 24;
  _3 = x_16(D) + _2;
  a = *_3;
  _4 = BIT_FIELD_REF <a.b4, 8, 64>;
  _12 = _4 & 1;
  _6 = (int) _12;
  s_18 = _6 + s_23;
  a ={v} {CLOBBER(eol)};
  i_20 = i_25 + 1;
  if (y_14(D) > i_20)

Candidate (2778): a
...
! Disqualifying a - No scalar replacements to be created.

the BIT_FIELD_REF is already created by early folding in
optimize_bit_field_compare folding (int) a.b4.f != 0

    s = ((int) NON_LVALUE_EXPR <BIT_FIELD_REF <a.b4, 8, 64>> & 1) + s;

SRA could handle BIT_FIELD_REFs just fine - esp. quantities with
a byte size.  And then this folding is just premature...

Removing the folding that handles BF != CST fixes it.  I know removing
all of it, esp. BF != BF will regress some stuff.  I'll put this half-way
patch through testing.

diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index 82299bb7f1d..3db383360d6 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -4695,7 +4695,7 @@ optimize_bit_field_compare (location_t loc, enum
tree_code code,
     return 0;

   if (const_p)
-    rreversep = lreversep;
+    return 0;
   else
    {
      /* If this is not a constant, we can only do something if bit positions,

  reply	other threads:[~2023-10-12  8:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12  7:31 [Bug c/111779] New: " juzhe.zhong at rivai dot ai
2023-10-12  8:45 ` rguenth at gcc dot gnu.org [this message]
2023-10-12  9:17 ` [Bug tree-optimization/111779] " rguenth at gcc dot gnu.org
2023-10-12 10:45 ` rguenth at gcc dot gnu.org
2023-10-13  6:34 ` cvs-commit at gcc dot gnu.org
2023-10-13  6:47 ` 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-111779-4-0gXy4Tvgtg@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).