1 ; RUN: opt < %s -passes=loop-vectorize -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx -debug-only=loop-vectorize -stats -S 2>&1 | FileCheck %s
4 ; CHECK: LV: Loop hints: force=enabled
5 ; CHECK: LV: Loop hints: force=?
6 ; No more loops in the module
7 ; CHECK-NOT: LV: Loop hints: force=
8 ; CHECK: 2 loop-vectorize - Number of loops analyzed for vectorization
9 ; CHECK: 1 loop-vectorize - Number of loops vectorized
11 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
12 target triple = "x86_64-apple-macosx10.8.0"
15 ; The source code for the test:
18 ; void foo(ptr restrict A, ptr restrict B)
20 ; for (int i = 0; i < 1000; i+=2) A[i] = sinf(B[i]);
25 ; This loop will be vectorized, although the scalar cost is lower than any of vector costs, but vectorization is explicitly forced in metadata.
28 define void @vectorized(ptr noalias nocapture %A, ptr noalias nocapture %B) {
33 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
34 %arrayidx = getelementptr inbounds float, ptr %B, i64 %indvars.iv
35 %0 = load float, ptr %arrayidx, align 4, !llvm.access.group !11
36 %call = tail call float @llvm.sin.f32(float %0)
37 %arrayidx2 = getelementptr inbounds float, ptr %A, i64 %indvars.iv
38 store float %call, ptr %arrayidx2, align 4, !llvm.access.group !11
39 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
40 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
41 %exitcond = icmp eq i32 %lftr.wideiv, 1000
42 br i1 %exitcond, label %for.end.loopexit, label %for.body, !llvm.loop !1
51 !1 = !{!1, !2, !{!"llvm.loop.parallel_accesses", !11}}
52 !2 = !{!"llvm.loop.vectorize.enable", i1 true}
56 ; This method will not be vectorized, as scalar cost is lower than any of vector costs.
59 define void @not_vectorized(ptr noalias nocapture %A, ptr noalias nocapture %B) {
64 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
65 %arrayidx = getelementptr inbounds float, ptr %B, i64 %indvars.iv
66 %0 = load float, ptr %arrayidx, align 4, !llvm.access.group !13
67 %call = tail call float @llvm.sin.f32(float %0)
68 %arrayidx2 = getelementptr inbounds float, ptr %A, i64 %indvars.iv
69 store float %call, ptr %arrayidx2, align 4, !llvm.access.group !13
70 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
71 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
72 %exitcond = icmp eq i32 %lftr.wideiv, 1000
73 br i1 %exitcond, label %for.end.loopexit, label %for.body, !llvm.loop !3
82 declare float @llvm.sin.f32(float) nounwind readnone
85 !3 = !{!3, !{!"llvm.loop.parallel_accesses", !13}}