From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0CBA33858418; Sun, 10 Oct 2021 09:18:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0CBA33858418 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102622] [9/10 Regression] Wrong code with -O1 and above due to phiopt and signed one bit integer types Date: Sun, 10 Oct 2021 09:18:51 +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: 12.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: pinskia at gcc dot gnu.org X-Bugzilla-Target-Milestone: 9.5 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 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: Sun, 10 Oct 2021 09:18:52 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102622 --- Comment #22 from Andrew Pinski --- Here is the simple patch which I will test for both GCC 10 and GCC 9. The question becomes does it make sense to make the same change to GCC 11 e= ven if it cannot be hit. diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 9ed26a3d45f..a6c197defea 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -770,9 +770,12 @@ conditional_replacement (basic_block cond_bb, basic_bl= ock middle_bb, if ((integer_zerop (arg0) && integer_onep (arg1)) || (integer_zerop (arg1) && integer_onep (arg0))) neg =3D false; + /* For signed one bit types, the negation is not needed and + should be avoided and is the same as 1 case for non-signed + one bit types. */ else if ((integer_zerop (arg0) && integer_all_onesp (arg1)) || (integer_zerop (arg1) && integer_all_onesp (arg0))) - neg =3D true; + neg =3D TYPE_PRECISION (TREE_TYPE (arg0)) !=3D 1; else return false;=