[LoopVectorizer] Refine loop vectorizer's register usage calculator by ignoring speci...
[oota-llvm.git] / test / Transforms / LoopVectorize / no_outside_user.ll
1 ; RUN: opt -S -loop-vectorize -force-vector-interleave=1 -force-vector-width=2 < %s 2>&1 | FileCheck %s
2
3 ; CHECK: remark: {{.*}}: loop not vectorized: value could not be identified as an induction or reduction variable
4 ; CHECK: remark: {{.*}}: loop not vectorized: use of induction value outside of the loop is not handled by vectorizer
5
6 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
7
8 @f = common global i32 0, align 4
9 @.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
10 @c = common global i32 0, align 4
11 @a = common global i32 0, align 4
12 @b = common global i32 0, align 4
13 @e = common global i32 0, align 4
14
15 ; We used to vectorize this loop. But it has a value that is used outside of the
16 ; and is not a recognized reduction variable "tmp17".
17
18 ; CHECK-LABEL: @main(
19 ; CHECK-NOT: <2 x i32>
20
21 define i32 @main()  {
22 bb:
23   %b.promoted = load i32, i32* @b, align 4
24   br label %.lr.ph.i
25
26 .lr.ph.i:
27   %tmp8 = phi i32 [ %tmp18, %bb16 ], [ %b.promoted, %bb ]
28   %tmp2 = icmp sgt i32 %tmp8, 10
29   br i1 %tmp2, label %bb16, label %bb10
30
31 bb10:
32   br label %bb16
33
34 bb16:
35   %tmp17 = phi i32 [ 0, %bb10 ], [ 1, %.lr.ph.i ]
36   %tmp18 = add nsw i32 %tmp8, 1
37   %tmp19 = icmp slt i32 %tmp18, 4
38   br i1 %tmp19, label %.lr.ph.i, label %f1.exit.loopexit
39
40 f1.exit.loopexit:
41   %.lcssa = phi i32 [ %tmp17, %bb16 ]
42   ret i32 %.lcssa
43 }
44
45 ; Don't vectorize this loop. Its phi node (induction variable) has an outside
46 ; loop user. We currently don't handle this case.
47 ; PR17179
48
49 ; CHECK-LABEL: @test2(
50 ; CHECK-NOT:  <2 x
51
52 @x1 = common global i32 0, align 4
53 @x2 = common global i32 0, align 4
54 @x0 = common global i32 0, align 4
55
56 define i32 @test2()  {
57 entry:
58   store i32 0, i32* @x1, align 4
59   %0 = load i32, i32* @x0, align 4
60   br label %for.cond1.preheader
61
62 for.cond1.preheader:
63   %inc7 = phi i32 [ 0, %entry ], [ %inc, %for.cond1.preheader ]
64   %inc = add nsw i32 %inc7, 1
65   %cmp = icmp eq i32 %inc, 52
66   br i1 %cmp, label %for.end5, label %for.cond1.preheader
67
68 for.end5:
69   %inc7.lcssa = phi i32 [ %inc7, %for.cond1.preheader ]
70   %xor = xor i32 %inc7.lcssa, %0
71   store i32 52, i32* @x1, align 4
72   store i32 1, i32* @x2, align 4
73   ret i32 %xor
74 }