Developer Guide and Reference

Contents

loop_count

Specifies the iterations for a for loop.

Syntax

#pragma loop_count
(
n
)
#pragma loop_count
=
n
or
#pragma loop_count
(
n1
[
,
n2
]
...
)
#pragma loop_count
=
n1
[
,
n2
]
...
or
#pragma loop_count
min
(
n
)
,
max
(
n
)
,
avg
(
n
)
#pragma loop_count
min
=
n
,
max
=
n
,
avg
=
n
Arguments
(n) or =n
A non-negative integer value. The compiler will attempt to iterate the next loop the number of times specified in
n
; however, the number of iterations is not guaranteed.
(n1[,n2]...) or = n1[,n2]...
Non-negative integer values. The compiler will attempt to iterate the next loop the number of time specified by
n1
or
n2
, or some other unspecified number of times. This behavior allows the compiler some flexibility in attempting to unroll the loop. The number of iterations is not guaranteed.
min(n), max(n), avg(n) or min=n, max=n, avg=n
Non-negative integer values. Specify one or more in any order without duplication. The compiler insures the next loop iterates for the specified maximum, minimum, or average number (
n1
) of times. The specified number of iterations is guaranteed for min and max.
Description
The
loop_count
pragma specifies the minimum, maximum, or average number of iterations for a
for
loop. In addition, a list of commonly occurring values can be specified to help the compiler generate multiple versions and perform complete unrolling.
You can specify more than one pragma for a single loop; however, do not duplicate the pragma.

Example

The following example illustrates how to use the
loop_count
pragma to iterate through the loop a minimum of three, a maximum of ten, and average of five times.
Example: Using the
loop_count
pragma min(n), max(n), avg(n)
#include <stdio.h> int i; int mysum(int start, int end, int a) { int iret=0; #pragma loop_count min(3), max(10), avg(5) for (i=start;i<=end;i++) iret += a; return iret; } int main() { int t; t = mysum(1, 10, 3); printf("t1=%d\r\n",t); t = mysum(2, 6, 2); printf("t2=%d\r\n",t); t = mysum(5, 12, 1); printf("t3=%d\r\n",t); }

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804