I just wanted to add that SM 3.0 capable video cards (I'm not sure about SM +4.0 running on OpenGL) such as GeForce 6 & 7 series have a couple limitations when doing for loops:
In theory, SM 3.0 adds dynamic branching and loops, therefore something like for( int i=0; i<100000; ++i ) should work. BUT, it's not that easy. For two reasons.
The first one, some stuff cannot be inside a branch. For example, something as simple as "constantExpression[i]" (constant register addressing/indexing) cannot be made inside a pixel shader while being in a dynamic branch; therefore the loop must be unrolled. This is true for DX9, not for DX10. OpenGL is a mistery to me.
My GeForce 8600 GTS has a MaxPixelShader30InstructionSlots of 4.096; which means that if the shader compiles into more than 4.096 instructions (a number very easy to achieve with an unrolled loop) it will fail. Of course, that's if I were using D3D9. I don't know what would happen in OpenGL (whether DX10 or DX9 specifications are used). Nonetheless, I'm 100% sure it will fail in a GeForce 6/7 because of hardware limitations. Note SM 3.0 has a minimum guaranteed of only 512 instruction slots (ATI Radeon X1000 series just have the minimum); while SM 4.0 has a minimum guaranteed of 65.535
Additionally, my GPU has a MaxPShaderInstructionsExecuted 65.535; which is a relatively high number and sane number and this counts instructions slots + for non-unrolled loops. Again, this is a limit for D3D9, but if you're using OGL, I don't know if works under DX9 or DX10 specs, or a mix of them. And again, a GF 6/7 will fail to execute more than 65.535 instructions in a non-unrolled loop because of HW limitations. Note in SM 4.0 there is virtually no limit of executed instructions in a for loop (unless unrolled, of course).
The second reason it may fail, Windows Vista (7 too?) has a very lame (OK; it's not that lame, it's really hard to solve the problem) way to tell if a GPU has stopped responding (due to HW failure or lock up, driver errors, etc) by just using a timeout and sending a heartbeat to the driver. If the GPU fails to answer the heartbeat in two seconds, the driver is ordered to shutdown the GPU and reset. This means very high values in your for loop will increase the likehood of getting a reset. This mechanism is explained here
Updated version here