1 ; RUN: opt < %s -mcpu=corei7 -O1 -S | FileCheck %s --check-prefix=O1
2 ; RUN: opt < %s -mcpu=corei7 -O2 -S | FileCheck %s --check-prefix=O2
3 ; RUN: opt < %s -mcpu=corei7 -O3 -S | FileCheck %s --check-prefix=O3
4 ; RUN: opt < %s -mcpu=corei7 -Os -S | FileCheck %s --check-prefix=Os
5 ; RUN: opt < %s -mcpu=corei7 -Oz -S | FileCheck %s --check-prefix=Oz
6 ; RUN: opt < %s -mcpu=corei7 -O1 -vectorize-loops -S | FileCheck %s --check-prefix=O1VEC
7 ; RUN: opt < %s -mcpu=corei7 -Oz -vectorize-loops -S | FileCheck %s --check-prefix=OzVEC
8 ; RUN: opt < %s -mcpu=corei7 -O1 -loop-vectorize -S | FileCheck %s --check-prefix=O1VEC2
9 ; RUN: opt < %s -mcpu=corei7 -Oz -loop-vectorize -S | FileCheck %s --check-prefix=OzVEC2
10 ; RUN: opt < %s -mcpu=corei7 -O3 -disable-loop-vectorization -S | FileCheck %s --check-prefix=O3DIS
12 ; This file tests the llvm.vectorizer.pragma forcing vectorization even when
13 ; optimization levels are too low, or when vectorization is disabled.
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"
28 ; O3DIS-LABEL: @enabled(
29 ; O3DIS: store <4 x i32>
37 ; O1VEC-LABEL: @enabled(
38 ; O1VEC: store <4 x i32>
40 ; OzVEC-LABEL: @enabled(
41 ; OzVEC: store <4 x i32>
43 ; O1VEC2-LABEL: @enabled(
44 ; O1VEC2: store <4 x i32>
46 ; OzVEC2-LABEL: @enabled(
47 ; OzVEC2: store <4 x i32>
50 define i32 @enabled(i32* noalias nocapture %a, i32* noalias nocapture readonly %b, i32 %N) {
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
65 for.end: ; preds = %for.body
66 %1 = load i32* %a, align 4
70 ; O1-LABEL: @nopragma(
71 ; O1-NOT: store <4 x i32>
73 ; O2-LABEL: @nopragma(
76 ; O3-LABEL: @nopragma(
79 ; O3DIS-LABEL: @nopragma(
80 ; O3DIS-NOT: store <4 x i32>
82 ; Os-LABEL: @nopragma(
85 ; Oz-LABEL: @nopragma(
86 ; Oz-NOT: store <4 x i32>
88 ; O1VEC-LABEL: @nopragma(
89 ; O1VEC: store <4 x i32>
91 ; OzVEC-LABEL: @nopragma(
92 ; OzVEC: store <4 x i32>
94 ; O1VEC2-LABEL: @nopragma(
95 ; O1VEC2: store <4 x i32>
97 ; OzVEC2-LABEL: @nopragma(
98 ; OzVEC2: store <4 x i32>
101 define i32 @nopragma(i32* noalias nocapture %a, i32* noalias nocapture readonly %b, i32 %N) {
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
116 for.end: ; preds = %for.body
117 %1 = load i32* %a, align 4
121 ; O1-LABEL: @disabled(
122 ; O1-NOT: store <4 x i32>
124 ; O2-LABEL: @disabled(
125 ; O2-NOT: store <4 x i32>
127 ; O3-LABEL: @disabled(
128 ; O3-NOT: store <4 x i32>
130 ; O3DIS-LABEL: @disabled(
131 ; O3DIS-NOT: store <4 x i32>
133 ; Os-LABEL: @disabled(
134 ; Os-NOT: store <4 x i32>
136 ; Oz-LABEL: @disabled(
137 ; Oz-NOT: store <4 x i32>
139 ; O1VEC-LABEL: @disabled(
140 ; O1VEC-NOT: store <4 x i32>
142 ; OzVEC-LABEL: @disabled(
143 ; OzVEC-NOT: store <4 x i32>
145 ; O1VEC2-LABEL: @disabled(
146 ; O1VEC2-NOT: store <4 x i32>
148 ; OzVEC2-LABEL: @disabled(
149 ; OzVEC2-NOT: store <4 x i32>
152 define i32 @disabled(i32* noalias nocapture %a, i32* noalias nocapture readonly %b, i32 %N) {
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
167 for.end: ; preds = %for.body
168 %1 = load i32* %a, align 4
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}