From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 491C33888C47; Thu, 20 Jun 2024 07:50:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 491C33888C47 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1718869840; bh=deav8UG3k5Ybvb9WP+yj3vQEYmrLKJ+2q7YyMAhICMs=; h=From:To:Subject:Date:From; b=Mf9cNaTOACE6n4q51ezh4n8NiHgNGWhJ82kUcOfB8kF8zYpIUxj5YxDxoVDxlU/Qe 9bVAdzl958jBop1uZtQswwJqOAD7DKzVc+Yv0fO4dkSaBq6LzL2c7my6qMhiAyYd1y B37MMdZU2urR9U2RrkuhX8y6uEWzMOeWTarnB46s= From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/115555] New: [Ranger] deduce 'a >= 0' from 'b << a' Date: Thu, 20 Jun 2024 07:50:39 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 15.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter cc target_milestone Message-ID: 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=3D115555 Bug ID: 115555 Summary: [Ranger] deduce 'a >=3D 0' from 'b << a' Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: aldyh at gcc dot gnu.org Target Milestone: --- Stumbled over this when looking at PR 115551. C has for the bitwise shift operators: "If the value of the right operand is negative or is greater than or equal = to the width of the promoted left operand, the behavior is undefined." Thus, it seems as if the ranger should be able to deduce 'a >=3D 0' in the following, such that both conditions can be optimized away: int f (int a, float *b) { *b =3D a >=3D 0 ? 1.0 : 2.0; int mask1 =3D 1U << a; // 'a' must be >=3D 0 =E2=86=92 '*b=3D1.0' above= and 'return -1' below if (a >=3D 0) return -1; return mask1; }=