- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
is there any optimization option I don't know about to merge duplicate string literals in the compiled code? Consider the simple test code:
subroutine test1(s1,s2)
character(*) s1,s2
write(0,101) s1,s2
101 format(a,', ',a)
end subroutine
subroutine test2()
call test1('hello','world')
call test1('goodbye','world')
call test1('hello','heaven')
end subroutine
whether compiled with ifort -O2, -O3 even -Os, the resulting object code
contains two instances of "hello" as well as "world".
Also, compiling to assembler shows that the three calls to test1 share no arguments (i.e. different strings are being referenced).
On the contrary, gfortran eliminates the duplicate literals even at -O0.
Of course, the same effect can be achieved by using named string constants, but I still reckon this is a fairly useful code size optimization.
Perhaps there is an option for this; If not, I can file an enhancement suggestion to Premier Support.
Thanks for comments
is there any optimization option I don't know about to merge duplicate string literals in the compiled code? Consider the simple test code:
subroutine test1(s1,s2)
character(*) s1,s2
write(0,101) s1,s2
101 format(a,', ',a)
end subroutine
subroutine test2()
call test1('hello','world')
call test1('goodbye','world')
call test1('hello','heaven')
end subroutine
whether compiled with ifort -O2, -O3 even -Os, the resulting object code
contains two instances of "hello" as well as "world".
Also, compiling to assembler shows that the three calls to test1 share no arguments (i.e. different strings are being referenced).
On the contrary, gfortran eliminates the duplicate literals even at -O0.
Of course, the same effect can be achieved by using named string constants, but I still reckon this is a fairly useful code size optimization.
Perhaps there is an option for this; If not, I can file an enhancement suggestion to Premier Support.
Thanks for comments
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is no option for this. Feel free to submit a feature request for it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Stick the strings in a module and decalre as a parameter. Then to global search and replace. This has the added benefit of using a different use file to change a language.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Back when I worked on VAX and Alpha compilers, constant pooling was a pretty standard thing to do, but memory sizes were smaller back then as well. Unless you have lots of copies of big strings, there's not really a measurable advantage to pooling, but I'll agree that it seems inelegant to not do so.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page