From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1CC42384AB5B; Fri, 3 May 2024 14:21:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1CC42384AB5B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714746078; bh=3TEAVJEfuhbCjXg8EAxJOL5JETbE6XKYR/IrWfiCd9s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=YLIt8ZKRn7lxVTF8U34Yks/xQZo6FxQbQPpztjxbxUA9766wqxWY4bg3vi1WIjhCv BqO1M3mJt6A/A7iZo4fBSHCLLquVCGNtGr61PGwKMmnTgub8WxwlIHTEMzhXaLk+HJ lwhUMSBqZ8oEuMyyd679JE6pCskH4L1rl3+gpm2c= From: "mital at mitalashok dot co.uk" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114937] [11 regression] -ftree-vrp optimizes out range check before conditional increment Date: Fri, 03 May 2024 14:21:17 +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.4.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: mital at mitalashok dot co.uk 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.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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114937 --- Comment #3 from Mital Ashok --- My real code looks more like: void sat_inc(int& y) { if (y < __INT_MAX__) ++y; } template void f(int& x, F&&... functions) { int copy =3D x; (functions(copy), ...); if (copy > x) x =3D copy; } void g(int& x) { f(x, sat_inc); } ... Where `g(x)` became `++x` unconditionally=