From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7F1833945C14; Tue, 24 Nov 2020 15:12:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F1833945C14 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/97960] [8/9/10/11 Regression] Wrong code at -O3 since r8-6511-g3ae129323d Date: Tue, 24 Nov 2020 15:12:31 +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: 11.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth 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: 8.5 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: Tue, 24 Nov 2020 15:12:31 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97960 --- Comment #3 from Richard Biener --- Creating dr for b[_7] base_address: &b offset from base address: (ssizetype) ((sizetype) (signed char) _5 = * 4) constant offset from base address: -1012 step: 4 base alignment: 32 base misalignment: 0 offset alignment: 4 step alignment: 4 base_object: b Access function 0: {(int) h_20, +, 1}_2 looks like the wrong sign for the constant offset. #0 split_constant_offset_1 (type=3D,=20 op0=3D, code=3DNOP_EXPR, op1=3D,=20 var=3D0x7fffffffba10, off=3D0x7fffffffba08, cache=3D..., limit=3D0x7fff= ffffc19c) now, var_min/max is UNSIGNED -3 / -1 (precision 8), woff is 3 we compute -3 + 3 =3D=3D 0 and overflow to true (UNSIGNED arithmetic) _5 =3D (unsigned char) _35; _6 =3D _5 + 3; h_20 =3D (signed char) _6; but then we continue with /* Calculate (ssizetype) OP0 - (ssizetype) TMP_VAR. */ widest_int diff =3D (widest_int::from (op0_min, sgn) - widest_int::from (var_min, sgn)); getting -253. I remember this place has changed quite some times and wide (sign-extended) vs. widest (signed) ints do not make it easier to see what's correct ... I'm defering to Richard here. The C testcase trips at this point just twice (ldist and vectorizer) so it's easy enough to 'catch' in a debugger.=