public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "nathanael.schaeffer at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/114107] New: poor vectorization at -O3 when dealing with arrays of different multiplicity, good with -O2
Date: Sun, 25 Feb 2024 23:40:30 +0000	[thread overview]
Message-ID: <bug-114107-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 114107
           Summary: poor vectorization at -O3 when dealing with arrays of
                    different multiplicity, good with -O2
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nathanael.schaeffer at gmail dot com
  Target Milestone: ---

A simple loop multiplying two arrays, with different multiplicity fails to
vectorize efficiently with -O3.
Target is AVX x86_64.
The loop is the following, where 4 consecutive values in data are multiplied by
the same factor :

    for (int i=0; i<n; i++) {
     for (int k=0; k<4; k++) data[4*i+k] *= factor[i];
    }

See the very poor generated assembly with -O3 on godbolt, while 
the correct solution of a simple vbroadcastsd is generated by gcc 12.1+ with
-O2 

https://godbolt.org/z/fWj34bbhq

             reply	other threads:[~2024-02-25 23:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-25 23:40 nathanael.schaeffer at gmail dot com [this message]
2024-02-25 23:46 ` [Bug target/114107] " pinskia at gcc dot gnu.org
2024-02-25 23:56 ` pinskia at gcc dot gnu.org
2024-02-26  0:12 ` nathanael.schaeffer at gmail dot com
2024-02-26  0:13 ` nathanael.schaeffer at gmail dot com
2024-02-26  0:27 ` pinskia at gcc dot gnu.org
2024-02-26  0:34 ` nathanael.schaeffer at gmail dot com
2024-02-26  2:51 ` liuhongt at gcc dot gnu.org
2024-02-26  3:28 ` liuhongt at gcc dot gnu.org
2024-02-26  7:42 ` nathanael.schaeffer at gmail dot com
2024-02-26  7:49 ` nathanael.schaeffer at gmail dot com
2024-02-26  7:54 ` liuhongt at gcc dot gnu.org
2024-02-26  8:13 ` nathanael.schaeffer at gmail dot com
2024-02-26  9:10 ` [Bug tree-optimization/114107] " rguenth at gcc dot gnu.org
2024-02-26 14:40 ` rguenth at gcc dot gnu.org
2024-06-13  6:22 ` cvs-commit at gcc dot gnu.org
2024-06-13  7:13 ` 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-114107-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).