From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CE7313858425; Sat, 19 Aug 2023 13:59:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE7313858425 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692453584; bh=hUmKv4XszAOJPiPEYHAnfbtrt8gBUAvqqN6D2I/UjAw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GY9wx2nvJnQz4RjoTxniO/LRUdGVR9fg56JO3D9miWjNNaIS4QKVf7BPgD0J7B91A T1dHPxn0nmf9NQoG3FqRITJuXhq9+ppL3npZGng4W7VfbXLgTyBWcD2daJ+YJ6KaJO hTT7KuIxjDSeUb3XW7XmzPDAY1TartS2hFw+c6gs= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/110932] [14 Regression] Dead Code Elimination Regression since r14-2230-g7e904d6c7f2 Date: Sat, 19 Aug 2023 13:59:44 +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: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status everconfirmed cf_reconfirmed_on 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=3D110932 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2023-08-19 --- Comment #1 from Andrew Pinski --- _41 =3D _43 <=3D 0; # RANGE [irange] unsigned short [0, 1] NONZERO 0x1 _40 =3D (unsigned short) _41; # RANGE [irange] unsigned short [65534, +INF] _36 =3D ~_40; # RANGE [irange] short int [-2, -1] _19 =3D (short intD.17) _36; # RANGE [irange] unsigned int [4294967294, +INF] _17 =3D (unsigned intD.9) _19; // ~(unsigned)_41 // rather _41 ? 4294967294 : 4294967295 i.1_14 =3D (unsigned intD.9) pretmp_60; _13 =3D i.1_14 < _17; # RANGE [irange] int [0, 1] NONZERO 0x1 _12 =3D (intD.6) _13; if (_12 =3D=3D pretmp_60) pretmp_60 =3D=3D (((unsigned intD.9) pretmp_60) < _17) Which is: (pretmp_60 =3D=3D 1 && ((unsigned intD.9) pretmp_60) < _17)) | (pretmp_60 =3D=3D 0 && ((unsigned intD.9) pretmp_60) >=3D _17)) Though ((unsigned intD.9) pretmp_60) >=3D _17) is always false because _17's range does not include 0. So we are left with: (pretmp_60 =3D=3D 1 && 1 < _17) But _17's range is always bigger than 0 so we are just left with: pretmp_60 =3D=3D 1 So the general rule is: (simplify (eq:c @0 (convert (cmp @1 @2))) (if (bitwise_equal_p (@0, @1)) (with { bool zeroalwaystrue =3D ... bool zeroalwaysfalse =3D ... bool onealwaystrue =3D ... bool onealwaysfalse =3D ... } (switch (if (zeroalwaystrue && onealwaystrue) (le @0:unsigned { one(unsigned); } )) // @0 =3D=3D 0 | @0 =3D=3D 1 (if (zeroalwaysfalse && onealwaysfalse ) { false_bool; }) // false (if (zeroalwaystrue && onealwaysfalse) (eq @0 { zero(TREE_TYPE(@0)); })) // @0 =3D=3D 0 (if (onealwaystrue && onealwaysfalse) (eq @0 { one(TREE_TYPE(@0)); })) // @0 =3D=3D 1 Later on instead of `if (_12 =3D=3D _50)` we would have `if (_50 =3D=3D 1)` ``` if (_50 =3D=3D 1) goto ; [51.12%] else goto ; [48.88%] ... [local count: 278223726]: if (_50 !=3D 0) goto ; [33.00%] else goto ; [67.00%] ``` Which is an obvious case where we know _50 is 1 in bb 4 and therefore !=3D0. etc.=