From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8DF993858C30; Wed, 22 Nov 2023 14:40:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8DF993858C30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700664059; bh=TDBiO4rm3wNSA6U4BK0peBfZe0SYNnkxUMwnJn5je84=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NUUMU/7WR69qV/N/af+C2uO1nyA9l/4FMKR/dhJterUlFv01RkUhRsGuugn/FKj7w 1+Y2xG7JBu6JQ4WWPEbMYRdxt3bjkI8X3reDUOq5tOheCR3D+51efkjF50igSBQfET St6oVha6JkhSmzdcwhRNt35xWDApaQi+YWVbp31Y= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/112344] [14 Regression] Wrong code at -O2 on x86_64-pc-linux-gnu Date: Wed, 22 Nov 2023 14:40:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: 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: P1 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 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=3D112344 --- Comment #10 from CVS Commits --- The master branch has been updated by Richard Biener : https://gcc.gnu.org/g:6bf66276e3e41d5d92f7b7260e98b6a111653805 commit r14-5759-g6bf66276e3e41d5d92f7b7260e98b6a111653805 Author: Richard Biener Date: Wed Nov 22 11:10:41 2023 +0100 tree-optimization/112344 - wrong final value replacement When performing final value replacement chrec_apply that's used to compute the overall effect of niters to a CHREC doesn't consider that the overall increment of { -2147483648, +, 2 } doesn't fit in a signed integer when the loop iterates until the value of the IV of 20. The following fixes this mistake, carrying out the multiply and add in an unsigned type instead, avoiding undefined overflow and thus later miscompilation by path range analysis. PR tree-optimization/112344 * tree-chrec.cc (chrec_apply): Perform the overall increment calculation and increment in an unsigned type. * gcc.dg/torture/pr112344.c: New testcase.=