From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6DF213857B98; Mon, 10 Jul 2023 10:36:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6DF213857B98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688985361; bh=gNeay1miLIEQSvRKDh8C/KuLCOGvYHllpa0YRv15TUI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OKxFI57S8nSsn/oLQi8O/kf0vbWuxwfg4pI8Cen6i2Kq2Y6noPuB/QLSPEhsGpxZJ +4MGn6YOLDVrRMj1figER4cOZ6iQsQJoiR7bFU5MdQGi6Yi3jti/Ry6ClGwYQJ+kiK nypfSHvZ7I+g6/cuhTm3s0ZN+DkOvWrZ8LTl6sKc= From: "cvs-commit at gcc dot 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:00 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: patch, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: xry111 at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110557 --- Comment #7 from CVS Commits --- The master branch has been updated by Xi Ruoyao : https://gcc.gnu.org/g:63ae6bc60c0f67fb2791991bf4b6e7e0a907d420 commit r14-2407-g63ae6bc60c0f67fb2791991bf4b6e7e0a907d420 Author: Xi Ruoyao 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 =3D MEM [(struct Item *)vectp_a.27_108]; vect_patt_38.30_112 =3D vect__ifc__49.29_110 & { 9223372036854775552, 9223372036854775552= }; vect_patt_39.31_113 =3D vect_patt_38.30_112 >> 8; vect_patt_40.32_114 =3D VIEW_CONVERT_EXPR(vect_patt_39.31_113); This is obviously incorrect. This pach has implemented it as: vect__ifc__25.16_62 =3D MEM [(struct Item *)vectp_a.14_60]; vect_patt_31.17_63 =3D VIEW_CONVERT_EXPR(vect__ifc__25.16_62); vect_patt_32.18_64 =3D vect_patt_31.17_63 << 1; vect_patt_33.19_65 =3D 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.=