From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B251F38930C4; Tue, 12 Jan 2021 10:05:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B251F38930C4 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/95731] Failure to optimize a >= 0 && b >= 0 to (a | b) >= 0 Date: Tue, 12 Jan 2021 10:05:54 +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: 11.0 X-Bugzilla-Keywords: easyhack, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub 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 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: Tue, 12 Jan 2021 10:05:54 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95731 --- Comment #6 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:13d47c37a2c043f3e5981e73e4c82158a39f41e8 commit r11-6609-g13d47c37a2c043f3e5981e73e4c82158a39f41e8 Author: Jakub Jelinek Date: Tue Jan 12 11:03:40 2021 +0100 reassoc: Optimize in reassoc x < 0 && y < 0 to (x | y) < 0 etc. [PR9573= 1] We already had x !=3D 0 && y !=3D 0 to (x | y) !=3D 0 and x !=3D -1 && y !=3D -1 to (x & y) !=3D -1 and x < 32U && y < 32U to (x | y) < 32U, this patch adds signed x < 0 && y < 0 to (x | y) < 0. In that case, the low/high seem to be always the same and just in_p indices whether it is >=3D 0 or < 0, also, all types in the same bucket (same precision) should be type compatible, but we can have some >=3D 0 and some < 0 comparison mixed, so the patch handles that by using the right BIT_IOR_EXPR or BIT_AND_EX= PR and doing one set of < 0 or >=3D 0 first, then BIT_NOT_EXPR and then the other one. I had to move optimize_range_tests_var_bound before this optimiza= tion because that one deals with signed a >=3D 0 && a < b, and limited it to= the last reassoc pass as reassoc itself can't virtually undo this optimizat= ion yet (and not sure if vrp would be able to). 2021-01-12 Jakub Jelinek PR tree-optimization/95731 * tree-ssa-reassoc.c (optimize_range_tests_cmp_bitwise): Also optimize x < 0 && y < 0 && z < 0 into (x | y | z) < 0 for signed x, y, z. (optimize_range_tests): Call optimize_range_tests_cmp_bitwise only after optimize_range_tests_var_bound. * gcc.dg/tree-ssa/pr95731.c: New test. * gcc.c-torture/execute/pr95731.c: New test.=