From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A626D385702B; Wed, 5 Jul 2023 13:15:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A626D385702B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688562926; bh=rckD1aNVdRmoUCQos625fMZbQ+XkvtN0AaAclhPX84c=; h=From:To:Subject:Date:In-Reply-To:References:From; b=l/7ub7Qm/2q9KR2P50/b6ysngw9lsV2lFvDGXNyssAQqp5p1NzmvDMOS0veyvzwcl FlJgvTvuFeV4KzmQeV3KxQw5C3b06ijQZYhJ9p5NLR+tEefKCDXxcuqH6Nw58UqyY8 vF2hpAi99zMdxy70phYBgPE0uaCxOqxsJNOVDtbQ= From: "pinskia 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: Wed, 05 Jul 2023 13:15:26 +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: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status keywords cf_reconfirmed_on everconfirmed component 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 Andrew Pinski 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 --- ifcvt produces correctly the sign extend: _ifc__18; _3 =3D a_14(D) + _2; _ifc__22 =3D _3->D.3439; _ifc__18 =3D BIT_FIELD_REF <_ifc__22, 56, 8>; _5 =3D (long long int) _ifc__18; _6 =3D _5 * -4; _7 =3D (long unsigned int) _6; _15 =3D MAX_EXPR <_7, size_19>; But then the vectorizer misses that: ``` _ifc__18 =3D BIT_FIELD_REF <_ifc__22, 56, 8>; vect_patt_13.20_76 =3D vect__ifc__22.19_74 & { 18446744073709551360, 18446744073709551360, 18446744073709551360, 18446744073709551360 }; vect_patt_10.21_77 =3D vect_patt_13.20_76 >> 8; vect_patt_9.22_78 =3D VIEW_CONVERT_EXPR(vect_patt_10.21_77); _5 =3D (long long int) _ifc__18; vect__6.23_80 =3D vect_patt_9.22_78 * { -4, -4, -4, -4 }; _6 =3D _5 * -4; ``` vect_patt_9.22_78 should have been sign extended ... With the C front-end, we get: ``` _24; _23; _24 =3D _25->y; _23 =3D _24 * -4; _22 =3D (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 .=