From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B663B385771C; Wed, 11 Oct 2023 14:00:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B663B385771C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697032844; bh=B0V1r37D5EeC2yHBxsUDaCC3ejgz3UicpYB1Q8QGpIs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=pkn80925uvtRzCdNlfe9ae5TEc1GPiQQMza6vOaA6DwM3pdfLCXS0DUpNgJ70j7q1 Q3MvRIZl1K4Ppsj1HJ/eEvdkQJ1h8O0f+mwGq0bQi92lte2bOCkUy3GbZVHt6NcKWF kW4gnQ7n14V0h8aSCzmFRXaNF0fLQIJUVOQwT79E= From: "amacleod at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111766] Missed optimization with __builtin_unreachable and ands Date: Wed, 11 Oct 2023 14:00: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: enhancement X-Bugzilla-Who: amacleod at redhat dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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=3D111766 --- Comment #1 from Andrew Macleod --- Imports: bb_3(D) Exports: _2 bb_3(D) _2 : bb_3(D)(I) bb_3(D) [irange] int [0, 3] MASK 0x3 VALUE 0x0 : _2 =3D bb_3(D) & 1; if (_2 =3D=3D 0) goto ; [INV] else goto ; [INV] _2 : [irange] int [0, 1] MASK 0x1 VALUE 0x0 4->5 (T) _2 : [irange] int [0, 0] MASK 0x1 VALUE 0x0 4->5 (T) bb_3(D) : [irange] int [0, 0][2, 2] MASK 0x2 VALUE 0x0 4->6 (F) _2 : [irange] int [1, 1] MASK 0x1 VALUE 0x0 4->6 (F) bb_3(D) : [irange] int [1, 3] MASK 0x2 VALUE 0x1 Looks like its just a lack of completeness in operator_bitwise_and::op1_range(). on the edge from 4->6 ranger knows _2 is [1,1], but when op1_range solves f= or _2 =3D bb_3 & 1 we have=20=20 [1,1] =3D int [0, 3] MASK 0x3 VALUE 0x0 & 1 and it produces int [1, 3] rather than [1,1][3,3]=