Bug 45715 - [ABI cleanup] Move runtime parsing of I/O control list to front end
Summary: [ABI cleanup] Move runtime parsing of I/O control list to front end
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks: 37577 48419 56818
  Show dependency treegraph
 
Reported: 2010-09-18 07:47 UTC by Thomas Koenig
Modified: 2013-04-02 18:52 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Koenig 2010-09-18 07:47:39 UTC
Currently, for code like

WRITE (*,ADVANCE="NO")

we compare the ADVANCE string in the library.  This is wasteful
in the vast majority of cases, where the corresponding strings
are constant.

We should do the string comparison in the front end, where it
can be folded, and pass a bit field to the library.

Something for the ABI cleanup, when it happens in 4.7.
Comment 1 Jerry DeLisle 2010-09-21 03:08:30 UTC
Here is a case where we do have to evaluate at run time.  So maybe we can not do what is proposed above.

character(10):: advancevar
advancevar = "no"
write(*, "(a)", advance=advancevar) "Well, "
print *, "Does it work?"
end
! Interestingly, if advancevar is a PARAMETER, we get an error.
Comment 2 Tobias Burnus 2010-09-21 06:54:38 UTC
(In reply to comment #1)
> Here is a case where we do have to evaluate at run time.  So maybe we can not
> do what is proposed above.

Well, I understood the request such that one passes a boolean for the 'YES' / 'NO' items. If it cannot be simplified at compile time, one adds (in trans*c) code like:
   advance = _gfortran_compare_string (3, &"YES", len, &str) == 0;

Possibly, one should add a new function like
  advance = _gfortran_io_yes_no (len, &str, "ADVANCE");
which takes then also into account invalid values.
Comment 3 Thomas Koenig 2011-04-17 19:27:47 UTC
Actually, for many strings, we would need
'yes', 'no" and a value for 'not specified', so four bits instead of 32.
Still better by a factor of 8, though :-)