- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Does having compile-time constants that are labelled as "PARAMETER" help to compiler to optimize? For example, if there we have a
LOGICAL, PARAMETER :: testValue = .FALSE.
and then somewhere
IF (testValue) THEN
! Some code here
END IF
Can the compiler work out that no test is needed? In fact, does the compiler no even include the code "! Some code here".
Regards,
Nym.
Does having compile-time constants that are labelled as "PARAMETER" help to compiler to optimize? For example, if there we have a
LOGICAL, PARAMETER :: testValue = .FALSE.
and then somewhere
IF (testValue) THEN
! Some code here
END IF
Can the compiler work out that no test is needed? In fact, does the compiler no even include the code "! Some code here".
Regards,
Nym.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In many cases, yes. PARAMETER constants and literal constants are treated the same here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok. So if there is some code
IF (.FALSE.) THEN
! Some code
END IF
Would the compiler include or not include the "! Some code" in the output file? Would the above three line be essentially removed?
Nym
IF (.FALSE.) THEN
! Some code
END IF
Would the compiler include or not include the "! Some code" in the output file? Would the above three line be essentially removed?
Nym
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could check this, for your own case, by compiling with -S, to see whether code corresponding to those source lines was eliminated. Most likely, this would be done in dead code elimination phases of the compiler (not at -O0).

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