From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4EE2E3858014; Fri, 19 Nov 2021 07:48:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4EE2E3858014 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103325] 1 << -1 is never reduced to a constant during gimple Date: Fri, 19 Nov 2021 07:48:36 +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: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on everconfirmed 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: Fri, 19 Nov 2021 07:48:36 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103325 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2021-11-19 Ever confirmed|0 |1 --- Comment #2 from Richard Biener --- I think we used to constant fold this as 1<<1. GCC 7 does > gcc-7 -S t.c -fdump-tree-original t.c: In function 'main': t.c:2:12: warning: right shift count is negative [-Wshift-count-negative] return 1 >> (-1); ^~ > cat t.c.003t.original=20 ;; Function main (null) ;; enabled by -tree-original { return 2; } return 0; but IIRC that behavior was removed from {int_const,wide}_int_binop at some point, maybe also to enable sanitization. gimple-ssa-isolate-paths.c would be one place to turn such code into unreachable or traps (see other PRs to make the behavior configurable).=