public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102725] New: [12 Regression] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768
@ 2021-10-13 8:18 marxin at gcc dot gnu.org
2021-10-13 8:31 ` [Bug tree-optimization/102725] " pinskia at gcc dot gnu.org
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-10-13 8:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102725
Bug ID: 102725
Summary: [12 Regression] -fno-builtin leads to call of strlen
since r12-4283-g6f966f06146be768
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: marxin at gcc dot gnu.org
CC: stefansf at linux dot ibm.com
Target Milestone: ---
I noticed that in valgrind package, where they define their own standard
library functions.
$ cat strlen.c
#include <stddef.h>
size_t mystrlen ( const char* str )
{
size_t i = 0;
while (str[i] != 0) i++;
return i;
}
int main(int argc, char **argv)
{
return mystrlen (argv[0]);
}
$ gcc strlen.c -O3 -fno-builtin -S && grep "call.*strlen" strlen.s
call strlen
call strlen
Before your revision, no strlen was called.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/102725] [12 Regression] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768
2021-10-13 8:18 [Bug tree-optimization/102725] New: [12 Regression] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768 marxin at gcc dot gnu.org
@ 2021-10-13 8:31 ` pinskia at gcc dot gnu.org
2021-10-13 8:38 ` [Bug tree-optimization/102725] " marxin at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-13 8:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102725
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
You need -fno-tree-loop-distribution -fno-tree-loop-distribute-patterns to turn
it off. There is another older bug about this for memcpy.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/102725] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768
2021-10-13 8:18 [Bug tree-optimization/102725] New: [12 Regression] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768 marxin at gcc dot gnu.org
2021-10-13 8:31 ` [Bug tree-optimization/102725] " pinskia at gcc dot gnu.org
@ 2021-10-13 8:38 ` marxin at gcc dot gnu.org
2021-10-13 8:46 ` pinskia at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-10-13 8:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102725
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> You need -fno-tree-loop-distribution -fno-tree-loop-distribute-patterns to
> turn it off. There is another older bug about this for memcpy.
Well, I would expect this optimization would do the optimization only if
__builtin_strlen is allowed (not disallowed by the option).
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/102725] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768
2021-10-13 8:18 [Bug tree-optimization/102725] New: [12 Regression] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768 marxin at gcc dot gnu.org
2021-10-13 8:31 ` [Bug tree-optimization/102725] " pinskia at gcc dot gnu.org
2021-10-13 8:38 ` [Bug tree-optimization/102725] " marxin at gcc dot gnu.org
@ 2021-10-13 8:46 ` pinskia at gcc dot gnu.org
2021-10-13 11:36 ` rguenth at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-13 8:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102725
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #2)
> (In reply to Andrew Pinski from comment #1)
> > You need -fno-tree-loop-distribution -fno-tree-loop-distribute-patterns to
> > turn it off. There is another older bug about this for memcpy.
>
> Well, I would expect this optimization would do the optimization only if
> __builtin_strlen is allowed (not disallowed by the option).
__builtin_strlen is always allowed even if -fno-builtin. -fno-builtin just
disables strlen -> __builtin_strlen conversion. See the other bugs that I
referenced for an example. There are more dealing with memcpy too.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/102725] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768
2021-10-13 8:18 [Bug tree-optimization/102725] New: [12 Regression] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768 marxin at gcc dot gnu.org
` (2 preceding siblings ...)
2021-10-13 8:46 ` pinskia at gcc dot gnu.org
@ 2021-10-13 11:36 ` rguenth at gcc dot gnu.org
2021-12-29 13:11 ` marxin at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-10-13 11:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102725
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think that 'strlen' is only used when it is explicitely declared. Hmm, maybe
I'm mistaken and it's 'implicit' already because it is standard.
So loop distribution could check for builtin_decl_declared_p (BUILT_IN_STRLEN)
(but that likely only "works" for the C family frontends)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/102725] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768
2021-10-13 8:18 [Bug tree-optimization/102725] New: [12 Regression] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768 marxin at gcc dot gnu.org
` (3 preceding siblings ...)
2021-10-13 11:36 ` rguenth at gcc dot gnu.org
@ 2021-12-29 13:11 ` marxin at gcc dot gnu.org
2022-07-18 22:44 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-12-29 13:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102725
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dani at danielbertalan dot dev
--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
*** Bug 103858 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/102725] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768
2021-10-13 8:18 [Bug tree-optimization/102725] New: [12 Regression] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768 marxin at gcc dot gnu.org
` (4 preceding siblings ...)
2021-12-29 13:11 ` marxin at gcc dot gnu.org
@ 2022-07-18 22:44 ` pinskia at gcc dot gnu.org
2023-02-08 17:45 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-18 22:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102725
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vincent.riviere at freesbee dot fr
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 106349 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/102725] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768
2021-10-13 8:18 [Bug tree-optimization/102725] New: [12 Regression] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768 marxin at gcc dot gnu.org
` (5 preceding siblings ...)
2022-07-18 22:44 ` pinskia at gcc dot gnu.org
@ 2023-02-08 17:45 ` pinskia at gcc dot gnu.org
2023-06-03 0:42 ` vincent.riviere at freesbee dot fr
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-08 17:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102725
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel at eyoman dot com
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 108715 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/102725] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768
2021-10-13 8:18 [Bug tree-optimization/102725] New: [12 Regression] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768 marxin at gcc dot gnu.org
` (6 preceding siblings ...)
2023-02-08 17:45 ` pinskia at gcc dot gnu.org
@ 2023-06-03 0:42 ` vincent.riviere at freesbee dot fr
2023-06-03 1:16 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: vincent.riviere at freesbee dot fr @ 2023-06-03 0:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102725
--- Comment #8 from Vincent Riviere <vincent.riviere at freesbee dot fr> ---
This still happens with m68k-elf-gcc 13.1.0.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/102725] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768
2021-10-13 8:18 [Bug tree-optimization/102725] New: [12 Regression] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768 marxin at gcc dot gnu.org
` (7 preceding siblings ...)
2023-06-03 0:42 ` vincent.riviere at freesbee dot fr
@ 2023-06-03 1:16 ` pinskia at gcc dot gnu.org
2023-06-03 1:56 ` terra at gnome dot org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-03 1:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102725
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Depends on| |56888
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Vincent Riviere from comment #8)
> This still happens with m68k-elf-gcc 13.1.0.
Yes because it is basically a dup of bug 56888.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888
[Bug 56888] memcpy implementation optimized as a call to memcpy
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/102725] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768
2021-10-13 8:18 [Bug tree-optimization/102725] New: [12 Regression] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768 marxin at gcc dot gnu.org
` (8 preceding siblings ...)
2023-06-03 1:16 ` pinskia at gcc dot gnu.org
@ 2023-06-03 1:56 ` terra at gnome dot org
2023-12-17 17:58 ` pinskia at gcc dot gnu.org
2023-12-17 19:56 ` gjl at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: terra at gnome dot org @ 2023-06-03 1:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102725
M Welinder <terra at gnome dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |terra at gnome dot org
--- Comment #10 from M Welinder <terra at gnome dot org> ---
mystrlen and strlen are not equivalent, so gcc is wrong in turning the former
into a call of the latter.
Specifically: mystrlen preserves errno, strlen need not do that. (C99 section
7.5 item 3.)
(Repeating the comment from over in bug 56888.)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/102725] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768
2021-10-13 8:18 [Bug tree-optimization/102725] New: [12 Regression] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768 marxin at gcc dot gnu.org
` (9 preceding siblings ...)
2023-06-03 1:56 ` terra at gnome dot org
@ 2023-12-17 17:58 ` pinskia at gcc dot gnu.org
2023-12-17 19:56 ` gjl at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-17 17:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102725
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gjl at gcc dot gnu.org
--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 113049 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/102725] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768
2021-10-13 8:18 [Bug tree-optimization/102725] New: [12 Regression] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768 marxin at gcc dot gnu.org
` (10 preceding siblings ...)
2023-12-17 17:58 ` pinskia at gcc dot gnu.org
@ 2023-12-17 19:56 ` gjl at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: gjl at gcc dot gnu.org @ 2023-12-17 19:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102725
--- Comment #12 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> You need -fno-tree-loop-distribution -fno-tree-loop-distribute-patterns to
> turn it off. There is another older bug about this for memcpy.
This is also a documentation issue.
Neither from the naming of that option nor from its documentation one can
concluse that it inhibits open-coded-foo -> foo transformations.
And IMO options that disable all builtin generations should be available on
single function basis, like -fno-auto-strlen or whatever.
Moreover, introducing a call to strlen in a function named "strlen" (or with
assembly name "strlen") is not very wise.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-12-17 19:56 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 8:18 [Bug tree-optimization/102725] New: [12 Regression] -fno-builtin leads to call of strlen since r12-4283-g6f966f06146be768 marxin at gcc dot gnu.org
2021-10-13 8:31 ` [Bug tree-optimization/102725] " pinskia at gcc dot gnu.org
2021-10-13 8:38 ` [Bug tree-optimization/102725] " marxin at gcc dot gnu.org
2021-10-13 8:46 ` pinskia at gcc dot gnu.org
2021-10-13 11:36 ` rguenth at gcc dot gnu.org
2021-12-29 13:11 ` marxin at gcc dot gnu.org
2022-07-18 22:44 ` pinskia at gcc dot gnu.org
2023-02-08 17:45 ` pinskia at gcc dot gnu.org
2023-06-03 0:42 ` vincent.riviere at freesbee dot fr
2023-06-03 1:16 ` pinskia at gcc dot gnu.org
2023-06-03 1:56 ` terra at gnome dot org
2023-12-17 17:58 ` pinskia at gcc dot gnu.org
2023-12-17 19:56 ` gjl 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).