From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E4F263858297; Thu, 8 Sep 2022 00:05:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E4F263858297 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662595538; bh=L5bsNI/q7eS0tys8CM+GVO31RTOkvmI/Q+cC4dxv9C4=; h=From:To:Subject:Date:From; b=EZLOld3sJN/UobWglrEYWEjYZZDW7UsmEBimY3jiSPljVgk22wkpNVu0fG/mtVhkm evcz5iYmcMLFjxElE24T7lGrIpClIdPjcl8JRf+LUXC4sAZQL9isiBsVOOftH0YFfP CkfQUtHMH0J10kgzBwJ6rtXnOuk+/1MOM7uVWXOw= From: "kristerw at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106883] New: SLSR may generate signed wrap Date: Thu, 08 Sep 2022 00:05:37 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new 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: kristerw at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D106883 Bug ID: 106883 Summary: SLSR may generate signed wrap Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: kristerw at gcc dot gnu.org Target Milestone: --- SLSR may generate new signed wrap for cases where the original did not wrap. This can be seen in the function f from gcc.dg/tree-ssa/slsr-19.c: int f (int c, int s) { int x1, x2, y1, y2; y1 =3D c + 2; x1 =3D s * y1; y2 =3D y1 + 2; x2 =3D s * y2; return x1 + x2; } SLSR optimizes this to int f (int c, int s) { int y1; int x2; int x1; int _7; int slsr_9; : y1_2 =3D c_1(D) + 2; x1_4 =3D y1_2 * s_3(D); slsr_9 =3D s_3(D) * 2; x2_6 =3D x1_4 + slsr_9; _7 =3D x1_4 + x2_6; return _7; Calling f(-3, 0x75181005) does not make any operation wrap in the original function, but slsr_9 overflow in the optimized code.=