public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/45636] New: Failed to fold simple Fortran string
@ 2010-09-10 14:48 hjl dot tools at gmail dot com
2010-09-10 15:12 ` [Bug fortran/45636] " kargl at gcc dot gnu dot org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-09-10 14:48 UTC (permalink / raw)
To: gcc-bugs
For this simple Fortran string:
[hjl@gnu-6 pr45634]$ cat pr45634.f90
SUBROUTINE RCRDRD (VTYP)
CHARACTER(4), INTENT(OUT) :: VTYP
CHARACTER(1), SAVE :: DBL = "D"
VTYP = DBL
END
GCC generates:
[hjl@gnu-6 pr45634]$ cat pr45634.s
.file "pr45634.f90"
.text
.p2align 4,,15
.globl rcrdrd_
.type rcrdrd_, @function
rcrdrd_:
.LFB0:
.cfi_startproc
movzbl dbl.1557(%rip), %eax
movw $8224, 1(%rdi)
movb $32, 3(%rdi)
movb %al, (%rdi)
ret
.cfi_endproc
.LFE0:
.size rcrdrd_, .-rcrdrd_
.section .rodata
.type dbl.1557, @object
.size dbl.1557, 1
dbl.1557:
.ascii "D"
.ident "GCC: (GNU) 4.6.0 20100910 (experimental)"
.section .note.GNU-stack,"",@progbits
IFORT generates:
[hjl@gnu-6 pr45634]$ cat icc.s
# -- Machine type EFI2
# mark_description "Intel(R) Fortran Compiler XE for applications running on
Intel(R) 64, Version 12.0.0 Beta Build 20100512";
# mark_description "-O3 -S";
.file "pr45634.f90"
.text
..TXTST0:
# -- Begin rcrdrd_
# mark_begin;
.align 16,0x90
.globl rcrdrd_
rcrdrd_:
# parameter 1: %rdi
# parameter 2: %rsi
..B1.1: # Preds ..B1.0
..___tag_value_rcrdrd_.1: #1.18
movl $538976324, (%rdi) #4.7
ret #5.7
--
Summary: Failed to fold simple Fortran string
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: hjl dot tools at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45636
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/45636] Failed to fold simple Fortran string
2010-09-10 14:48 [Bug fortran/45636] New: Failed to fold simple Fortran string hjl dot tools at gmail dot com
@ 2010-09-10 15:12 ` kargl at gcc dot gnu dot org
2010-09-10 15:20 ` kargl at gcc dot gnu dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-09-10 15:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from kargl at gcc dot gnu dot org 2010-09-10 15:12 -------
I have a slightly different result with your code.
troutmask:sgk[212] gfc4x -c -O g.f90
g.f90: In function 'rcrdrd':
g.f90:1:0: internal compiler error: in build_int_cst_wide, at tree.c:1218
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
If I replace the SAVE attribute by PARAMETER (which will most
likely cause the folding you want), everything compiles fine.
The ICE also goes away if I increase the length of DBL from
one to any larger value.
troutmask:sgk[219] gfc4x -v
Using built-in specs.
COLLECT_GCC=/home/sgk/work/4x/bin/gfortran
COLLECT_LTO_WRAPPER=/usr/home/sgk/work/4x/bin/../libexec/gcc/x86_64-unknown-freebsd9.0/4.6.0/lto-wrapper
Target: x86_64-unknown-freebsd9.0
Configured with: ../gcc4x/configure --prefix=/home/sgk/work/4x
--enable-languages=c,fortran --disable-libmudflap --disable-bootstrap
--with-quad=/home/sgk/work
Thread model: posix
gcc version 4.6.0 20100909 (experimental) (GCC)
--
kargl at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45636
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/45636] Failed to fold simple Fortran string
2010-09-10 14:48 [Bug fortran/45636] New: Failed to fold simple Fortran string hjl dot tools at gmail dot com
2010-09-10 15:12 ` [Bug fortran/45636] " kargl at gcc dot gnu dot org
@ 2010-09-10 15:20 ` kargl at gcc dot gnu dot org
2010-09-10 15:33 ` hjl dot tools at gmail dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-09-10 15:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from kargl at gcc dot gnu dot org 2010-09-10 15:20 -------
The -fdump-tree-original for HJ's original code look like
rcrdrd (character(kind=1)[1:4] & restrict vtyp, integer(kind=4) _vtyp)
{
static character(kind=1) dbl[1:1] = "D";
(MEM[(c_char * {ref-all})vtyp] = MEM[(c_char * {ref-all})&dbl];, (void *)
vtyp;);
__builtin_memset ((void *) vtyp + 1, 32, 3);
}
If I increase the length of DBL to 2, then the dump looks like
rcrdrd (character(kind=1)[1:4] & restrict vtyp, integer(kind=4) _vtyp)
{
static character(kind=1) dbl[1:2] = "D ";
__builtin_memmove ((void *) vtyp, (void *) &dbl, 2);
__builtin_memset ((void *) vtyp + 2, 32, 2);
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45636
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/45636] Failed to fold simple Fortran string
2010-09-10 14:48 [Bug fortran/45636] New: Failed to fold simple Fortran string hjl dot tools at gmail dot com
2010-09-10 15:12 ` [Bug fortran/45636] " kargl at gcc dot gnu dot org
2010-09-10 15:20 ` kargl at gcc dot gnu dot org
@ 2010-09-10 15:33 ` hjl dot tools at gmail dot com
2010-09-10 15:34 ` kargl at gcc dot gnu dot org
2010-09-10 15:47 ` jakub at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-09-10 15:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from hjl dot tools at gmail dot com 2010-09-10 15:32 -------
(In reply to comment #1)
> I have a slightly different result with your code.
>
> troutmask:sgk[212] gfc4x -c -O g.f90
> g.f90: In function 'rcrdrd':
> g.f90:1:0: internal compiler error: in build_int_cst_wide, at tree.c:1218
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <http://gcc.gnu.org/bugs.html> for instructions.
>
>
It is fixed by
http://gcc.gnu.org/ml/gcc-cvs/2010-09/msg00475.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45636
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/45636] Failed to fold simple Fortran string
2010-09-10 14:48 [Bug fortran/45636] New: Failed to fold simple Fortran string hjl dot tools at gmail dot com
` (2 preceding siblings ...)
2010-09-10 15:33 ` hjl dot tools at gmail dot com
@ 2010-09-10 15:34 ` kargl at gcc dot gnu dot org
2010-09-10 15:47 ` jakub at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-09-10 15:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from kargl at gcc dot gnu dot org 2010-09-10 15:34 -------
(In reply to comment #3)
> (In reply to comment #1)
> > I have a slightly different result with your code.
> >
> > troutmask:sgk[212] gfc4x -c -O g.f90
> > g.f90: In function 'rcrdrd':
> > g.f90:1:0: internal compiler error: in build_int_cst_wide, at tree.c:1218
> > Please submit a full bug report,
> > with preprocessed source if appropriate.
> > See <http://gcc.gnu.org/bugs.html> for instructions.
> >
> >
>
> It is fixed by
>
> http://gcc.gnu.org/ml/gcc-cvs/2010-09/msg00475.html
>
HJ,
Thanks. I updated by trunk right before your patch,
so I missed it my most recent build.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45636
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/45636] Failed to fold simple Fortran string
2010-09-10 14:48 [Bug fortran/45636] New: Failed to fold simple Fortran string hjl dot tools at gmail dot com
` (3 preceding siblings ...)
2010-09-10 15:34 ` kargl at gcc dot gnu dot org
@ 2010-09-10 15:47 ` jakub at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-09-10 15:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jakub at gcc dot gnu dot org 2010-09-10 15:47 -------
For arbitrary lengths (both of the constant string and of the padding) the
memmove (which will be optimized to memcpy as the source is read-only) + memset
is the best thing to do, replacing say
memmove (x, "900 bytes long string", 900);
memset (x + 900, ' ', 100);
would be very .rodata size unfriendly.
So, the question is, do we want to optimize this for very small sizes of both
(what sizes? Should we call can_store_by_pieces to determine that from the
FE?)
in the FE by transforming that say
memmove (x, "ABCDE", 5);
memset (x + 5, ' ', 3);
into
memcpy (x, "ABCDE ", 8);
or should we do this generically in the middle-end, where we'd do this
transformation for such cases even for other languages?
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45636
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-09-10 15:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-10 14:48 [Bug fortran/45636] New: Failed to fold simple Fortran string hjl dot tools at gmail dot com
2010-09-10 15:12 ` [Bug fortran/45636] " kargl at gcc dot gnu dot org
2010-09-10 15:20 ` kargl at gcc dot gnu dot org
2010-09-10 15:33 ` hjl dot tools at gmail dot com
2010-09-10 15:34 ` kargl at gcc dot gnu dot org
2010-09-10 15:47 ` jakub 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).