Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29253 Discussions

PARAMETER Variable - helps optimization?

neverwillreply
Beginner
665 Views
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.
0 Kudos
3 Replies
Steven_L_Intel1
Employee
665 Views
In many cases, yes. PARAMETER constants and literal constants are treated the same here.
0 Kudos
neverwillreply
Beginner
665 Views
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
0 Kudos
TimP
Honored Contributor III
665 Views
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).
0 Kudos
Reply