summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/LoopVectorize
diff options
context:
space:
mode:
authorAnna Thomas <anna@azul.com>2017-09-12 16:32:45 +0000
committerAnna Thomas <anna@azul.com>2017-09-12 16:32:45 +0000
commit9f1be02fa333f7d9d4a6b3021181d15df847c03c (patch)
tree85fe6d52eeb65d5a691e69796489555e1167fa5d /llvm/test/Transforms/LoopVectorize
parenta54ed0a4074d255665b3ffcc6602244800e13f2c (diff)
downloadbcm5719-llvm-9f1be02fa333f7d9d4a6b3021181d15df847c03c.tar.gz
bcm5719-llvm-9f1be02fa333f7d9d4a6b3021181d15df847c03c.zip
[LV] Clamp the VF to the trip count
Summary: When the MaxVectorSize > ConstantTripCount, we should just clamp the vectorization factor to be the ConstantTripCount. This vectorizes loops where the TinyTripCountThreshold >= TripCount < MaxVF. Earlier we were finding the maximum vector width, which could be greater than the trip count itself. The Loop vectorizer does all the work for generating a vectorizable loop, but in the end we would always choose the scalar loop (since the VF > trip count). This allows us to choose the VF keeping in mind the trip count if available. This is a fix on top of rL312472. Reviewers: Ayal, zvi, hfinkel, dneilson Reviewed by: Ayal Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37702 llvm-svn: 313046
Diffstat (limited to 'llvm/test/Transforms/LoopVectorize')
-rw-r--r--llvm/test/Transforms/LoopVectorize/X86/vector_max_bandwidth.ll26
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/test/Transforms/LoopVectorize/X86/vector_max_bandwidth.ll b/llvm/test/Transforms/LoopVectorize/X86/vector_max_bandwidth.ll
index a32cc46e913..4e7880d09d6 100644
--- a/llvm/test/Transforms/LoopVectorize/X86/vector_max_bandwidth.ll
+++ b/llvm/test/Transforms/LoopVectorize/X86/vector_max_bandwidth.ll
@@ -46,3 +46,29 @@ for.body:
%exitcond = icmp eq i64 %indvars.iv.next, 1000
br i1 %exitcond, label %for.cond.cleanup, label %for.body
}
+
+; We should not choose a VF larger than the constant TC.
+; VF chosen should be atmost 16 (not the max possible vector width = 32 for AVX2)
+define void @not_too_small_tc(i8* noalias nocapture %A, i8* noalias nocapture readonly %B) {
+; CHECK-LABEL: not_too_small_tc
+; CHECK-AVX2: LV: Selecting VF: 16.
+entry:
+ br label %for.body
+
+for.body:
+ %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
+ %arrayidx = getelementptr inbounds i8, i8* %B, i64 %indvars.iv
+ %l1 = load i8, i8* %arrayidx, align 4, !llvm.mem.parallel_loop_access !3
+ %arrayidx2 = getelementptr inbounds i8, i8* %A, i64 %indvars.iv
+ %l2 = load i8, i8* %arrayidx2, align 4, !llvm.mem.parallel_loop_access !3
+ %add = add i8 %l1, %l2
+ store i8 %add, i8* %arrayidx2, align 4, !llvm.mem.parallel_loop_access !3
+ %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+ %exitcond = icmp eq i64 %indvars.iv.next, 16
+ br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !4
+
+for.end:
+ ret void
+}
+!3 = !{!3}
+!4 = !{!4}
OpenPOWER on IntegriCloud