From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6EB21385840E; Sun, 20 Aug 2023 18:36:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6EB21385840E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692556583; bh=/90D4j876qeEP8y+qQ6pB2Rg1QtkOA4SrRUtpVbn3F4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=S6BJ0OWqJqalcY9H0zyevn0ULBMpkONzcPwlYEsLgmPspWDOI3pAkTa4kPV8eZ7Z9 694ApcSfnWif71yarUQDbcs9Us0k2FREtuVaZxYaEJya9DtkXaeprdNb0aChz/Wb+O 4xBlfHjulsPGRKjBo+r+w9LWgKaOcJ/budgHxl8I= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/110919] [14 Regression] Dead Code Elimination Regression at -O3 since r14-1691-gbc5a2c2e793 Date: Sun, 20 Aug 2023 18:36:23 +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: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal 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: bug_status assigned_to 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=3D110919 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot = gnu.org --- Comment #4 from Andrew Pinski --- After reassoc1 we have: _19 =3D _6 =3D=3D iftmp.1_8; _3 =3D iftmp.1_8 ^ 1; _21 =3D (_Bool) _3; _23 =3D _6 !=3D 0; _10 =3D _19 & _23; _5 =3D _10 & _21; Which is: (_6 !=3D 0) & (_6 =3D=3D iftmp.1_8) But since we know that iftmp.= 1_8 only has 2 values, we could optimize this to: (_6 =3D=3D 1) & (iftmp.1_8 =3D=3D = 1) Reduced testcase: ``` _Bool f(int a, int b) { b &=3D 1; _Bool t =3D a =3D=3D b; int c =3D b^1; _Bool d =3D c; _Bool e =3D a; _Bool g =3D t & d; _Bool h =3D g & e; return h; } ``` This should return false always. So something like: (simplify (bit_and:c (eq:c @0 @1) (ne:c @0 INTEGER_CST@2)) (if (has_two_value_range (@1)) (with { tree other_value =3D ...; } (bit_and (eq @0 { other_value; }) (eq @1 { other_value; })) ) ) )=