Created attachment 12893 [details] Example input to opt that demonstrates bug When pass loop-vectorize runs, it adds new loop metadata to indicate that the vectorizer ran, but fails to remove the old conflicting metadata. For example, if you take the attached file for.ll and process it with: opt -S -loop-vectorize -debug-only=loop-vectorize for.ll the output has: br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !3 ... !1 = metadata !{metadata !"llvm.loop.vectorize.width", i32 1} !2 = metadata !{metadata !"llvm.loop.interleave.count", i32 1} !3 = metadata !{metadata !3, metadata !4, metadata !1, metadata !2} !4 = metadata !{metadata !"llvm.loop.vectorize.width", i32 4} Note that !3 contains two conflicting widths: a width of 1 inside !2 and a width of 4 inside !4. The pass should not have included !4 inside !3. I'm using LLVM version 3.6.0svn.
Right, seems an vectorizer vs. O3+vectorizer issue, as with just -O3 the loop looks perfect. Still, I think we could make setAlreadyVectorized() clean up after itself without needing additional cleanup passes. I'll have a look, should be simple.
Ended up refactoring the whole hint code... :) http://reviews.llvm.org/D4913
Fixed in r215994
MSVC 2011 can't cope with my patch's C++11 goodness, so this will have to wait. Once MSVC 2013 becomes the new minimum requirement, I'll commit again.
Is there a reason why a work-around would be difficult?
No reason, but the bug is very low priority, since it only happens in a particularly obscure combination of flags and even so, it's not really that critical. I'd rather wait for a nice code than work around it now and forget later. :) If this really affects people's work I can think of a work around, of course.
Trying again on r216870 with MSVC2012-safe code.
It seems MSVC 2012 is happy with the code, thanks Seth Cantrell for the tip.