From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 535C33858D20; Fri, 11 Aug 2023 06:51:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 535C33858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691736711; bh=+fd1jqOpLydRv7WLJ0FEiXRmakV19R5+WPNEQa3jTRg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rUJkV/gU2ko7k0MvnW6qkV3bpfg1QlMkL+zRieQQ+XPoZWgVlFzdfCp0/rScJ/d2C EAcVOJgcymjTWVsPcHuOuzXDmZYXkJL9IyzooFU1xL3UJwqkMaF5qhVeOV6iN3Nvok Lr7Ff11krH8OGD5z6vYJFb0fM10AZsQKvIuJOuQc= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/110954] [14 Regression] Wrong code with -O0 Date: Fri, 11 Aug 2023 06:51:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: wrong-code 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: pinskia at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.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=3D110954 --- Comment #6 from CVS Commits --- The trunk branch has been updated by Andrew Pinski : https://gcc.gnu.org/g:f956c232649e4bb7482786cd54e5d5b4085cd00a commit r14-3140-gf956c232649e4bb7482786cd54e5d5b4085cd00a Author: Andrew Pinski Date: Wed Aug 9 13:49:24 2023 -0700 Fix PR 110954: wrong code with cmp | !cmp This was an oversight on my part forgetting that cmp will might have a different true value than all ones but will have a value of 1 in most cases. This means if we have `(f < 0) | !(f < 0)` we would optimize this to -1 rather than just 1. This is version 2 of the patch. Decided to go down a different route than just checking if the precission was 1 inside bitwise_inverted_equal_p. So instead bitwise_inverted_equal_p gets passed an argument that will be set if there was a comparison that was being compared and the user of bitwise_inverted_equal_p decides what needs to be done. In most uses of bitwise_inverted_equal_p, the check will be `!wascmp || element_precision (type) =3D=3D 1` . But in the case of `a & ~a` and `a ^| ~a` we can handle the case of wascmp by using constant_boolean_node isntead. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR tree-optimization/110954 gcc/ChangeLog: * generic-match-head.cc (bitwise_inverted_equal_p): Add wascmp argument and set it accordingly. * gimple-match-head.cc (bitwise_inverted_equal_p): Add wascmp argument to the macro. (gimple_bitwise_inverted_equal_p): Add wascmp argument and set it accordingly. * match.pd (`a & ~a`, `a ^| ~a`): Update call to bitwise_inverted_equal_p and handle wascmp case. (`(~x | y) & x`, `(~x | y) & x`, `a?~t:t`): Update call to bitwise_inverted_equal_p and check to see if was !wascmp or if precision was 1. gcc/testsuite/ChangeLog: * gcc.c-torture/execute/pr110954-1.c: New test.=