1; This test verifies that the loop vectorizer will NOT vectorize loops that
2; will produce a tail loop with the optimize for size or the minimize size
3; attributes. This is a target-dependent version of the test.
4; RUN: opt < %s -loop-vectorize -force-vector-width=64 -S -mtriple=x86_64-unknown-linux -mcpu=skx | FileCheck %s
5
6target datalayout = "E-m:e-p:32:32-i64:32-f64:32:64-a:0:32-n32-S128"
7
8@tab = common global [32 x i8] zeroinitializer, align 1
9
10define i32 @foo_optsize() #0 {
11; CHECK-LABEL: @foo_optsize(
12; CHECK-NOT: x i8>
13
14entry:
15  br label %for.body
16
17for.body:                                         ; preds = %for.body, %entry
18  %i.08 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
19  %arrayidx = getelementptr inbounds [32 x i8], [32 x i8]* @tab, i32 0, i32 %i.08
20  %0 = load i8, i8* %arrayidx, align 1
21  %cmp1 = icmp eq i8 %0, 0
22  %. = select i1 %cmp1, i8 2, i8 1
23  store i8 %., i8* %arrayidx, align 1
24  %inc = add nsw i32 %i.08, 1
25  %exitcond = icmp eq i32 %i.08, 202
26  br i1 %exitcond, label %for.end, label %for.body
27
28for.end:                                          ; preds = %for.body
29  ret i32 0
30}
31
32attributes #0 = { optsize }
33
34define i32 @foo_minsize() #1 {
35; CHECK-LABEL: @foo_minsize(
36; CHECK-NOT: x i8>
37
38entry:
39  br label %for.body
40
41for.body:                                         ; preds = %for.body, %entry
42  %i.08 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
43  %arrayidx = getelementptr inbounds [32 x i8], [32 x i8]* @tab, i32 0, i32 %i.08
44  %0 = load i8, i8* %arrayidx, align 1
45  %cmp1 = icmp eq i8 %0, 0
46  %. = select i1 %cmp1, i8 2, i8 1
47  store i8 %., i8* %arrayidx, align 1
48  %inc = add nsw i32 %i.08, 1
49  %exitcond = icmp eq i32 %i.08, 202
50  br i1 %exitcond, label %for.end, label %for.body
51
52for.end:                                          ; preds = %for.body
53  ret i32 0
54}
55
56attributes #1 = { minsize }
57
58