public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/30398] memmove for string operations
[not found] <bug-30398-4@http.gcc.gnu.org/bugzilla/>
@ 2020-11-11 9:31 ` tkoenig at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2020-11-11 9:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30398
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
This is what we generated now for
program main
character(len=1) :: s
character(len=2) :: c
s = 'a'
c = repeat(s,2)
call foo(c)
end program main
:
;; Function main (main, funcdef_no=1, decl_uid=3926, cgraph_uid=2,
symbol_order=1) (executed once)
__attribute__((externally_visible))
main (integer(kind=4) argc, character(kind=1) * * argv)
{
character(kind=1) c[1:2];
static integer(kind=4) options.3[7] = {2116, 4095, 0, 1, 1, 0, 31};
<bb 2> [local count: 1073741825]:
_gfortran_set_args (argc_2(D), argv_3(D));
_gfortran_set_options (7, &options.3[0]);
MEM <unsigned short> [(c_char * {ref-all})&c] = 24929;
foo (&c, 2);
c ={v} {CLOBBER};
return 0;
}
So, everything that should be optimized is now optimized.
Fixed.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug tree-optimization/30398] memmove for string operations
2007-01-06 22:05 [Bug fortran/30398] New: " tkoenig at gcc dot gnu dot org
@ 2007-04-13 15:27 ` tobi at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: tobi at gcc dot gnu dot org @ 2007-04-13 15:27 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from tobi at gcc dot gnu dot org 2007-04-13 16:27 -------
With FX' patch to inline REPEAT (see PR31304), we are left with this as final
dump after a -O compilation:
;; Function MAIN__ (MAIN__)
MAIN__ ()
{
char[1:] * pstr.1;
char s[1:1];
char c[1:2];
void * D.1004;
<bb 2>:
_gfortran_set_std (68, 127, 0, 0, 0);
s[1]{lb: 1 sz: 1} = 97;
D.1004 = _gfortran_internal_malloc (2);
pstr.1 = (char[1:] *) D.1004;
__builtin_memcpy ((char *) pstr.1, &s, 1);
__builtin_memcpy (pstr.1 + 1B, &s, 1);
__builtin_memmove (&c, pstr.1, 2);
_gfortran_internal_free (pstr.1);
return;
}
The call to memmove makes it way into the assembly, even though pstr and c
can't alias. This is now an optimizer issue, moving to component
tree-optimization, as the tree-ssa optimizers should be able to eliminate the
memmove in favor of a memcpy. Or even better, get rid of the whole copying
business and predict the correct results. If that's possible it would be great
to have a way to get rid of the then unnecessary temporary allocation.
--
tobi at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tobi at gcc dot gnu dot org,
| |fxcoudert at gcc dot gnu dot
| |org
Component|fortran |tree-optimization
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30398
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-11 9:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-30398-4@http.gcc.gnu.org/bugzilla/>
2020-11-11 9:31 ` [Bug tree-optimization/30398] memmove for string operations tkoenig at gcc dot gnu.org
2007-01-06 22:05 [Bug fortran/30398] New: " tkoenig at gcc dot gnu dot org
2007-04-13 15:27 ` [Bug tree-optimization/30398] " tobi at gcc dot gnu dot 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).