public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit 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: Mon, 10 Jul 2023 10:36:58 +0000	[thread overview]
Message-ID: <bug-110557-4-11qVgLyy7j@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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>:

https://gcc.gnu.org/g:1e6a948cd22f2f142cdc828296f78c7af9e283c8

commit r13-7553-g1e6a948cd22f2f142cdc828296f78c7af9e283c8
Author: Xi Ruoyao <xry111@xry111.site>
Date:   Thu Jul 6 23:08:57 2023 +0800

    vect: Fix vectorized BIT_FIELD_REF for signed bit-fields [PR110557]

    If a bit-field is signed and it's wider than the output type, we must
    ensure the extracted result sign-extended.  But this was not handled
    correctly.

    For example:

        int x : 8;
        long y : 55;
        bool z : 1;

    The vectorized extraction of y was:

        vect__ifc__49.29_110 =
          MEM <vector(2) long unsigned int> [(struct Item *)vectp_a.27_108];
        vect_patt_38.30_112 =
          vect__ifc__49.29_110 & { 9223372036854775552, 9223372036854775552 };
        vect_patt_39.31_113 = vect_patt_38.30_112 >> 8;
        vect_patt_40.32_114 =
          VIEW_CONVERT_EXPR<vector(2) long int>(vect_patt_39.31_113);

    This is obviously incorrect.  This pach has implemented it as:

        vect__ifc__25.16_62 =
          MEM <vector(2) long unsigned int> [(struct Item *)vectp_a.14_60];
        vect_patt_31.17_63 =
          VIEW_CONVERT_EXPR<vector(2) long int>(vect__ifc__25.16_62);
        vect_patt_32.18_64 = vect_patt_31.17_63 << 1;
        vect_patt_33.19_65 = vect_patt_32.18_64 >> 9;

    gcc/ChangeLog:

            PR tree-optimization/110557
            * tree-vect-patterns.cc (vect_recog_bitfield_ref_pattern):
            Ensure the output sign-extended if necessary.

    gcc/testsuite/ChangeLog:

            PR tree-optimization/110557
            * g++.dg/vect/pr110557.cc: New test.

    (cherry picked from commit 63ae6bc60c0f67fb2791991bf4b6e7e0a907d420)

  parent reply	other threads:[~2023-07-10 10:36 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 ` [Bug tree-optimization/110557] " pinskia at gcc dot gnu.org
2023-07-06  8:17 ` 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 [this message]
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-11qVgLyy7j@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).