From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 167C93858D38; Sun, 6 Aug 2023 00:07:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 167C93858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691280458; bh=gLh1YLnQyd3+e9wxYwiY4ILT7DxFsnO2KunRHWZAagY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ipZIuyie5CswWQ+SM4S6p3QiSTut0tDAiW1Khiw3o6gHq4ilWf5YYgidT4HJoSwgB EfiMGT6WYpDw60N6xxC2T8GUcGyqerCWXNWV3Iv5XazqLohx+tpVs4QHC+nExqnwzK Q29UZCrlfK+rw+q1jQOLulPKPdJ6rMsEOAMoMWYw= From: "kristerw at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106884] ifcombine may move shift so it shifts more than bitwidth Date: Sun, 06 Aug 2023 00:07:37 +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: 13.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: kristerw 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: 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=3D106884 --- Comment #6 from Krister Walfridsson --- One more similar case (that may be the same as comment #3): int g; void foo(int a, int b, int c, int d, int e) { if ((10 + a) * b) { g =3D (c || (g >> d)) << 1; } } In this case, reassoc1 optimizes the IR for c || (g >> d) to do=20 (c | (g >> d)) !=3D 0 and we are now always doing the shift, even when c is true.=