Parallel Programming Guide for HP-UX Systems

Troubleshooting
Compiler assumptions
Chapter 9 203
start + ((trip - 1) * stride) 2
31
The start value is 1, so trip is solved as follows:
start + ((trip - 1) * stride) 2
31
1 + (trip - 1) * 2
22
2
31
(trip - 1) * 2
22
2
31
- 1
trip - 1 2
9
- 2
-22
trip 2
9
- 2
-22
+ 1
trip 512
The maximum value for n in the given loop, then, is 512.
NOTE If you find that certain loops give wrong answers at
optimization levels +O2 or higher, the problem may be test
replacement. If you still want to optimize these loops at
+O2 or above, restructure them to force the compiler to
choose a different induction variable.
Large trip counts at +O2 and above
When a loop is optimized at level +O2 or above, its trip count must occupy
no more than a signed 32-bit storage location. The largest positive value
that can fit in this space is 2
31
- 1 (2,147,483,647). Loops with trip counts
that cannot be determined at compile time but that exceed 2
31
- 1 at
runtime yield wrong answers.
This limitation only applies at optimization levels +O2 and above.
A loop with a trip count that overflows 32 bits is optimized by manually
strip mining the loop.