public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "krebbel at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/105175] New: [12 Regression] Pointless warning about missed vector optimization
Date: Wed, 06 Apr 2022 07:00:55 +0000	[thread overview]
Message-ID: <bug-105175-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 105175
           Summary: [12 Regression] Pointless warning about missed vector
                    optimization
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: krebbel at gcc dot gnu.org
  Target Milestone: ---

For this code snippet extracted from Qemu source:

enum { QEMU_MIGRATION_COOKIE_PERSISTENT = 1 };
struct {
  unsigned flags;
  unsigned flagsMandatory
} qemuMigrationCookieGetPersistent_mig;
qemuMigrationCookieGetPersistent() {
  qemuMigrationCookieGetPersistent_mig.flags &=
      QEMU_MIGRATION_COOKIE_PERSISTENT;
  qemuMigrationCookieGetPersistent_mig.flagsMandatory &=
      QEMU_MIGRATION_COOKIE_PERSISTENT;
}

cc1 -O3 -mno-sse t.c -Wvector-operation-performance

gives me:

t.c: In function ‘qemuMigrationCookieGetPersistent’:
t.c:7:46: warning: vector operation will be expanded with a single scalar
operation [-Wvector-operation-performance]
    7 |   qemuMigrationCookieGetPersistent_mig.flags &=

The generated code actually looks quite decent. Both integer AND operations are
merged into a 64 bit AND since
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=f31da42e047e8018ca6ad9809273bc7efb6ffcaf

This appears to be a nice optimization to me. However, in tree-vect-generic.cc
we then complain about this being implemented with just a scalar instruction.
Apart from this being pretty confusing for the programmer who never requested
anything to be vectorized I also don't see why it is a bad thing to implement a
vector operation with a scalar operation as long as it is able to cover the
entire vector with that.

With GCC 12 we have auto-vectorization enabled already with -O2, so I expect
this warning to surface much more frequently now. In particular on targets like
s390 where older distros still have to build everything without hardware vector
support this might be annoying. Also I'm not sure whether this warning ever
points at an actual problem. To me it looks like we should just drop it
altogether.

             reply	other threads:[~2022-04-06  7:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-06  7:00 krebbel at gcc dot gnu.org [this message]
2022-04-06  8:17 ` [Bug tree-optimization/105175] " rguenth at gcc dot gnu.org
2022-04-06  8:30 ` krebbel at gcc dot gnu.org
2022-04-06  8:49 ` rguenth at gcc dot gnu.org
2022-04-06  9:17 ` rguenth at gcc dot gnu.org
2022-04-08  6:34 ` cvs-commit at gcc dot gnu.org
2022-04-08  6:35 ` 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-105175-4@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).