summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/LoopVectorize/reduction-small-size.ll
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@codeaurora.org>2018-02-04 15:42:24 +0000
committerChad Rosier <mcrosier@codeaurora.org>2018-02-04 15:42:24 +0000
commita097bc69df64cede9d0eb94441aa57f8ef7d9777 (patch)
treea97f03320d124fe55cf73d565fac603f995dc29d /llvm/test/Transforms/LoopVectorize/reduction-small-size.ll
parentc6b3c7bb635352c7d228140ed0816befe2096944 (diff)
downloadbcm5719-llvm-a097bc69df64cede9d0eb94441aa57f8ef7d9777.tar.gz
bcm5719-llvm-a097bc69df64cede9d0eb94441aa57f8ef7d9777.zip
[LV] Use Demanded Bits and ValueTracking for reduction type-shrinking
The type-shrinking logic in reduction detection, although narrow in scope, is also rather ad-hoc, which has led to bugs (e.g., PR35734). This patch modifies the approach to rely on the demanded bits and value tracking analyses, if available. We currently perform type-shrinking separately for reductions and other instructions in the loop. Long-term, we should probably think about computing minimal bit widths in a more complete way for the loops we want to vectorize. PR35734 Differential Revision: https://reviews.llvm.org/D42309 llvm-svn: 324195
Diffstat (limited to 'llvm/test/Transforms/LoopVectorize/reduction-small-size.ll')
-rw-r--r--llvm/test/Transforms/LoopVectorize/reduction-small-size.ll37
1 files changed, 35 insertions, 2 deletions
diff --git a/llvm/test/Transforms/LoopVectorize/reduction-small-size.ll b/llvm/test/Transforms/LoopVectorize/reduction-small-size.ll
index b44beb8ce68..879f1c3c5ad 100644
--- a/llvm/test/Transforms/LoopVectorize/reduction-small-size.ll
+++ b/llvm/test/Transforms/LoopVectorize/reduction-small-size.ll
@@ -14,7 +14,7 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
; CHECK-NEXT: [[TMP17]] = zext <4 x i8> [[TMP16]] to <4 x i32>
; CHECK-NEXT: br i1 {{.*}}, label %middle.block, label %vector.body
;
-define void @PR34687(i1 %c, i32 %x, i32 %n) {
+define i8 @PR34687(i1 %c, i32 %x, i32 %n) {
entry:
br label %for.body
@@ -36,5 +36,38 @@ if.end:
for.end:
%tmp2 = phi i32 [ %r.next, %if.end ]
- ret void
+ %tmp3 = trunc i32 %tmp2 to i8
+ ret i8 %tmp3
+}
+
+; CHECK-LABEL: @PR35734(
+; CHECK: vector.ph:
+; CHECK: [[TMP3:%.*]] = insertelement <4 x i32> zeroinitializer, i32 %y, i32 0
+; CHECK-NEXT: br label %vector.body
+; CHECK: vector.body:
+; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
+; CHECK-NEXT: [[VEC_PHI:%.*]] = phi <4 x i32> [ [[TMP3]], %vector.ph ], [ [[TMP9:%.*]], %vector.body ]
+; CHECK: [[TMP5:%.*]] = and <4 x i32> [[VEC_PHI]], <i32 1, i32 1, i32 1, i32 1>
+; CHECK-NEXT: [[TMP6:%.*]] = add <4 x i32> [[TMP5]], <i32 -1, i32 -1, i32 -1, i32 -1>
+; CHECK-NEXT: [[INDEX_NEXT]] = add i32 [[INDEX]], 4
+; CHECK: [[TMP8:%.*]] = trunc <4 x i32> [[TMP6]] to <4 x i1>
+; CHECK-NEXT: [[TMP9]] = sext <4 x i1> [[TMP8]] to <4 x i32>
+; CHECK-NEXT: br i1 {{.*}}, label %middle.block, label %vector.body
+;
+define i32 @PR35734(i32 %x, i32 %y) {
+entry:
+ br label %for.body
+
+for.body:
+ %i = phi i32 [ %x, %entry ], [ %i.next, %for.body ]
+ %r = phi i32 [ %y, %entry ], [ %r.next, %for.body ]
+ %tmp0 = and i32 %r, 1
+ %r.next = add i32 %tmp0, -1
+ %i.next = add nsw i32 %i, 1
+ %cond = icmp sgt i32 %i, 77
+ br i1 %cond, label %for.end, label %for.body
+
+for.end:
+ %tmp1 = phi i32 [ %r.next, %for.body ]
+ ret i32 %tmp1
}
OpenPOWER on IntegriCloud