1 ; RUN: opt < %s -passes=loop-vectorize -force-vector-width=2 -force-vector-interleave=2 -S | FileCheck %s
3 define void @test1(ptr noalias nocapture %a, ptr noalias nocapture readonly %b) {
6 ; CHECK: [[WIDE_LOAD:%.*]] = load <2 x float>, ptr {{.*}}, align 4
7 ; CHECK: [[WIDE_LOAD1:%.*]] = load <2 x float>, ptr {{.*}}, align 4
8 ; CHECK-NEXT: [[TMP1:%.*]] = fcmp ogt <2 x float> [[WIDE_LOAD]], <float 1.000000e+02, float 1.000000e+02>
9 ; CHECK-NEXT: [[TMP2:%.*]] = fcmp ogt <2 x float> [[WIDE_LOAD1]], <float 1.000000e+02, float 1.000000e+02>
10 ; CHECK-NEXT: [[TMP3:%.*]] = extractelement <2 x i1> [[TMP1]], i32 0
11 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP3]])
12 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i1> [[TMP1]], i32 1
13 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP4]])
14 ; CHECK-NEXT: [[TMP5:%.*]] = extractelement <2 x i1> [[TMP2]], i32 0
15 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP5]])
16 ; CHECK-NEXT: [[TMP6:%.*]] = extractelement <2 x i1> [[TMP2]], i32 1
17 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP6]])
21 for.body: ; preds = %for.body, %entry
22 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
23 %arrayidx = getelementptr inbounds float, ptr %b, i64 %indvars.iv
24 %0 = load float, ptr %arrayidx, align 4
25 %cmp1 = fcmp ogt float %0, 1.000000e+02
26 tail call void @llvm.assume(i1 %cmp1)
27 %add = fadd float %0, 1.000000e+00
28 %arrayidx5 = getelementptr inbounds float, ptr %a, i64 %indvars.iv
29 store float %add, ptr %arrayidx5, align 4
30 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
31 %exitcond = icmp eq i64 %indvars.iv, 1599
32 br i1 %exitcond, label %for.end, label %for.body
34 for.end: ; preds = %for.body
38 declare void @llvm.assume(i1) #0
40 attributes #0 = { nounwind willreturn }
42 %struct.data = type { ptr, ptr }
44 define void @test2(ptr nocapture readonly %d) {
45 ; CHECK-LABEL: @test2(
47 ; CHECK: [[MASKCOND:%.*]] = icmp eq i64 %maskedptr, 0
48 ; CHECK: [[MASKCOND4:%.*]] = icmp eq i64 %maskedptr3, 0
50 ; CHECK: tail call void @llvm.assume(i1 [[MASKCOND]])
51 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[MASKCOND]])
52 ; CHECK: tail call void @llvm.assume(i1 [[MASKCOND4]])
53 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[MASKCOND4]])
56 %b = getelementptr inbounds %struct.data, ptr %d, i64 0, i32 1
57 %0 = load ptr, ptr %b, align 8
58 %ptrint = ptrtoint ptr %0 to i64
59 %maskedptr = and i64 %ptrint, 31
60 %maskcond = icmp eq i64 %maskedptr, 0
61 %1 = load ptr, ptr %d, align 8
62 %ptrint2 = ptrtoint ptr %1 to i64
63 %maskedptr3 = and i64 %ptrint2, 31
64 %maskcond4 = icmp eq i64 %maskedptr3, 0
68 for.body: ; preds = %for.body, %entry
69 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
70 tail call void @llvm.assume(i1 %maskcond)
71 %arrayidx = getelementptr inbounds float, ptr %0, i64 %indvars.iv
72 %2 = load float, ptr %arrayidx, align 4
73 %add = fadd float %2, 1.000000e+00
74 tail call void @llvm.assume(i1 %maskcond4)
75 %arrayidx5 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
76 store float %add, ptr %arrayidx5, align 4
77 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
78 %exitcond = icmp eq i64 %indvars.iv, 1599
79 br i1 %exitcond, label %for.end, label %for.body
81 for.end: ; preds = %for.body
85 ; Test case for PR43620. Make sure we can vectorize with predication in presence
86 ; of assume calls. For now, check that we drop all assumes in predicated blocks
88 define void @predicated_assume(ptr noalias nocapture readonly %a, ptr noalias nocapture %b, i32 %n) {
89 ; Check that the vector.body does not contain any assumes.
90 ; CHECK-LABEL: @predicated_assume(
92 ; CHECK-NOT: llvm.assume
95 %cmp15 = icmp eq i32 %n, 0
96 br i1 %cmp15, label %for.cond.cleanup, label %for.body.preheader
98 for.body.preheader: ; preds = %entry
99 %0 = zext i32 %n to i64
102 for.cond.cleanup.loopexit: ; preds = %if.end5
103 br label %for.cond.cleanup
105 for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry
108 for.body: ; preds = %for.body.preheader, %if.end5
109 %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %if.end5 ]
110 %cmp1 = icmp ult i64 %indvars.iv, 495616
111 br i1 %cmp1, label %if.end5, label %if.else
113 if.else: ; preds = %for.body
114 %cmp2 = icmp ult i64 %indvars.iv, 991232
115 tail call void @llvm.assume(i1 %cmp2)
118 if.end5: ; preds = %for.body, %if.else
119 %x.0 = phi float [ 4.200000e+01, %if.else ], [ 2.300000e+01, %for.body ]
120 %arrayidx = getelementptr inbounds float, ptr %a, i64 %indvars.iv
121 %1 = load float, ptr %arrayidx, align 4
122 %mul = fmul float %x.0, %1
123 %arrayidx7 = getelementptr inbounds float, ptr %b, i64 %indvars.iv
124 store float %mul, ptr %arrayidx7, align 4
125 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
126 %cmp = icmp eq i64 %indvars.iv.next, %0
127 br i1 %cmp, label %for.cond.cleanup.loopexit, label %for.body