public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/40628]  New: Assignment using "= trim(string)": Optimize "trim" away
@ 2009-07-03  7:16 burnus at gcc dot gnu dot org
  2009-07-05  9:14 ` [Bug fortran/40628] " fxcoudert at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-07-03  7:16 UTC (permalink / raw)
  To: gcc-bugs

In assignments, such as
  string = trim(string)
  string(n1:n2) = trim(string)
the trim has no effect and can be optimized away.

(Note: With Fortran 2003 and allocatable strings with "len=:", the first
version cannot be optimized as on length mismatch the LHS is reallocated.)

Such code can easily be present in real-world code and causes unnecessarily a
large overhead, cf. e.g. http://www.tddft.org/trac/octopus/changeset/5672


-- 
           Summary: Assignment using "= trim(string)": Optimize "trim" away
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40628


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/40628] Assignment using "= trim(string)": Optimize "trim" away
  2009-07-03  7:16 [Bug fortran/40628] New: Assignment using "= trim(string)": Optimize "trim" away burnus at gcc dot gnu dot org
@ 2009-07-05  9:14 ` fxcoudert at gcc dot gnu dot org
  2010-06-18 21:12 ` tkoenig at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2009-07-05  9:14 UTC (permalink / raw)
  To: gcc-bugs



-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-07-05 09:13:58
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40628


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/40628] Assignment using "= trim(string)": Optimize "trim" away
  2009-07-03  7:16 [Bug fortran/40628] New: Assignment using "= trim(string)": Optimize "trim" away burnus at gcc dot gnu dot org
  2009-07-05  9:14 ` [Bug fortran/40628] " fxcoudert at gcc dot gnu dot org
@ 2010-06-18 21:12 ` tkoenig at gcc dot gnu dot org
  2010-06-18 21:19 ` burnus at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2010-06-18 21:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from tkoenig at gcc dot gnu dot org  2010-06-18 21:12 -------
Mine.


-- 

tkoenig at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |tkoenig at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2009-09-29 05:52:11         |2010-06-18 21:12:29
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40628


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/40628] Assignment using "= trim(string)": Optimize "trim" away
  2009-07-03  7:16 [Bug fortran/40628] New: Assignment using "= trim(string)": Optimize "trim" away burnus at gcc dot gnu dot org
  2009-07-05  9:14 ` [Bug fortran/40628] " fxcoudert at gcc dot gnu dot org
  2010-06-18 21:12 ` tkoenig at gcc dot gnu dot org
@ 2010-06-18 21:19 ` burnus at gcc dot gnu dot org
  2010-07-25 19:32 ` tkoenig at gcc dot gnu dot org
  2010-07-25 19:37 ` tkoenig at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-06-18 21:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2010-06-18 21:19 -------
In the link, one also finds
  trim(str1) == trim(str2)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40628


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/40628] Assignment using "= trim(string)": Optimize "trim" away
  2009-07-03  7:16 [Bug fortran/40628] New: Assignment using "= trim(string)": Optimize "trim" away burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2010-06-18 21:19 ` burnus at gcc dot gnu dot org
@ 2010-07-25 19:32 ` tkoenig at gcc dot gnu dot org
  2010-07-25 19:37 ` tkoenig at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2010-07-25 19:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from tkoenig at gcc dot gnu dot org  2010-07-25 19:31 -------
Subject: Bug 40628

Author: tkoenig
Date: Sun Jul 25 19:31:37 2010
New Revision: 162519

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=162519
Log:
2010-07-25  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR fortran/40628
        * Make-lang.in:  Add fortran/frontend-passes.o.
        * gfortran.h:  Add prototype for gfc_run_passes.
        * resolve.c (gfc_resolve):  Call gfc_run_passes.
        * frontend-passes.c:  New file.

2010-07-25  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR fortran/40628
        * trim_optimize_1.f90:  New test.
        * character_comparision_1.f90:  New test.


Added:
    trunk/gcc/fortran/frontend-passes.c
    trunk/gcc/testsuite/gfortran.dg/character_comparison_1.f90
    trunk/gcc/testsuite/gfortran.dg/trim_optimize_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/Make-lang.in
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40628


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/40628] Assignment using "= trim(string)": Optimize "trim" away
  2009-07-03  7:16 [Bug fortran/40628] New: Assignment using "= trim(string)": Optimize "trim" away burnus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2010-07-25 19:32 ` tkoenig at gcc dot gnu dot org
@ 2010-07-25 19:37 ` tkoenig at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2010-07-25 19:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from tkoenig at gcc dot gnu dot org  2010-07-25 19:37 -------
Fixed on trunk.  Closing.


-- 

tkoenig at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40628


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-07-25 19:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-03  7:16 [Bug fortran/40628] New: Assignment using "= trim(string)": Optimize "trim" away burnus at gcc dot gnu dot org
2009-07-05  9:14 ` [Bug fortran/40628] " fxcoudert at gcc dot gnu dot org
2010-06-18 21:12 ` tkoenig at gcc dot gnu dot org
2010-06-18 21:19 ` burnus at gcc dot gnu dot org
2010-07-25 19:32 ` tkoenig at gcc dot gnu dot org
2010-07-25 19:37 ` tkoenig 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).