From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5EB4A3858D39; Tue, 9 Apr 2024 20:49:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5EB4A3858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712695757; bh=imZT8kyhIbxRygAvNqqMwZMknjiZOwCumy2i/RDRkRA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xpSg6jxwcfhBrWJO6kzP4lo2CkDsBAStwEyahYpbEPOnJRqyepQxY/id2Vw5OORTC Xme6b6lpbZdweSXBBf4LlLSzkVms8Q9tiJ9uSTTvQagXfghZrd7E5DlHOn9z8jD8gq LfNuYTbfNty4byopBGofdBJG/kE/Ato9p5OK3A2w= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114666] [14 Regression] Signed single bit comparison miscompile at -O2 Date: Tue, 09 Apr 2024 20:49:17 +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: pinskia 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=3D114666 --- Comment #3 from Andrew Pinski --- With match.pd:7103 disable we get: Folding statement: _2 =3D (long unsigned int) _1; Global Exported: _2 =3D [irange] long unsigned int [0, 0][+INF, +INF] Not folded Folding statement: _3 =3D _2 ^ 1; Matching expression match.pd:2835, gimple-match-2.cc:35 Matching expression match.pd:2838, gimple-match-1.cc:66 Matching expression match.pd:2845, gimple-match-2.cc:96 Matching expression match.pd:2243, gimple-match-5.cc:20 Matching expression match.pd:2835, gimple-match-2.cc:35 Matching expression match.pd:2838, gimple-match-1.cc:66 Matching expression match.pd:2845, gimple-match-2.cc:96 Applying pattern match.pd:6795, gimple-match-4.cc:1721 Matching expression match.pd:2243, gimple-match-5.cc:20 Matching expression match.pd:2286, gimple-match-3.cc:23 Matching expression match.pd:2255, gimple-match-4.cc:67 Matching expression match.pd:2243, gimple-match-5.cc:20 Applying pattern match.pd:5898, gimple-match-7.cc:51777 gimple_simplified to _3 =3D _1 ? 18446744073709551614 : 1; Global Exported: _3 =3D [irange] long unsigned int [1, 1][18446744073709551= 614, 18446744073709551614] Folded into: _3 =3D _1 ? 18446744073709551614 : 1; But _1 here is an 1bit signed integer which I am 100% sure is really invalid gimple but we don't reject it. We don't check the operand 0 for COND_EXPR in verify_gimple_assign_ternary = at all .....=