public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114025] New: Seeming missing frange based optimizations
@ 2024-02-20 22:04 pinskia at gcc dot gnu.org
0 siblings, 0 replies; only message in thread
From: pinskia at gcc dot gnu.org @ 2024-02-20 22:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114025
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 <algorithm>
#include <stdexcept>
#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 >= 0.0f && value <= 100.0f) {
m_Value = value;
}
else {
throw std::out_of_range("Value must be [0, 100].");
}
}
void TestFunc(TestClass& t, float value)
{
value = 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 >= 0.0f && value <= 100.0f` is not optimized away.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-02-20 22:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-20 22:04 [Bug tree-optimization/114025] New: Seeming missing frange based optimizations pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).