public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/101995] New: regression built-in memset missed-optimization arm -Os
@ 2021-08-20 9:35 dumoulin.thibaut at gmail dot com
2021-08-20 12:21 ` [Bug middle-end/101995] " rguenth at gcc dot gnu.org
` (15 more replies)
0 siblings, 16 replies; 17+ messages in thread
From: dumoulin.thibaut at gmail dot com @ 2021-08-20 9:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101995
Bug ID: 101995
Summary: regression built-in memset missed-optimization arm -Os
Product: gcc
Version: 10.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: dumoulin.thibaut at gmail dot com
Target Milestone: ---
For cortex-m4 -Os, GCC10 produces bigger assembly code than GCC7 when memset is
called.
Here is the C code example to trigger the regression:
```C
#include <stdio.h>
#include <string.h>
struct foo_t {
int a;
int b;
int c;
int d;
};
/* Random function modifying foo with another value than 0 */
void doStuff(struct foo_t *foo) {
foo->b = foo->a + foo->c;
}
void twoLinesFunction(struct foo_t *foo) {
/* R0 is saved in GCC10 but not in GCC7 */
memset(foo, 0x00, sizeof(struct foo_t));
doStuff(foo);
}
int main(void) {
struct foo_t foo;
twoLinesFunction(&foo);
return 0;
}
```
compile command: `gcc -Os -mcpu=cortex-m4`
GCC7.3.1 produces:
```asm
<twoLinesFunction>:
push {r3, lr}
movs r2, #16
movs r1, #0
bl 8168 <memset>
ldmia.w sp!, {r3, lr}
b.w 8104 <doStuff>
```
While GCC10.3.0 produces:
```asm
<twoLinesFunction>:
push {r4, lr}
movs r2, #16
mov r4, r0 --> backup r0
movs r1, #0
bl 8174 <memset>
mov r0, r4 --> restore r0
ldmia.w sp!, {r4, lr}
b.w 810c <doStuff>
```
Main function remains the same.
The builtin memset function does not change R0 so there is no need to save it
and restore it later. GCC7 is more efficient.
GCC10 should not backup R0 for this builtin function in this case, it produces
slower code.
There is this PR https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61241 which is
also referring to this behavior with a patch to implement the optimization but
I'm not sure when this optimization has been wiped out.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug middle-end/101995] regression built-in memset missed-optimization arm -Os
2021-08-20 9:35 [Bug c/101995] New: regression built-in memset missed-optimization arm -Os dumoulin.thibaut at gmail dot com
@ 2021-08-20 12:21 ` rguenth at gcc dot gnu.org
2021-08-20 21:45 ` [Bug rtl-optimization/101995] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
` (14 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-08-20 12:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101995
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c |middle-end
Keywords| |needs-bisection, ra
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The RA used to know how to rematerialize a register from the memset return
value.
Sth made that no longer work it seems.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug rtl-optimization/101995] [9/10/11/12 Regression] regression built-in memset missed-optimization arm -Os
2021-08-20 9:35 [Bug c/101995] New: regression built-in memset missed-optimization arm -Os dumoulin.thibaut at gmail dot com
2021-08-20 12:21 ` [Bug middle-end/101995] " rguenth at gcc dot gnu.org
@ 2021-08-20 21:45 ` pinskia at gcc dot gnu.org
2021-08-21 2:53 ` pinskia at gcc dot gnu.org
` (13 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-20 21:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101995
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |8.2.0
Known to fail| |9.1.0
Target Milestone|--- |9.5
Summary|regression built-in memset |[9/10/11/12 Regression]
|missed-optimization arm -Os |regression built-in memset
| |missed-optimization arm -Os
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug rtl-optimization/101995] [9/10/11/12 Regression] regression built-in memset missed-optimization arm -Os
2021-08-20 9:35 [Bug c/101995] New: regression built-in memset missed-optimization arm -Os dumoulin.thibaut at gmail dot com
2021-08-20 12:21 ` [Bug middle-end/101995] " rguenth at gcc dot gnu.org
2021-08-20 21:45 ` [Bug rtl-optimization/101995] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
@ 2021-08-21 2:53 ` pinskia at gcc dot gnu.org
2021-08-21 3:17 ` pinskia at gcc dot gnu.org
` (12 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-21 2:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101995
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-08-21
Target|arm |arm, aarch64
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
On x86_64 for some reason it works in GCC 9+; tested with " -Os
-mstringop-strategy=libcall" and adding noinline to doStuff just to force to
make sure it does not inline.
Anyways confirmed, worked in GCC 8.2.0 for both aarch64 and arm but does not
work in GCC 9.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug rtl-optimization/101995] [9/10/11/12 Regression] regression built-in memset missed-optimization arm -Os
2021-08-20 9:35 [Bug c/101995] New: regression built-in memset missed-optimization arm -Os dumoulin.thibaut at gmail dot com
` (2 preceding siblings ...)
2021-08-21 2:53 ` pinskia at gcc dot gnu.org
@ 2021-08-21 3:17 ` pinskia at gcc dot gnu.org
2021-08-21 3:26 ` pinskia at gcc dot gnu.org
` (11 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-21 3:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101995
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
REG_RETURNED is no longer there.
Looks like there is an extra move which caused the code to be different.
For aarch64 we have:
(insn 18 4 2 2 (set (reg:DI 94)
(reg:DI 0 x0 [ foo ])) "/app/example.cpp":17:42 47 {*movdi_aarch64}
(nil))
(insn 2 18 3 2 (set (reg/v/f:DI 90 [ foo ])
(reg:DI 94)) "/app/example.cpp":17:42 47 {*movdi_aarch64}
(expr_list:REG_DEAD (reg:DI 94)
(nil)))
Before the call to memset.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug rtl-optimization/101995] [9/10/11/12 Regression] regression built-in memset missed-optimization arm -Os
2021-08-20 9:35 [Bug c/101995] New: regression built-in memset missed-optimization arm -Os dumoulin.thibaut at gmail dot com
` (3 preceding siblings ...)
2021-08-21 3:17 ` pinskia at gcc dot gnu.org
@ 2021-08-21 3:26 ` pinskia at gcc dot gnu.org
2021-08-23 9:10 ` rguenth at gcc dot gnu.org
` (10 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-21 3:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101995
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note I suspect it is r9-3594 is what makes the difference here. Also this is
just very fragile really.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug rtl-optimization/101995] [9/10/11/12 Regression] regression built-in memset missed-optimization arm -Os
2021-08-20 9:35 [Bug c/101995] New: regression built-in memset missed-optimization arm -Os dumoulin.thibaut at gmail dot com
` (4 preceding siblings ...)
2021-08-21 3:26 ` pinskia at gcc dot gnu.org
@ 2021-08-23 9:10 ` rguenth at gcc dot gnu.org
2021-12-08 14:10 ` [Bug rtl-optimization/101995] [9/10/11/12 Regression] regression built-in memset missed-optimization arm -Os since r9-3594 marxin at gcc dot gnu.org
` (9 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-08-23 9:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101995
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
For reference, it's find_call_crossed_cheap_reg finding (or not) such
candidate.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug rtl-optimization/101995] [9/10/11/12 Regression] regression built-in memset missed-optimization arm -Os since r9-3594
2021-08-20 9:35 [Bug c/101995] New: regression built-in memset missed-optimization arm -Os dumoulin.thibaut at gmail dot com
` (5 preceding siblings ...)
2021-08-23 9:10 ` rguenth at gcc dot gnu.org
@ 2021-12-08 14:10 ` marxin at gcc dot gnu.org
2021-12-08 20:42 ` segher at gcc dot gnu.org
` (8 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-12-08 14:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101995
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|needs-bisection |
CC| |marxin at gcc dot gnu.org,
| |segher at gcc dot gnu.org
Summary|[9/10/11/12 Regression] |[9/10/11/12 Regression]
|regression built-in memset |regression built-in memset
|missed-optimization arm -Os |missed-optimization arm -Os
| |since r9-3594
--- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> ---
Really started with r9-3594.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug rtl-optimization/101995] [9/10/11/12 Regression] regression built-in memset missed-optimization arm -Os since r9-3594
2021-08-20 9:35 [Bug c/101995] New: regression built-in memset missed-optimization arm -Os dumoulin.thibaut at gmail dot com
` (6 preceding siblings ...)
2021-12-08 14:10 ` [Bug rtl-optimization/101995] [9/10/11/12 Regression] regression built-in memset missed-optimization arm -Os since r9-3594 marxin at gcc dot gnu.org
@ 2021-12-08 20:42 ` segher at gcc dot gnu.org
2021-12-08 20:44 ` segher at gcc dot gnu.org
` (7 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: segher at gcc dot gnu.org @ 2021-12-08 20:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101995
--- Comment #7 from Segher Boessenkool <segher at gcc dot gnu.org> ---
I don't see any problem with aarch64 fwiw.
If RA decides it does not want to tie the new pseudo to the argument
register, it may have a reason for it? Or suboptimal heuristics.
What is this REG_RETURNED thing?
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug rtl-optimization/101995] [9/10/11/12 Regression] regression built-in memset missed-optimization arm -Os since r9-3594
2021-08-20 9:35 [Bug c/101995] New: regression built-in memset missed-optimization arm -Os dumoulin.thibaut at gmail dot com
` (7 preceding siblings ...)
2021-12-08 20:42 ` segher at gcc dot gnu.org
@ 2021-12-08 20:44 ` segher at gcc dot gnu.org
2021-12-08 20:50 ` segher at gcc dot gnu.org
` (6 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: segher at gcc dot gnu.org @ 2021-12-08 20:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101995
--- Comment #8 from Segher Boessenkool <segher at gcc dot gnu.org> ---
Also, what is fragile here? This is *removing* fragility and premature
choices!
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug rtl-optimization/101995] [9/10/11/12 Regression] regression built-in memset missed-optimization arm -Os since r9-3594
2021-08-20 9:35 [Bug c/101995] New: regression built-in memset missed-optimization arm -Os dumoulin.thibaut at gmail dot com
` (8 preceding siblings ...)
2021-12-08 20:44 ` segher at gcc dot gnu.org
@ 2021-12-08 20:50 ` segher at gcc dot gnu.org
2021-12-09 8:18 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: segher at gcc dot gnu.org @ 2021-12-08 20:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101995
--- Comment #9 from Segher Boessenkool <segher at gcc dot gnu.org> ---
(In reply to Segher Boessenkool from comment #7)
> What is this REG_RETURNED thing?
Ah, something added in ira-lives.c, and you call *that* code fragile?
I agree :-)
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug rtl-optimization/101995] [9/10/11/12 Regression] regression built-in memset missed-optimization arm -Os since r9-3594
2021-08-20 9:35 [Bug c/101995] New: regression built-in memset missed-optimization arm -Os dumoulin.thibaut at gmail dot com
` (9 preceding siblings ...)
2021-12-08 20:50 ` segher at gcc dot gnu.org
@ 2021-12-09 8:18 ` pinskia at gcc dot gnu.org
2021-12-09 21:08 ` segher at gcc dot gnu.org
` (4 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-09 8:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101995
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>I don't see any problem with aarch64 fwiw.
I have to try it on aarch64 but it failed there at one point.
(In reply to Segher Boessenkool from comment #8)
> Also, what is fragile here? This is *removing* fragility and premature
> choices!
(In reply to Segher Boessenkool from comment #9)
> (In reply to Segher Boessenkool from comment #7)
> > What is this REG_RETURNED thing?
>
> Ah, something added in ira-lives.c, and you call *that* code fragile?
> I agree :-)
You got to what I thought was fragile in the end. And yes the whole
REG_RETURNED mechanism seems very fragile (not the change r9-3594 ). I could
not figure out how it was being known to be set on which function call even.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug rtl-optimization/101995] [9/10/11/12 Regression] regression built-in memset missed-optimization arm -Os since r9-3594
2021-08-20 9:35 [Bug c/101995] New: regression built-in memset missed-optimization arm -Os dumoulin.thibaut at gmail dot com
` (10 preceding siblings ...)
2021-12-09 8:18 ` pinskia at gcc dot gnu.org
@ 2021-12-09 21:08 ` segher at gcc dot gnu.org
2022-01-20 10:46 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: segher at gcc dot gnu.org @ 2021-12-09 21:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101995
--- Comment #11 from Segher Boessenkool <segher at gcc dot gnu.org> ---
Yeah, that could be much more robust.
OTOH this stuff is completely opportunistic in the first place: it handles
only function return values, not any other hard registers (like local
register vars).
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug rtl-optimization/101995] [9/10/11/12 Regression] regression built-in memset missed-optimization arm -Os since r9-3594
2021-08-20 9:35 [Bug c/101995] New: regression built-in memset missed-optimization arm -Os dumoulin.thibaut at gmail dot com
` (11 preceding siblings ...)
2021-12-09 21:08 ` segher at gcc dot gnu.org
@ 2022-01-20 10:46 ` rguenth at gcc dot gnu.org
2022-05-27 9:46 ` [Bug rtl-optimization/101995] [10/11/12/13 " rguenth at gcc dot gnu.org
` (2 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-20 10:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101995
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug rtl-optimization/101995] [10/11/12/13 Regression] regression built-in memset missed-optimization arm -Os since r9-3594
2021-08-20 9:35 [Bug c/101995] New: regression built-in memset missed-optimization arm -Os dumoulin.thibaut at gmail dot com
` (12 preceding siblings ...)
2022-01-20 10:46 ` rguenth at gcc dot gnu.org
@ 2022-05-27 9:46 ` rguenth at gcc dot gnu.org
2022-06-28 10:46 ` jakub at gcc dot gnu.org
2023-07-07 10:40 ` [Bug rtl-optimization/101995] [11/12/13/14 " rguenth at gcc dot gnu.org
15 siblings, 0 replies; 17+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27 9:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101995
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|9.5 |10.4
--- Comment #12 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9 branch is being closed
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug rtl-optimization/101995] [10/11/12/13 Regression] regression built-in memset missed-optimization arm -Os since r9-3594
2021-08-20 9:35 [Bug c/101995] New: regression built-in memset missed-optimization arm -Os dumoulin.thibaut at gmail dot com
` (13 preceding siblings ...)
2022-05-27 9:46 ` [Bug rtl-optimization/101995] [10/11/12/13 " rguenth at gcc dot gnu.org
@ 2022-06-28 10:46 ` jakub at gcc dot gnu.org
2023-07-07 10:40 ` [Bug rtl-optimization/101995] [11/12/13/14 " rguenth at gcc dot gnu.org
15 siblings, 0 replies; 17+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101995
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.4 |10.5
--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug rtl-optimization/101995] [11/12/13/14 Regression] regression built-in memset missed-optimization arm -Os since r9-3594
2021-08-20 9:35 [Bug c/101995] New: regression built-in memset missed-optimization arm -Os dumoulin.thibaut at gmail dot com
` (14 preceding siblings ...)
2022-06-28 10:46 ` jakub at gcc dot gnu.org
@ 2023-07-07 10:40 ` rguenth at gcc dot gnu.org
15 siblings, 0 replies; 17+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101995
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.5 |11.5
--- Comment #14 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2023-07-07 10:40 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-20 9:35 [Bug c/101995] New: regression built-in memset missed-optimization arm -Os dumoulin.thibaut at gmail dot com
2021-08-20 12:21 ` [Bug middle-end/101995] " rguenth at gcc dot gnu.org
2021-08-20 21:45 ` [Bug rtl-optimization/101995] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
2021-08-21 2:53 ` pinskia at gcc dot gnu.org
2021-08-21 3:17 ` pinskia at gcc dot gnu.org
2021-08-21 3:26 ` pinskia at gcc dot gnu.org
2021-08-23 9:10 ` rguenth at gcc dot gnu.org
2021-12-08 14:10 ` [Bug rtl-optimization/101995] [9/10/11/12 Regression] regression built-in memset missed-optimization arm -Os since r9-3594 marxin at gcc dot gnu.org
2021-12-08 20:42 ` segher at gcc dot gnu.org
2021-12-08 20:44 ` segher at gcc dot gnu.org
2021-12-08 20:50 ` segher at gcc dot gnu.org
2021-12-09 8:18 ` pinskia at gcc dot gnu.org
2021-12-09 21:08 ` segher at gcc dot gnu.org
2022-01-20 10:46 ` rguenth at gcc dot gnu.org
2022-05-27 9:46 ` [Bug rtl-optimization/101995] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:46 ` jakub at gcc dot gnu.org
2023-07-07 10:40 ` [Bug rtl-optimization/101995] [11/12/13/14 " rguenth 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).