1; RUN: opt -S -loop-vectorize < %s 2>&1 -pass-remarks-analysis=.* | FileCheck %s
2
3; Test the optimization remark emitter for recognition
4; of a mathlib function vs. an arbitrary function.
5
6target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
7target triple = "x86_64-apple-macosx10.14.0"
8@data = external local_unnamed_addr global [32768 x float], align 16
9
10; CHECK: loop not vectorized: library call cannot be vectorized
11
12define void @libcall_blocks_vectorization() {
13entry:
14  br label %for.body
15
16for.cond.cleanup:
17  ret void
18
19for.body:
20  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
21  %arrayidx = getelementptr inbounds [32768 x float], [32768 x float]* @data, i64 0, i64 %indvars.iv
22  %t0 = load float, float* %arrayidx, align 4
23  %sqrtf = tail call float @sqrtf(float %t0)
24  store float %sqrtf, float* %arrayidx, align 4
25  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
26  %exitcond = icmp eq i64 %indvars.iv.next, 32768
27  br i1 %exitcond, label %for.cond.cleanup, label %for.body
28}
29
30; CHECK: loop not vectorized: call instruction cannot be vectorized
31
32define void @arbitrary_call_blocks_vectorization() {
33entry:
34  br label %for.body
35
36for.cond.cleanup:
37  ret void
38
39for.body:
40  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
41  %arrayidx = getelementptr inbounds [32768 x float], [32768 x float]* @data, i64 0, i64 %indvars.iv
42  %t0 = load float, float* %arrayidx, align 4
43  %sqrtf = tail call float @arbitrary(float %t0)
44  store float %sqrtf, float* %arrayidx, align 4
45  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
46  %exitcond = icmp eq i64 %indvars.iv.next, 32768
47  br i1 %exitcond, label %for.cond.cleanup, label %for.body
48}
49
50declare float @sqrtf(float)
51declare float @arbitrary(float)
52
53