1 ; This test verifies that the loop vectorizer will NOT produce a tail
2 ; loop with the optimize for size or the minimize size attributes.
4 ; RUN: opt < %s -loop-vectorize -S | FileCheck %s
5 ; RUN: opt < %s -loop-vectorize -pgso -S | FileCheck %s -check-prefix=PGSO
6 ; RUN: opt < %s -loop-vectorize -pgso=false -S | FileCheck %s -check-prefix=NPGSO
8 target datalayout = "E-m:e-p:32:32-i64:32-f64:32:64-a:0:32-n32-S128"
10 @tab = common global [32 x i8] zeroinitializer, align 1
12 define i32 @foo_optsize() #0 {
13 ; CHECK-LABEL: @foo_optsize(
20 for.body: ; preds = %for.body, %entry
21 %i.08 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
22 %arrayidx = getelementptr inbounds [32 x i8], [32 x i8]* @tab, i32 0, i32 %i.08
23 %0 = load i8, i8* %arrayidx, align 1
24 %cmp1 = icmp eq i8 %0, 0
25 %. = select i1 %cmp1, i8 2, i8 1
26 store i8 %., i8* %arrayidx, align 1
27 %inc = add nsw i32 %i.08, 1
28 %exitcond = icmp eq i32 %i.08, 202
29 br i1 %exitcond, label %for.end, label %for.body
31 for.end: ; preds = %for.body
35 attributes #0 = { optsize }
37 define i32 @foo_minsize() #1 {
38 ; CHECK-LABEL: @foo_minsize(
41 ; CHECK-LABEL: @foo_pgso(
46 for.body: ; preds = %for.body, %entry
47 %i.08 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
48 %arrayidx = getelementptr inbounds [32 x i8], [32 x i8]* @tab, i32 0, i32 %i.08
49 %0 = load i8, i8* %arrayidx, align 1
50 %cmp1 = icmp eq i8 %0, 0
51 %. = select i1 %cmp1, i8 2, i8 1
52 store i8 %., i8* %arrayidx, align 1
53 %inc = add nsw i32 %i.08, 1
54 %exitcond = icmp eq i32 %i.08, 202
55 br i1 %exitcond, label %for.end, label %for.body
57 for.end: ; preds = %for.body
61 attributes #1 = { minsize }
63 define i32 @foo_pgso() !prof !14 {
64 ; PGSO-LABEL: @foo_pgso(
65 ; PGSO-NOT: <{{[0-9]+}} x i8>
66 ; NPGSO-LABEL: @foo_pgso(
67 ; NPGSO: <{{[0-9]+}} x i8>
72 for.body: ; preds = %for.body, %entry
73 %i.08 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
74 %arrayidx = getelementptr inbounds [32 x i8], [32 x i8]* @tab, i32 0, i32 %i.08
75 %0 = load i8, i8* %arrayidx, align 1
76 %cmp1 = icmp eq i8 %0, 0
77 %. = select i1 %cmp1, i8 2, i8 1
78 store i8 %., i8* %arrayidx, align 1
79 %inc = add nsw i32 %i.08, 1
80 %exitcond = icmp eq i32 %i.08, 202
81 br i1 %exitcond, label %for.end, label %for.body
83 for.end: ; preds = %for.body
87 ; PR43371: don't run into an assert due to emitting SCEV runtime checks
90 @cm_array = external global [2592 x i16], align 1
92 define void @pr43371() optsize {
94 ; CHECK-LABEL: @pr43371
95 ; CHECK-NOT: vector.scevcheck
97 ; We do not want to generate SCEV predicates when optimising for size, because
98 ; that will lead to extra code generation such as the SCEV overflow runtime
99 ; checks. Not generating SCEV predicates can still result in vectorisation as
100 ; the non-consecutive loads/stores can be scalarized:
102 ; CHECK: vector.body:
103 ; CHECK: store i16 0, i16* %{{.*}}, align 1
104 ; CHECK: store i16 0, i16* %{{.*}}, align 1
105 ; CHECK: br i1 {{.*}}, label %vector.body
114 %i24.0170 = phi i16 [ 0, %entry], [ %inc37, %for.body29]
115 %add33 = add i16 undef, %i24.0170
116 %idxprom34 = zext i16 %add33 to i32
117 %arrayidx35 = getelementptr [2592 x i16], [2592 x i16] * @cm_array, i32 0, i32 %idxprom34
118 store i16 0, i16 * %arrayidx35, align 1
119 %inc37 = add i16 %i24.0170, 1
120 %cmp26 = icmp ult i16 %inc37, 756
121 br i1 %cmp26, label %for.body29, label %for.cond.cleanup28
124 !llvm.module.flags = !{!0}
125 !0 = !{i32 1, !"ProfileSummary", !1}
126 !1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
127 !2 = !{!"ProfileFormat", !"InstrProf"}
128 !3 = !{!"TotalCount", i64 10000}
129 !4 = !{!"MaxCount", i64 10}
130 !5 = !{!"MaxInternalCount", i64 1}
131 !6 = !{!"MaxFunctionCount", i64 1000}
132 !7 = !{!"NumCounts", i64 3}
133 !8 = !{!"NumFunctions", i64 3}
134 !9 = !{!"DetailedSummary", !10}
135 !10 = !{!11, !12, !13}
136 !11 = !{i32 10000, i64 100, i32 1}
137 !12 = !{i32 999000, i64 100, i32 1}
138 !13 = !{i32 999999, i64 1, i32 2}
139 !14 = !{!"function_entry_count", i64 0}