Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29298 Discussions

PARAMETER Variable - helps optimization?

neverwillreply
Beginner
721 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
721 Views
In many cases, yes. PARAMETER constants and literal constants are treated the same here.
0 Kudos
neverwillreply
Beginner
721 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
721 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