From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7BDCD3858D33; Sat, 27 May 2023 07:02:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7BDCD3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685170921; bh=tz7e+ZMwXJKr8khT+TSveYDwtRClnrjPwvw1Y6m0MQY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=FDyrW04rKwlnxdhGQlZFJYfzExVLQ5KVkjv+7OZjwq9+kqeoPd4GNLArjjZ3TSvqC AthopkqPzfJUVQt1RSx49TzOFvP/HHt+UCljxfMzgwLjt59/sQI1oy0tnDpqwDIOW0 slATU7zLgXa1+RRnNmc5YdLvLPq4ybjtSW3Kr37w= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/108847] [10/11/12/13/14 Regression] unnecessary bitwise AND on boolean types and shifting of the "sign" bit Date: Sat, 27 May 2023 07:02:01 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: deferred, missed-optimization X-Bugzilla-Severity: trivial X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: pinskia at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 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=3D108847 --- Comment #6 from Andrew Pinski --- Just for reference here are the functions I tried to see which way was the = best (set_bool0 and set_bool0_ produce the best for x86): void set_bool(bool& fl, __UINT32_TYPE__ value) { bool t =3D fl; __UINT32_TYPE__ t1 =3D value>>31; __UINT32_TYPE__ t2 =3D t; t =3D t2 | t1; fl =3D t; } void set_bool0(bool& fl, __UINT32_TYPE__ value) { bool t =3D fl; __UINT32_TYPE__ t1 =3D value>>31; bool t3 =3D t1; t =3D t | t3; fl =3D t; }=20=20 void set_bool0_(bool& fl, __INT32_TYPE__ value) { bool t =3D fl; __UINT32_TYPE__ t1 =3D value<0; bool t3 =3D t1; t =3D t | t3; fl =3D t; } void set_bool1(bool& fl, __UINT32_TYPE__ value) { fl |=3D value >> 31; }=