From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BF67C3830882; Tue, 28 Jun 2022 11:54:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BF67C3830882 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106112] [10/11/12/13 Regression] wrong code at -Os and above on x86_64-linux-gnu since r10-2711-g3ed01d5408045d80 Date: Tue, 28 Jun 2022 11:54:30 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to bug_status 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, 28 Jun 2022 11:54:30 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106112 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot = gnu.org Status|NEW |ASSIGNED --- Comment #3 from Richard Biener --- [local count: 1073741824]: e.0_1 =3D e; _2 =3D e.0_1 | 4294967292; e =3D _2; d.1_3 =3D d; _4 =3D (long unsigned int) d.1_3; - # RANGE [2147483647, 6442450942] NONZERO 8589934591 + # RANGE ~[2147483647, 18446744071562067967] _10 =3D _4 + 4294967295; _7 =3D _10 - _2; _8 =3D 18446744073709551615 % _7; _9 =3D (int) _8; c =3D _9; _11 =3D 18446744073709551614 - _2; - _13 =3D d.1_3 + -1; - # RANGE ~[2147483647, 18446744071562067967] - _14 =3D (long unsigned int) _13; - _15 =3D _11 % _14; + _15 =3D _11 % _10; is the key change, replacing (unsigned long)(intvar + -1) with (unsigned long)intvar + 4294967295 It looks like /* For constants simply extend it. */ if (TREE_CODE (op) =3D=3D INTEGER_CST) return wide_int_to_tree (wide_type, wi::to_wide (op)); doesn't sign-extend the -1 from int to unsigned log. Using wi::to_widest does and fixes the testcase.=