public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ptk.prasertsuk at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/110035] Missed optimization for dependent assignment statements
Date: Wed, 31 May 2023 01:20:08 +0000 [thread overview]
Message-ID: <bug-110035-4-tP67zC3oXq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110035-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110035
--- Comment #4 from Pontakorn Prasertsuk <ptk.prasertsuk at gmail dot com> ---
(In reply to Richard Biener from comment #1)
> Ick - convoluted C++. We end up with
>
> void ff (struct MyClass & obj)
> {
> vector(2) long unsigned int vect_SR.16;
> vector(2) long unsigned int vect_SR.15;
> vector(2) long unsigned int vect_SR.14;
> void * _6;
>
> <bb 2> [local count: 1073741824]:
> vect_SR.14_5 = MEM <vector(2) long unsigned int> [(struct MyClass
> &)obj_2(D)];
> vect_SR.15_28 = MEM <vector(2) long unsigned int> [(struct MyClass
> &)obj_2(D) + 16];
> vect_SR.16_30 = MEM <vector(2) long unsigned int> [(struct MyClass
> &)obj_2(D) + 32];
> _6 = operator new (48);
> MEM <vector(2) long unsigned int> [(struct MyClass2 *)_6] = vect_SR.14_5;
> MEM <vector(2) long unsigned int> [(struct MyClass2 *)_6 + 16B] =
> vect_SR.15_28;
> MEM <vector(2) long unsigned int> [(struct MyClass2 *)_6 + 32B] =
> vect_SR.16_30;
> HandleMyClass2 (_6); [tail call]
>
> and the issue is that 'operator new (48)' can alter what 'obj' points to,
> so we cannot move the loads across the call and we get spilling.
>
> There is no inter-procedural analysis in GCC that would tell us that
> 'obj_2(D)' (the MyClass & obj argument of ff) does not point to an
> object that did not escape. In fact 'ff' has global visibility
> and it might have other callers.
>
> If you add -fwhole-program then you get the function inlined to main and
>
> main:
> .LFB652:
> .cfi_startproc
> subq $8, %rsp
> .cfi_def_cfa_offset 16
> movl $48, %edi
> call _Znwm
> movq $0, (%rax)
> movq %rax, %rdi
> movq $0, 8(%rax)
> movq $0, 16(%rax)
> movq $0, 24(%rax)
> movq $0, 32(%rax)
> movq $0, 40(%rax)
> call _Z14HandleMyClass2Pv
> xorl %eax, %eax
> addq $8, %rsp
> .cfi_def_cfa_offset 8
> ret
>
> (not using vectors because 'main' is considered cold). Do you cite an
> inline copy of ff() for clang?
Hi Richard,
The clang snippet I provided is not inlined into 'main' function.
next prev parent reply other threads:[~2023-05-31 1:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 8:35 [Bug tree-optimization/110035] New: " ptk.prasertsuk at gmail dot com
2023-05-30 11:55 ` [Bug tree-optimization/110035] " rguenth at gcc dot gnu.org
2023-05-30 16:45 ` pinskia at gcc dot gnu.org
2023-05-30 17:22 ` pinskia at gcc dot gnu.org
2023-05-31 1:20 ` ptk.prasertsuk at gmail dot com [this message]
2023-05-31 1:46 ` ptk.prasertsuk at gmail dot com
2023-05-31 6:34 ` rguenther at suse dot de
2023-06-03 0:23 ` ptk.prasertsuk at gmail dot com
2023-06-05 7:16 ` rguenth at gcc dot gnu.org
2023-06-05 7:58 ` ptk.prasertsuk at gmail dot com
2023-06-05 8:11 ` rguenther at suse dot de
2023-06-06 5:46 ` ptk.prasertsuk at gmail dot com
2023-06-06 5:49 ` ptk.prasertsuk at gmail dot com
2023-06-06 8:17 ` rguenther at suse dot de
2023-06-06 8:29 ` rguenth at gcc dot gnu.org
2023-06-06 9:12 ` amonakov at gcc dot gnu.org
2023-06-06 11:54 ` rguenther at suse dot de
2024-05-24 7:50 ` user202729 at protonmail dot com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-110035-4-tP67zC3oXq@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).