From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D91BA3857C44; Wed, 4 Oct 2023 07:29:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D91BA3857C44 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696404597; bh=yR1Ym12hX9OhdcTZRlfkUINJkJqRjllhouCBh2xAkKA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BrbogcRcsG3kmFoYzL1a5SWNikjisl2P2fmwxNJAOZsccmvnsoIxdPAwWTeYi/6+D 1gI/oviKByN8AtiXkU/9prn+ZvfsjV7zIqkTpJkAuwf7C/aMDfQexFNl2omit9ISGb P+REDrcVm/L8VU6OfhypgcOkZB/ShML8EYVAiUo0= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111668] [12/13/14 Regression] vrp2 (match and simplify) introduces invalid wide signed Boolean values Date: Wed, 04 Oct 2023 07:29:56 +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: 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: jakub 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=3D111668 --- Comment #6 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:7ab01269396203d5200fff8579768da54dcfde5d commit r14-4391-g7ab01269396203d5200fff8579768da54dcfde5d Author: Jakub Jelinek Date: Wed Oct 4 09:27:40 2023 +0200 match.pd: Fix up a ? cst1 : cst2 regression on signed bool [PR111668] My relatively recent changes to these simplifiers to avoid doing build_nonstandard_integer_type (primarily for BITINT_TYPE) broke PR111668, a recurrence of the PR110487 bug. I thought the build_nonstandard_integer_type isn't ever needed there, but there is one special case where it is. For the a ? -1 : 0 and a ? 0 : -1 simplifications there are actually 3 different cases. One is for signed 1-bit precision types (signed kind of implied from integer_all_onesp, because otherwise it would match integer_onep earlier), where the simplifier wierdly was matching them using the a ? powerof2cst : 0 -> a << (log2(powerof2cst)) simplification and then another simplifier optimizing away the left shi= ft when log2(powerof2cst) was 0. Another one is signed BOOLEAN_TYPE with precision > 1, where indeed we shouldn't be doing the negation in type, because it isn't well defined in that type, the type only has 2 valid values, 0 and -1. As an alternative, we could also e.g. cast to signed 1-bit precision BOOLEAN_TYPE and then extend to type. And the last case is what we were doing for types which have both 1 and= -1 (all all ones) as valid values (i.e. all signed/unsigned ENUMERAL_TYPEs, INTEGRAL_TYPEs and BITINT_TYPEs with precision > 1). The following patch avoids the hops through << 0 for 1-bit precision and uses build_nonstandard_integer_type solely for the BOOLEAN_TYPE typ= es (where we have a guarantee the precision is reasonably small, nothing o= ught to be created 129+ bit precision BOOLEAN_TYPEs). 2023-10-04 Jakub Jelinek PR tree-optimization/111668 * match.pd (a ? CST1 : CST2): Handle the a ? -1 : 0 and a ? 0 : -1 cases before the powerof2cst cases and differentiate between 1-bit precision types, larger precision boolean types and other integral types. Fix comment pastos and formatting.=