[Bug tree-optimization/93540] Attributes pure and const not working with aggregate return types, even trivial ones

2021-12-20 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93540

Andrew Pinski  changed:

   What|Removed |Added

 Resolution|--- |DUPLICATE
 Status|UNCONFIRMED |RESOLVED

--- Comment #3 from Andrew Pinski  ---
Dup of bug 59739.

*** This bug has been marked as a duplicate of bug 59739 ***

[Bug tree-optimization/93540] Attributes pure and const not working with aggregate return types, even trivial ones

2021-09-04 Thread trass3r at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93540

Trass3r  changed:

   What|Removed |Added

 CC||trass3r at gmail dot com

--- Comment #2 from Trass3r  ---
I also ran into this when trying to optimize trivial but expensive getter
functions, e.g. returning shared_ptr.

struct Foo
{
int operator+(const Foo& f);
int a;
};

[[gnu::const]]
Foo foo(); // int instead of Foo works

auto testfunction()
{
return foo() + foo(); // results in 2 calls
}

[Bug tree-optimization/93540] Attributes pure and const not working with aggregate return types, even trivial ones

2020-02-01 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93540

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||missed-optimization
  Component|c   |tree-optimization
   Severity|normal  |enhancement

--- Comment #1 from Andrew Pinski  ---
Yes this is expected.  GCC only currently handles non-aggregate pure/const
functions (vector and complex types work).