public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/98925] New: Extend modref to handle return slot optimization
@ 2021-02-01 18:37 slyfox at gcc dot gnu.org
2021-02-01 19:11 ` [Bug tree-optimization/98925] " hubicka at ucw dot cz
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: slyfox at gcc dot gnu.org @ 2021-02-01 18:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98925
Bug ID: 98925
Summary: Extend modref to handle return slot optimization
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: hubicka at gcc dot gnu.org
Reporter: slyfox at gcc dot gnu.org
CC: rguenth at gcc dot gnu.org
Target Milestone: ---
Moving out https://gcc.gnu.org/PR98499#c9 to a separate enhancement PR:
Right now analyze_ssa_name_flags() does not perform detailed modref analysis of
return slot optimization and falls back to conservative assumption:
analyze_ssa_name_flags()
/* Return slot optiomization would require bit of propagation;
give up for now. */
if (gimple_call_return_slot_opt_p (call)
&& gimple_call_lhs (call) != NULL_TREE
&& TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (call))))
{
if (dump_file)
fprintf (dump_file, "%*s Unhandled return slot opt\n",
depth * 4, "");
lattice[index].merge (0);
}
I don't know what would be a good test for it.
If I don't overstimate modref and alias analysis destructor should disappear
completely in the example below (from https://gcc.gnu.org/PR98499#c4):
struct string {
char * _M_buf;
// local store
char _M_local_buf[16];
__attribute__((noinline)) string() : _M_buf(_M_local_buf) {}
~string() {
if (_M_buf != _M_local_buf)
__builtin_trap();
}
string(const string &__str); // no copies
};
// main.cc
__attribute__((noinline)) static string dir_name() { return string(); }
class Importer {
string base_path;
public:
__attribute__((noinline)) Importer() : base_path (dir_name()) {}
};
int main() {
Importer imp;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/98925] Extend modref to handle return slot optimization
2021-02-01 18:37 [Bug tree-optimization/98925] New: Extend modref to handle return slot optimization slyfox at gcc dot gnu.org
@ 2021-02-01 19:11 ` hubicka at ucw dot cz
2021-11-07 22:17 ` [Bug tree-optimization/98925] Extend ipa-prop to handle return functions for " hubicka at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: hubicka at ucw dot cz @ 2021-02-01 19:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98925
--- Comment #1 from Jan Hubicka <hubicka at ucw dot cz> ---
> If I don't overstimate modref and alias analysis destructor should disappear
> completely in the example below (from https://gcc.gnu.org/PR98499#c4):
>
> struct string {
> char * _M_buf;
> // local store
> char _M_local_buf[16];
>
> __attribute__((noinline)) string() : _M_buf(_M_local_buf) {}
>
> ~string() {
> if (_M_buf != _M_local_buf)
> __builtin_trap();
> }
>
> string(const string &__str); // no copies
> };
To see that _M_buf == _M_local_buf at the destruction time would require
tracking the aggregate alue from the inlinined constructor to destructor
which is something fitting to ipa-prop.
Modref can helip in case _M_buf is initialized to NULL. In that case
the address of return value would be non-escaping and we could optimize
the if condition to true (is we did incorrectly before).
I have WIP patch for this and will discuss with Martin Jambor the jump
functions for return values.
Thanks!
Honza
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/98925] Extend ipa-prop to handle return functions for slot optimization
2021-02-01 18:37 [Bug tree-optimization/98925] New: Extend modref to handle return slot optimization slyfox at gcc dot gnu.org
2021-02-01 19:11 ` [Bug tree-optimization/98925] " hubicka at ucw dot cz
@ 2021-11-07 22:17 ` hubicka at gcc dot gnu.org
2023-11-22 13:24 ` [Bug ipa/98925] " hubicka at gcc dot gnu.org
2024-09-21 0:34 ` sjames at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: hubicka at gcc dot gnu.org @ 2021-11-07 22:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98925
Jan Hubicka <hubicka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Extend modref to handle |Extend ipa-prop to handle
|return slot optimization |return functions for slot
| |optimization
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
CC| |mjambor at suse dot cz
Severity|normal |enhancement
Last reconfirmed| |2021-11-07
--- Comment #2 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Modref now handles return slots.
However as discussed in earlier comment we also need return function in
ipa-prop to propagate constant from callee to caller. So I am keeping the PR to
track this (I think it would be useful especially for offlined ctors)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug ipa/98925] Extend ipa-prop to handle return functions for slot optimization
2021-02-01 18:37 [Bug tree-optimization/98925] New: Extend modref to handle return slot optimization slyfox at gcc dot gnu.org
2021-02-01 19:11 ` [Bug tree-optimization/98925] " hubicka at ucw dot cz
2021-11-07 22:17 ` [Bug tree-optimization/98925] Extend ipa-prop to handle return functions for " hubicka at gcc dot gnu.org
@ 2023-11-22 13:24 ` hubicka at gcc dot gnu.org
2024-09-21 0:34 ` sjames at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: hubicka at gcc dot gnu.org @ 2023-11-22 13:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98925
--- Comment #3 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Return value range propagation was added in
r:53ba8d669550d3a1f809048428b97ca607f95cf5
however it works on scalar return values only for now. Extending it to
aggregates is a logical next step and should not be terribly hard.
The code also misses logic for IPA streaming so it works only in ealry and late
opts.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug ipa/98925] Extend ipa-prop to handle return functions for slot optimization
2021-02-01 18:37 [Bug tree-optimization/98925] New: Extend modref to handle return slot optimization slyfox at gcc dot gnu.org
` (2 preceding siblings ...)
2023-11-22 13:24 ` [Bug ipa/98925] " hubicka at gcc dot gnu.org
@ 2024-09-21 0:34 ` sjames at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-09-21 0:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98925
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-09-21 0:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-01 18:37 [Bug tree-optimization/98925] New: Extend modref to handle return slot optimization slyfox at gcc dot gnu.org
2021-02-01 19:11 ` [Bug tree-optimization/98925] " hubicka at ucw dot cz
2021-11-07 22:17 ` [Bug tree-optimization/98925] Extend ipa-prop to handle return functions for " hubicka at gcc dot gnu.org
2023-11-22 13:24 ` [Bug ipa/98925] " hubicka at gcc dot gnu.org
2024-09-21 0:34 ` sjames 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).