From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2C04D385842E; Fri, 30 Sep 2022 11:34:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2C04D385842E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664537688; bh=4M2aKrDIfCNrE6LR42h134hy2NWcTKeK1LPR2mD89nM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HKLzHyFian6hn+A/7Lt9s86ih+4ig+rqCOhV+cHYndIUbrp1LuMW/GkmC3aRrOh9v vtsGA2B45IjPPE4DSovAAgnlDnUo7nWFsKkQwCoT0WG/tGY9EXDcvGlolAbALS95no YTON2FG555OY8+3Kkn3RnKXe+vVxdtRdzac076EY= 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: Fri, 30 Sep 2022 11:34:47 +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 #3 from Krister Walfridsson --- A similar case is int r1, r2; int foo(int a, int s1, int s2) { if (a & (1 << s1)) return r1; if (a & (1 << s2)) return r1; return r2; } where reassoc2 optimizes this to always shift by s2.=