diff options
author | Thomas Lively <tlively@google.com> | 2018-10-19 21:11:43 +0000 |
---|---|---|
committer | Thomas Lively <tlively@google.com> | 2018-10-19 21:11:43 +0000 |
commit | 8a91cf1cc511d9f7a9a46b807982615cf548f911 (patch) | |
tree | dbe000dc6abb4852e80576031ea464e13237d953 /llvm/test/Transforms/LoopVectorize/intrinsic.ll | |
parent | f95f763ea59372eab87dcd03f6746f1987af9889 (diff) | |
download | bcm5719-llvm-8a91cf1cc511d9f7a9a46b807982615cf548f911.tar.gz bcm5719-llvm-8a91cf1cc511d9f7a9a46b807982615cf548f911.zip |
[LoopVectorize] Loop vectorization for minimum and maximum
Summary: Depends on D52766.
Reviewers: aheejin, dschuff
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D52767
llvm-svn: 344816
Diffstat (limited to 'llvm/test/Transforms/LoopVectorize/intrinsic.ll')
-rw-r--r-- | llvm/test/Transforms/LoopVectorize/intrinsic.ll | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/llvm/test/Transforms/LoopVectorize/intrinsic.ll b/llvm/test/Transforms/LoopVectorize/intrinsic.ll index 178d602e7f3..203c4435c88 100644 --- a/llvm/test/Transforms/LoopVectorize/intrinsic.ll +++ b/llvm/test/Transforms/LoopVectorize/intrinsic.ll @@ -1247,3 +1247,59 @@ for.body: ; preds = %entry, %for.body for.end: ; preds = %for.body, %entry ret void } + +declare float @llvm.minimum.f32(float, float) nounwind readnone + +;CHECK-LABEL: @minimum_f32( +;CHECK: llvm.minimum.v4f32 +;CHECK: ret void +define void @minimum_f32(i32 %n, float* noalias %y, float* noalias %x, float* noalias %z) nounwind uwtable { +entry: + %cmp9 = icmp sgt i32 %n, 0 + br i1 %cmp9, label %for.body, label %for.end + +for.body: ; preds = %entry, %for.body + %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ] + %arrayidx = getelementptr inbounds float, float* %y, i64 %indvars.iv + %0 = load float, float* %arrayidx, align 4 + %arrayidx2 = getelementptr inbounds float, float* %z, i64 %indvars.iv + %1 = load float, float* %arrayidx2, align 4 + %call = tail call float @llvm.minimum.f32(float %0, float %1) nounwind readnone + %arrayidx4 = getelementptr inbounds float, float* %x, i64 %indvars.iv + store float %call, float* %arrayidx4, align 4 + %indvars.iv.next = add i64 %indvars.iv, 1 + %lftr.wideiv = trunc i64 %indvars.iv.next to i32 + %exitcond = icmp eq i32 %lftr.wideiv, %n + br i1 %exitcond, label %for.end, label %for.body + +for.end: ; preds = %for.body, %entry + ret void +} + +declare float @llvm.maximum.f32(float, float) nounwind readnone + +;CHECK-LABEL: @maximum_f32( +;CHECK: llvm.maximum.v4f32 +;CHECK: ret void +define void @maximum_f32(i32 %n, float* noalias %y, float* noalias %x, float* noalias %z) nounwind uwtable { +entry: + %cmp9 = icmp sgt i32 %n, 0 + br i1 %cmp9, label %for.body, label %for.end + +for.body: ; preds = %entry, %for.body + %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ] + %arrayidx = getelementptr inbounds float, float* %y, i64 %indvars.iv + %0 = load float, float* %arrayidx, align 4 + %arrayidx2 = getelementptr inbounds float, float* %z, i64 %indvars.iv + %1 = load float, float* %arrayidx2, align 4 + %call = tail call float @llvm.maximum.f32(float %0, float %1) nounwind readnone + %arrayidx4 = getelementptr inbounds float, float* %x, i64 %indvars.iv + store float %call, float* %arrayidx4, align 4 + %indvars.iv.next = add i64 %indvars.iv, 1 + %lftr.wideiv = trunc i64 %indvars.iv.next to i32 + %exitcond = icmp eq i32 %lftr.wideiv, %n + br i1 %exitcond, label %for.end, label %for.body + +for.end: ; preds = %for.body, %entry + ret void +} |