public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/110557] [13/14 Regression] Wrong code for x86_64-linux-gnu with -O3 -mavx2: vectorized loop mishandles signed bit-fields
Date: Wed, 05 Jul 2023 13:15:26 +0000	[thread overview]
Message-ID: <bug-110557-4-D7nhb5x5M0@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110557-4@http.gcc.gnu.org/bugzilla/>

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Keywords|needs-bisection             |
   Last reconfirmed|                            |2023-07-05
     Ever confirmed|0                           |1
          Component|target                      |tree-optimization

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
ifcvt produces correctly the sign extend:

  <unnamed-signed:56> _ifc__18;


  _3 = a_14(D) + _2;
  _ifc__22 = _3->D.3439;
  _ifc__18 = BIT_FIELD_REF <_ifc__22, 56, 8>;
  _5 = (long long int) _ifc__18;
  _6 = _5 * -4;
  _7 = (long unsigned int) _6;
  _15 = MAX_EXPR <_7, size_19>;

But then the vectorizer misses that:
```
  _ifc__18 = BIT_FIELD_REF <_ifc__22, 56, 8>;
  vect_patt_13.20_76 = vect__ifc__22.19_74 & { 18446744073709551360,
18446744073709551360, 18446744073709551360, 18446744073709551360 };
  vect_patt_10.21_77 = vect_patt_13.20_76 >> 8;
  vect_patt_9.22_78 = VIEW_CONVERT_EXPR<vector(4) long long
int>(vect_patt_10.21_77);
  _5 = (long long int) _ifc__18;
  vect__6.23_80 = vect_patt_9.22_78 * { -4, -4, -4, -4 };
  _6 = _5 * -4;
```

vect_patt_9.22_78 should have been sign extended ...



With the C front-end, we get:
```
  <unnamed-signed:56> _24;
  <unnamed-signed:56> _23;

  _24 = _25->y;
  _23 = _24 * -4;
  _22 = (long unsigned int) _23;
```

Which the vectorizer does not understand could be prompted to 64bit and then
truncated so it does not vectorize it.


r13-3219-g25413fdb2ac24933214123e24ba16502 .

  parent reply	other threads:[~2023-07-05 13:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-05 11:10 [Bug target/110557] New: " xry111 at gcc dot gnu.org
2023-07-05 11:11 ` [Bug target/110557] [13/14 Regression] " xry111 at gcc dot gnu.org
2023-07-05 13:15 ` pinskia at gcc dot gnu.org [this message]
2023-07-06  8:17 ` [Bug tree-optimization/110557] " rguenth at gcc dot gnu.org
2023-07-06 10:17 ` avieira at gcc dot gnu.org
2023-07-06 10:21 ` xry111 at gcc dot gnu.org
2023-07-06 11:30 ` xry111 at gcc dot gnu.org
2023-07-06 14:58 ` avieira at gcc dot gnu.org
2023-07-06 16:18 ` xry111 at gcc dot gnu.org
2023-07-06 16:32 ` xry111 at gcc dot gnu.org
2023-07-10 10:36 ` cvs-commit at gcc dot gnu.org
2023-07-10 10:36 ` cvs-commit at gcc dot gnu.org
2023-07-10 10:38 ` xry111 at gcc dot gnu.org
2023-07-11  8:16 ` xry111 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-110557-4-D7nhb5x5M0@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).