The code block below appears to generate bad code when the automatic vectorizer is enabled but correct code when /Qvec- is used even up to /O3 optimization. The vectorizer does not track N properly so that the values of RD for N=5-8 are repeated for N=9-12 followed by the values expected for N=9 and up.
N = 0 R = RFI DO I = 1, M1B K = M2(I) DR = DROD*F(I) DO J = 1, K R = R + DR N = N + 1 RD(N) = R R = R + DR END DO END DO
Adding a PRINT statement in the inner loop (which probably disables vectorization) also eliminates the incorrect behavior.
This occurs running Intel(R) Composer XE 2013 Update 5 (package 198). I am downloading SP1 and will try that.
If this is a confirmed bug it would be great to have it reported formally.
Thanks,
Stuart