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 target/109964] auto-vectorization of shift ignores integral promotions
Date: Thu, 25 May 2023 11:15:42 +0000	[thread overview]
Message-ID: <bug-109964-4-v4JzmMNDTi@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109964-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-05-25
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |rguenth at gcc dot gnu.org,
                   |                            |rsandifo at gcc dot gnu.org

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
using V [[gnu::vector_size(16)]] = short;

V f(V s)
{
  return V{
    short(1) >> s[0],
    short(1) >> s[1],
    short(1) >> s[2],
    short(1) >> s[3],
    short(1) >> s[4],
    short(1) >> s[5],
    short(1) >> s[6],
    short(1) >> s[7]
    };
}

the frontend gives us

return <retval> = {(short int) (1 >> (int) VIEW_CONVERT_EXPR<short
int[8]>(s)[0]), (short int) (1 >> (int) VIEW_CONVERT_EXPR<short int[8]>(s)[1]),
(short int) (1 >> (int) VIEW_CONVERT_EXPR<short int[8]>(s)[2]), (short int) (1
>> (int) VIEW_CONVERT_EXPR<short int[8]>(s)[3]), (short int) (1 >> (int)
VIEW_CONVERT_EXPR<short int[8]>(s)[4]), (short int) (1 >> (int)
VIEW_CONVERT_EXPR<short int[8]>(s)[5]), (short int) (1 >> (int)
VIEW_CONVERT_EXPR<short int[8]>(s)[6]), (short int) (1 >> (int)
VIEW_CONVERT_EXPR<short int[8]>(s)[7])};

and the promotion/demotion stays until eventually basic-block vectorization
vectorizes this without doing the promotion.

t.ii:14:5: note:   vect_recog_over_widening_pattern: detected: _3 = 1 >> _2;
t.ii:14:5: note:   demoting int to signed short
t.ii:14:5: note:   created pattern stmt: patt_36 = 1 >> _1;

I don't think there's any way to query the target about whether vector
shifts "behave".

We end up with

V f (V s)
{
  vector(8) signed short vect_patt_36.3;

  <bb 2> [local count: 1073741824]:
  vect_patt_36.3_62 = { 1, 1, 1, 1, 1, 1, 1, 1 } >> s_33(D);
  return vect_patt_36.3_62;

  reply	other threads:[~2023-05-25 11:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-25 10:49 [Bug target/109964] New: " mkretz at gcc dot gnu.org
2023-05-25 11:15 ` rguenth at gcc dot gnu.org [this message]
2023-05-25 11:17 ` [Bug target/109964] " rguenth at gcc dot gnu.org
2023-05-25 11:45 ` rguenth at gcc dot gnu.org
2023-05-25 13:01 ` rsandifo at gcc dot gnu.org
2023-07-28 12:05 ` rguenth at gcc dot gnu.org
2024-04-15 13:28 ` rguenth at gcc dot gnu.org
2024-04-15 13:40 ` mkretz at gcc dot gnu.org
2024-04-15 13:42 ` 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-109964-4-v4JzmMNDTi@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).