From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 075453858405; Sun, 10 Oct 2021 09:04:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 075453858405 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102622] [9/10/12 Regression] Wrong code with -O1 and above due to phiopt and signed one bit integer types Date: Sun, 10 Oct 2021 09:04:25 +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: 12.0 X-Bugzilla-Keywords: patch, 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: P1 X-Bugzilla-Assigned-To: pinskia at gcc dot gnu.org X-Bugzilla-Target-Milestone: 9.5 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: Sun, 10 Oct 2021 09:04:26 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102622 --- Comment #20 from CVS Commits --- The trunk branch has been updated by Andrew Pinski : https://gcc.gnu.org/g:882d806c1a8f9d2d2ade1133de88d63e5d4fe40c commit r12-4276-g882d806c1a8f9d2d2ade1133de88d63e5d4fe40c Author: Andrew Pinski Date: Sun Oct 10 01:28:59 2021 +0000 tree-optimization: [PR102622]: wrong code due to signed one bit integer= and "a?-1:0" So it turns out this is kinda of a latent bug but not really latent. In GCC 9 and 10, phi-opt would transform a?-1:0 (even for signed 1-bit integer) to -(type)a but the type is an one bit integer which means the negation= is undefined. GCC 11 fixed the problem by checking for a?pow2cst:0 transformation before a?-1:0 transformation. When I added the transformations to match.pd, I had swapped the order n= ot paying attention and I didn't expect anything of it. Because there was no test= case failing due to this. Anyways this fixes the problem on the trunk by swapping the order in match.pd and adding a comment of why the order is this way. I will try to come up with a patch for GCC 9 and 10 series later on whi= ch fixes the problem there too. Note I didn't include the original testcase which requires the vectoriz= er and AVX-512f as I can't figure out the right dg options to restrict it to avx-512f b= ut I did come up with a testcase which shows the problem and even more shows the problem with the 9/10 series as mentioned. OK? Bootstrapped and tested on x86_64-linux-gnu. PR tree-optimization/102622 gcc/ChangeLog: * match.pd: Swap the order of a?pow2cst:0 and a?-1:0 transformations. Swap the order of a?0:pow2cst and a?0:-1 transformations. gcc/testsuite/ChangeLog: * gcc.c-torture/execute/bitfld-10.c: New test.=