Implement X86TTI::getUnrollingPreferences
[oota-llvm.git] / test / Transforms / LoopVectorize / X86 / metadata-enable.ll
1 ; RUN: opt < %s -mcpu=corei7 -O1 -S -x86-use-partial-unrolling=0 | FileCheck %s --check-prefix=O1
2 ; RUN: opt < %s -mcpu=corei7 -O2 -S -x86-use-partial-unrolling=0 | FileCheck %s --check-prefix=O2
3 ; RUN: opt < %s -mcpu=corei7 -O3 -S -x86-use-partial-unrolling=0 | FileCheck %s --check-prefix=O3
4 ; RUN: opt < %s -mcpu=corei7 -Os -S -x86-use-partial-unrolling=0 | FileCheck %s --check-prefix=Os
5 ; RUN: opt < %s -mcpu=corei7 -Oz -S -x86-use-partial-unrolling=0 | FileCheck %s --check-prefix=Oz
6 ; RUN: opt < %s -mcpu=corei7 -O1 -vectorize-loops -S -x86-use-partial-unrolling=0 | FileCheck %s --check-prefix=O1VEC
7 ; RUN: opt < %s -mcpu=corei7 -Oz -vectorize-loops -S -x86-use-partial-unrolling=0 | FileCheck %s --check-prefix=OzVEC
8 ; RUN: opt < %s -mcpu=corei7 -O1 -loop-vectorize -S -x86-use-partial-unrolling=0 | FileCheck %s --check-prefix=O1VEC2
9 ; RUN: opt < %s -mcpu=corei7 -Oz -loop-vectorize -S -x86-use-partial-unrolling=0 | FileCheck %s --check-prefix=OzVEC2
10 ; RUN: opt < %s -mcpu=corei7 -O3 -disable-loop-vectorization -S -x86-use-partial-unrolling=0 | FileCheck %s --check-prefix=O3DIS
11
12 ; This file tests the llvm.vectorizer.pragma forcing vectorization even when
13 ; optimization levels are too low, or when vectorization is disabled.
14
15 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
16 target triple = "x86_64-unknown-linux-gnu"
17
18 ; O1-LABEL: @enabled(
19 ; O1: store <4 x i32>
20 ; O1: ret i32
21 ; O2-LABEL: @enabled(
22 ; O2: store <4 x i32>
23 ; O2: ret i32
24 ; O3-LABEL: @enabled(
25 ; O3: store <4 x i32>
26 ; O3: ret i32
27 ; Pragma always wins!
28 ; O3DIS-LABEL: @enabled(
29 ; O3DIS: store <4 x i32>
30 ; O3DIS: ret i32
31 ; Os-LABEL: @enabled(
32 ; Os: store <4 x i32>
33 ; Os: ret i32
34 ; Oz-LABEL: @enabled(
35 ; Oz: store <4 x i32>
36 ; Oz: ret i32
37 ; O1VEC-LABEL: @enabled(
38 ; O1VEC: store <4 x i32>
39 ; O1VEC: ret i32
40 ; OzVEC-LABEL: @enabled(
41 ; OzVEC: store <4 x i32>
42 ; OzVEC: ret i32
43 ; O1VEC2-LABEL: @enabled(
44 ; O1VEC2: store <4 x i32>
45 ; O1VEC2: ret i32
46 ; OzVEC2-LABEL: @enabled(
47 ; OzVEC2: store <4 x i32>
48 ; OzVEC2: ret i32
49
50 define i32 @enabled(i32* noalias nocapture %a, i32* noalias nocapture readonly %b, i32 %N) {
51 entry:
52   br label %for.body
53
54 for.body:                                         ; preds = %for.body, %entry
55   %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
56   %arrayidx = getelementptr inbounds i32* %b, i64 %indvars.iv
57   %0 = load i32* %arrayidx, align 4
58   %add = add nsw i32 %0, %N
59   %arrayidx2 = getelementptr inbounds i32* %a, i64 %indvars.iv
60   store i32 %add, i32* %arrayidx2, align 4
61   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
62   %exitcond = icmp eq i64 %indvars.iv.next, 32
63   br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !0
64
65 for.end:                                          ; preds = %for.body
66   %1 = load i32* %a, align 4
67   ret i32 %1
68 }
69
70 ; O1-LABEL: @nopragma(
71 ; O1-NOT: store <4 x i32>
72 ; O1: ret i32
73 ; O2-LABEL: @nopragma(
74 ; O2: store <4 x i32>
75 ; O2: ret i32
76 ; O3-LABEL: @nopragma(
77 ; O3: store <4 x i32>
78 ; O3: ret i32
79 ; O3DIS-LABEL: @nopragma(
80 ; O3DIS-NOT: store <4 x i32>
81 ; O3DIS: ret i32
82 ; Os-LABEL: @nopragma(
83 ; Os: store <4 x i32>
84 ; Os: ret i32
85 ; Oz-LABEL: @nopragma(
86 ; Oz-NOT: store <4 x i32>
87 ; Oz: ret i32
88 ; O1VEC-LABEL: @nopragma(
89 ; O1VEC: store <4 x i32>
90 ; O1VEC: ret i32
91 ; OzVEC-LABEL: @nopragma(
92 ; OzVEC: store <4 x i32>
93 ; OzVEC: ret i32
94 ; O1VEC2-LABEL: @nopragma(
95 ; O1VEC2: store <4 x i32>
96 ; O1VEC2: ret i32
97 ; OzVEC2-LABEL: @nopragma(
98 ; OzVEC2: store <4 x i32>
99 ; OzVEC2: ret i32
100
101 define i32 @nopragma(i32* noalias nocapture %a, i32* noalias nocapture readonly %b, i32 %N) {
102 entry:
103   br label %for.body
104
105 for.body:                                         ; preds = %for.body, %entry
106   %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
107   %arrayidx = getelementptr inbounds i32* %b, i64 %indvars.iv
108   %0 = load i32* %arrayidx, align 4
109   %add = add nsw i32 %0, %N
110   %arrayidx2 = getelementptr inbounds i32* %a, i64 %indvars.iv
111   store i32 %add, i32* %arrayidx2, align 4
112   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
113   %exitcond = icmp eq i64 %indvars.iv.next, 32
114   br i1 %exitcond, label %for.end, label %for.body
115
116 for.end:                                          ; preds = %for.body
117   %1 = load i32* %a, align 4
118   ret i32 %1
119 }
120
121 ; O1-LABEL: @disabled(
122 ; O1-NOT: store <4 x i32>
123 ; O1: ret i32
124 ; O2-LABEL: @disabled(
125 ; O2-NOT: store <4 x i32>
126 ; O2: ret i32
127 ; O3-LABEL: @disabled(
128 ; O3-NOT: store <4 x i32>
129 ; O3: ret i32
130 ; O3DIS-LABEL: @disabled(
131 ; O3DIS-NOT: store <4 x i32>
132 ; O3DIS: ret i32
133 ; Os-LABEL: @disabled(
134 ; Os-NOT: store <4 x i32>
135 ; Os: ret i32
136 ; Oz-LABEL: @disabled(
137 ; Oz-NOT: store <4 x i32>
138 ; Oz: ret i32
139 ; O1VEC-LABEL: @disabled(
140 ; O1VEC-NOT: store <4 x i32>
141 ; O1VEC: ret i32
142 ; OzVEC-LABEL: @disabled(
143 ; OzVEC-NOT: store <4 x i32>
144 ; OzVEC: ret i32
145 ; O1VEC2-LABEL: @disabled(
146 ; O1VEC2-NOT: store <4 x i32>
147 ; O1VEC2: ret i32
148 ; OzVEC2-LABEL: @disabled(
149 ; OzVEC2-NOT: store <4 x i32>
150 ; OzVEC2: ret i32
151
152 define i32 @disabled(i32* noalias nocapture %a, i32* noalias nocapture readonly %b, i32 %N) {
153 entry:
154   br label %for.body
155
156 for.body:                                         ; preds = %for.body, %entry
157   %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
158   %arrayidx = getelementptr inbounds i32* %b, i64 %indvars.iv
159   %0 = load i32* %arrayidx, align 4
160   %add = add nsw i32 %0, %N
161   %arrayidx2 = getelementptr inbounds i32* %a, i64 %indvars.iv
162   store i32 %add, i32* %arrayidx2, align 4
163   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
164   %exitcond = icmp eq i64 %indvars.iv.next, 32
165   br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !2
166
167 for.end:                                          ; preds = %for.body
168   %1 = load i32* %a, align 4
169   ret i32 %1
170 }
171
172 !0 = metadata !{metadata !0, metadata !1}
173 !1 = metadata !{metadata !"llvm.vectorizer.enable", i1 1}
174 !2 = metadata !{metadata !2, metadata !3}
175 !3 = metadata !{metadata !"llvm.vectorizer.enable", i1 0}