From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1E9003858C62; Wed, 26 Apr 2023 18:52:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E9003858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682535179; bh=VBqUMjSw6HQt3W3xtLdhPS7p4o683qK5QQlbMcFb5LA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xdQjHkG0yIpdRd3VP0NslukK4PhV1XXlTE5Skv1KLcbMwtd2vS0WV8w6OD2LYNESs MquabLeKkkeP0lZIZe3RQe/wzOiuVMU81yGSnSWSrl+dXtxr/exii+QdPVlgWBue6R ybtFYtfRuC85zy6w9OuikY0ZH7IMtnNkglrQRWXk= From: "amacleod at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109637] unnecessary range check in complete switch on bitfield Date: Wed, 26 Apr 2023 18:52:58 +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.1.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: amacleod at redhat dot com X-Bugzilla-Status: NEW 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: cc 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=3D109637 Andrew Macleod changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amacleod at redhat dot com --- Comment #2 from Andrew Macleod --- I think the bigger questions is why did switch conv change: 1 =3D s_5(D)->x; switch (_1) [INV], case 1: [INV], case 2: [INV], case 3: [INV]> : : goto ; [INV] : : goto ; [INV] : : : # _3 =3D PHI <0(2), 1(3), 2(4), 3(5)> : return _3; to=20 : _1 =3D s_5(D)->x; _6 =3D (unsigned char) _1; _2 =3D _6 + 255; if (_2 <=3D 2) goto ; [INV] else goto ; [INV] : : _10 =3D 0; goto ; [100.00%] : : _8 =3D (unsigned int) _1; _9 =3D (int) _1; _7 =3D _9; : # _3 =3D PHI <_10(3), _7(4)> : : return _3; Why are we adding -1 to [0,3] ? Thats the root of this issue I think? see= ms strange=