diff options
| author | Michael Zolotukhin <mzolotukhin@apple.com> | 2015-06-24 17:26:24 +0000 |
|---|---|---|
| committer | Michael Zolotukhin <mzolotukhin@apple.com> | 2015-06-24 17:26:24 +0000 |
| commit | 79ff564ef356de75e4d430a88c30cddc286c6e02 (patch) | |
| tree | 265d56318be0bb91c9077082533da37676d3b749 /llvm | |
| parent | 8454044b1f62ee4ec16d4d13ac92d4fbd98b19e7 (diff) | |
| download | bcm5719-llvm-79ff564ef356de75e4d430a88c30cddc286c6e02.tar.gz bcm5719-llvm-79ff564ef356de75e4d430a88c30cddc286c6e02.zip | |
[LoopVectorizer] Fix bailing-out condition for OptForSize case.
With option OptForSize enabled, the Loop Vectorizer is not supposed to
create tail loop. The condition checking that was invalid and was not
matching to the comment above.
Patch by Marianne Mailhot-Sarrasin.
llvm-svn: 240556
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 7 | ||||
| -rw-r--r-- | llvm/test/Transforms/LoopVectorize/optsize.ll | 34 |
2 files changed, 37 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index d9a38844b50..7e21002e074 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -4642,10 +4642,9 @@ LoopVectorizationCostModel::selectVectorizationFactor(bool OptForSize) { if (VF == 0) VF = MaxVectorSize; - - // If the trip count that we found modulo the vectorization factor is not - // zero then we require a tail. - if (VF < 2) { + else { + // If the trip count that we found modulo the vectorization factor is not + // zero then we require a tail. emitAnalysis(VectorizationReport() << "cannot optimize for size and vectorize at the " "same time. Enable vectorization of this loop " diff --git a/llvm/test/Transforms/LoopVectorize/optsize.ll b/llvm/test/Transforms/LoopVectorize/optsize.ll new file mode 100644 index 00000000000..e183fda099a --- /dev/null +++ b/llvm/test/Transforms/LoopVectorize/optsize.ll @@ -0,0 +1,34 @@ +; This test verifies that the loop vectorizer will NOT produce a tail +; loop with Optimize for size attibute. +; REQUIRES: asserts +; RUN: opt < %s -loop-vectorize -Os -debug -debug-only=loop-vectorize -S 2>&1 | FileCheck %s + +;CHECK-NOT: <2 x i8> +;CHECK-NOT: <4 x i8> +;CHECK: Aborting. A tail loop is required in Os. + +target datalayout = "E-m:e-p:32:32-i64:32-f64:32:64-a:0:32-n32-S128" + +@tab = common global [32 x i8] zeroinitializer, align 1 + +; Function Attrs: nounwind optsize +define i32 @foo() #0 { +entry: + br label %for.body + +for.body: ; preds = %for.body, %entry + %i.08 = phi i32 [ 0, %entry ], [ %inc, %for.body ] + %arrayidx = getelementptr inbounds [32 x i8], [32 x i8]* @tab, i32 0, i32 %i.08 + %0 = load i8, i8* %arrayidx, align 1 + %cmp1 = icmp eq i8 %0, 0 + %. = select i1 %cmp1, i8 2, i8 1 + store i8 %., i8* %arrayidx, align 1 + %inc = add nsw i32 %i.08, 1 + %exitcond = icmp eq i32 %i.08, 202 + br i1 %exitcond, label %for.end, label %for.body + +for.end: ; preds = %for.body + ret i32 0 +} + +attributes #0 = { nounwind optsize "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |

