I was trying to trace the Loop vectorizer of the LLVM, I wrote a simple loop with a clear dependency.
But found that the debug shows that ‘we can vectorize this loop’
Here you are my loop with dependency:
dataY[k] = dataY[k-1];
And the debug prints:
LV: Checking a loop in “main”
LV: Found a loop: for.body4
LV: Found an induction variable.
LV: Found a write-only loop!
LV: We can vectorize this loop!
LV: Vectorization is possible but not beneficial.
From the LLVM IR, it contains only one ‘store’ instruction with ‘%.pre’. Seems that no ‘load’ instruction prevented the Vectorizer to detect dependency.
Is that a bug, or I’m missing something? Please advice
for.body4: ; preds = %for.body4, %for.cond2.preheader
%k.030 = phi i32 [ 20, %for.cond2.preheader ], [ %inc8, %for.body4 ]
%arrayidx6 = getelementptr inbounds i32* %0, i32 %k.030
store i32 %.pre, i32* %arrayidx6, align 4, !tbaa !0
%inc8 = add nsw i32 %k.030, 1
%exitcond32 = icmp eq i32 %inc8, 50
br i1 %exitcond32, label %for.cond10.preheader, label %for.body4
Thanks in advance,