From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7F0613858428; Thu, 8 Sep 2022 00:20:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F0613858428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662596450; bh=YO+EnQ9EX276kPweQ8EBXo8QGX/UCisJk5EbvY3QNqk=; h=From:To:Subject:Date:From; b=qgDbV7139/2UsiNdldfHU1lgbIKGEJInSTUHxD+W1ziAP+Y4kH/mAWlTfR3pSprfs aWYr9fvZATxx141ARYhc4SsOqAIaVsItWUbOb7RL9AEOurb59WeDH8cHjTs+NvteCJ eiP/5nc4HAkcdyJrx/m15HRcnf92lDeA4nRcZEss= From: "kristerw at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106884] New: ifcombine may move shift so it shifts more than bitwidth Date: Thu, 08 Sep 2022 00:20:48 +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=3D106884 Bug ID: 106884 Summary: ifcombine may move shift so it shifts more than bitwidth 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: --- The function foo from gcc.dg/tree-ssa/ssa-ifcombine-1.c can be called as foo(1, 1, 33) without invoking undefined behavior int foo (int x, int a, int b) { int c =3D 1 << a; if (x & c) if (x & (1 << b)) return 2; return 0; } But ifcombine transforms this to int foo (int x, int a, int b) { int c; int _4; int _10; int _11; int _12; int _13; : _10 =3D 1 << b_8(D); _11 =3D 1 << a_5(D); _12 =3D _10 | _11; _13 =3D x_7(D) & _12; if (_12 =3D=3D _13) goto ; else goto ; : : # _4 =3D PHI <2(3), 0(2)> return _4; } and this will now calculate 1 << 33 unconditionally for _10.=