From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CCA673858404; Tue, 10 Jan 2023 17:32:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CCA673858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673371970; bh=6nWrQ8E2BVCHqndlKCDM/asj5L9E6v9+WmGxb+Cx1eQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=EHXhusthlc9+o9JiIJOvkhD4t83i+04Y0AcysMBh1ziOcYYBCAVK2j9xQSUZlDMTn XGsj6qT09++cQuOd1OKAwV7RwyIL+E9TYOCx+NE+d6ibxVahRgrvpZnYW44lj/15Sf 9OopENjkne1Is9an2g7kxSPX3b9xhk3RoytIP69I= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108360] [13 Regression] Dead Code Elimination Regression at -Os since r13-2048-g418b71c0d535bf Date: Tue, 10 Jan 2023 17:32:50 +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.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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: 13.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=3D108360 --- Comment #2 from Jakub Jelinek --- Seems it happens even with short b; static short c; unsigned char e; char f; void foo(); short(a)(short h, short i) { return h + i; } static short(d)(short h, int i) { return (h >=3D 32 || h > (7 >> i)) ? h : = h << i; } unsigned g(short h, short i) { return h + i; } int main() { short j, k =3D -1; c =3D a(0 >=3D b, k); f =3D c <=3D 0xD315BEF1; e =3D f << 4; j =3D d(e, 5); if (3 >=3D g(j =3D=3D b, k)) foo(); b =3D 32; } where we can't assume anything about b's value initially. Still in GCC 12 we decide to thread jump it based on whether e (h in inline= d d) is 0 or non-0 - h >=3D 32 is based on ranges clearly always false and as e = has [0, 16] range, h > 0 and h !=3D 0 are the same thing, if h !=3D 0, then d r= eturns h, otherwise h << 5. Later on we correctly figure out that if h =3D=3D 0, = then h << 5 is 0. But what I really don't understand how threadfull1 in that case decided that foo will not be called.=