From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 50AC33858429; Mon, 30 Aug 2021 10:05:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 50AC33858429 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/102124] [11/12 Regression] -ftree-loop-vectorize Causing Data To Lose Sign Bit on AARCH64 Platform Date: Mon, 30 Aug 2021 10:05:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 11.2.1 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Aug 2021 10:05:57 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102124 --- Comment #5 from Jakub Jelinek --- I think the bug is in vect_recog_widen_op_pattern. When we have half_type unsigned, for PLUS_EXPR, MULT_EXPR (and supposedly LSHIFT_EXPR) it is ok that itype is twice the precision and same sign as half_type, say unsigned char uc1 =3D 0xfe, uc2 =3D 0xff; int t1 =3D uc1, t2 =3D uc2; t1 + t2 (or t1 * t2) wants to perform the widening operation and then zero-extend to the result type. But MINUS_EXPR seems to be special, t1 - t2 is negative despite half_type being unsigned (and, even if type is unsigned, such as for unsigned u1 =3D uc1, u2 =3D uc2; u1 - u2 wants sign-extension from unsigned short (aka itype) to unsigned int (aka t= ype) rather than zero-extension.=