From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9FFB03858D28; Tue, 20 Feb 2024 22:04:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9FFB03858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708466673; bh=FgdPwpR4LocLZ8TbvAi4cyMBS4zuA8gCQaOEUbvbDmw=; h=From:To:Subject:Date:From; b=xWYJkYVj54FRAz8wqyaeqfsAg+n4TDZ48AF5RPJ6zv1xG21FCAyBFqeMVVYBbgBw2 7XHjDi9HySYdD+TiITfq7kBZNbTTGzw2QFqc+x40b+Ns9dN8E36mwIO+sTkrIVGHQV DleMDpXGPJu2K08W5wFpMKNiqdH4APGeCLRZu08I= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114025] New: Seeming missing frange based optimizations Date: Tue, 20 Feb 2024 22:04:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia 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 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=3D114025 Bug ID: 114025 Summary: Seeming missing frange based optimizations Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` #include #include #if 1 #define AINLINE #else #define AINLINE [[gnu::always_inline]] inline #endif class TestClass { public: AINLINE void SetValue(float value); private: float m_Value; }; AINLINE void TestClass::SetValue(float value) { if (value >=3D 0.0f && value <=3D 100.0f) { m_Value =3D value; } else { throw std::out_of_range("Value must be [0, 100]."); } } void TestFunc(TestClass& t, float value) { value =3D std::clamp(value, 30.0f, 50.0f); // When TestClass::SetValue is inlined, the exception throwing code is = not eliminated. // Given that at this point we can prove that 'value' lies in the range [30.0f, 50.0f] well within the range required by the setter function, we can rid the not taken paths of code. t.SetValue(value); } ``` at `-O3 -ffinite-math-only` when AINLINE is declared as nothing, TestFunc is not always to just the clamp, but if we define it to be `inline` with always_inline, then it is optimized to clamp. as far as I can tell the IR in VRP1 is not able to handle correctly put the frange in for some of the SSA_= NAME and so `value >=3D 0.0f && value <=3D 100.0f` is not optimized away.=