1 ; RUN: opt < %s -scalable-vectorization=on -force-target-supports-scalable-vectors=true -loop-vectorize -force-vector-width=2 -force-vector-interleave=2 -S | FileCheck %s
3 define void @test1(float* noalias nocapture %a, float* noalias nocapture readonly %b) {
6 ; CHECK: [[FCMP1:%.*]] = fcmp ogt <vscale x 2 x float>
7 ; CHECK-NEXT: [[FCMP2:%.*]] = fcmp ogt <vscale x 2 x float>
8 ; CHECK-NEXT: [[FCMP1L0:%.*]] = extractelement <vscale x 2 x i1> [[FCMP1]], i32 0
9 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[FCMP1L0]])
10 ; CHECK-NEXT: [[FCMP2L0:%.*]] = extractelement <vscale x 2 x i1> [[FCMP2]], i32 0
11 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[FCMP2L0]])
15 for.body: ; preds = %for.body, %entry
16 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
17 %arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv
18 %0 = load float, float* %arrayidx, align 4
19 %cmp1 = fcmp ogt float %0, 1.000000e+02
20 tail call void @llvm.assume(i1 %cmp1)
21 %add = fadd float %0, 1.000000e+00
22 %arrayidx5 = getelementptr inbounds float, float* %a, i64 %indvars.iv
23 store float %add, float* %arrayidx5, align 4
24 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
25 %exitcond = icmp eq i64 %indvars.iv, 1599
26 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !0
28 for.end: ; preds = %for.body
32 declare void @llvm.assume(i1) #0
34 attributes #0 = { nounwind willreturn }
36 %struct.data = type { float*, float* }
38 define void @test2(float *%a, float *%b) {
39 ; CHECK-LABEL: @test2(
41 ; CHECK: [[MASKCOND:%.*]] = icmp eq i64 %ptrint1, 0
42 ; CHECK: [[MASKCOND4:%.*]] = icmp eq i64 %ptrint2, 0
44 ; CHECK: tail call void @llvm.assume(i1 [[MASKCOND]])
45 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[MASKCOND]])
46 ; CHECK: tail call void @llvm.assume(i1 [[MASKCOND4]])
47 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[MASKCOND4]])
49 %ptrint1 = ptrtoint float* %a to i64
50 %maskcond = icmp eq i64 %ptrint1, 0
51 %ptrint2 = ptrtoint float* %b to i64
52 %maskcond4 = icmp eq i64 %ptrint2, 0
56 for.body: ; preds = %for.body, %entry
57 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
58 tail call void @llvm.assume(i1 %maskcond)
59 %arrayidx = getelementptr inbounds float, float* %a, i64 %indvars.iv
60 %0 = load float, float* %arrayidx, align 4
61 %add = fadd float %0, 1.000000e+00
62 tail call void @llvm.assume(i1 %maskcond4)
63 %arrayidx5 = getelementptr inbounds float, float* %b, i64 %indvars.iv
64 store float %add, float* %arrayidx5, align 4
65 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
66 %exitcond = icmp eq i64 %indvars.iv, 1599
67 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !0
69 for.end: ; preds = %for.body
73 ; Test case for PR43620. Make sure we can vectorize with predication in presence
74 ; of assume calls. For now, check that we drop all assumes in predicated blocks
76 define void @predicated_assume(float* noalias nocapture readonly %a, float* noalias nocapture %b, i64 %n) {
77 ; Check that the vector.body does not contain any assumes.
78 ; CHECK-LABEL: @predicated_assume(
80 ; CHECK-NOT: llvm.assume
85 for.body: ; preds = %for.body.preheader, %if.end5
86 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %if.end5 ]
87 %cmp1 = icmp ult i64 %indvars.iv, 495616
88 br i1 %cmp1, label %if.end5, label %if.else
90 if.else: ; preds = %for.body
91 %cmp2 = icmp ult i64 %indvars.iv, 991232
92 tail call void @llvm.assume(i1 %cmp2)
95 if.end5: ; preds = %for.body, %if.else
96 %x.0 = phi float [ 4.200000e+01, %if.else ], [ 2.300000e+01, %for.body ]
97 %arrayidx = getelementptr inbounds float, float* %a, i64 %indvars.iv
98 %0 = load float, float* %arrayidx, align 4
99 %mul = fmul float %x.0, %0
100 %arrayidx7 = getelementptr inbounds float, float* %b, i64 %indvars.iv
101 store float %mul, float* %arrayidx7, align 4
102 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
103 %cmp = icmp eq i64 %indvars.iv.next, %n
104 br i1 %cmp, label %for.cond.cleanup, label %for.body, !llvm.loop !0
106 for.cond.cleanup: ; preds = %if.end5, %entry
110 !0 = distinct !{!0, !1}
111 !1 = !{!"llvm.loop.vectorize.scalable.enable", i1 true}