1 ; RUN: opt -basicaa -loop-vectorize -force-vector-width=2 \
2 ; RUN: -force-vector-interleave=1 -S < %s \
3 ; RUN: | FileCheck %s -check-prefix=BOTH -check-prefix=LV
4 ; RUN: opt -basicaa -scoped-noalias -loop-vectorize -dse -force-vector-width=2 \
5 ; RUN: -force-vector-interleave=1 -S < %s \
6 ; RUN: | FileCheck %s -check-prefix=BOTH -check-prefix=DSE
8 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
10 ; This loop needs to be versioned with memchecks between {A, B} x {C} before
11 ; it can be vectorized.
13 ; for (i = 0; i < n; i++) {
18 ; Check that the corresponding noalias metadata is added to the vector loop
19 ; but not to the scalar loop.
21 ; Since in the versioned vector loop C and B can no longer alias, the first
22 ; store to C[i] can be DSE'd.
25 define void @f(i32* %a, i32* %b, i32* %c) {
29 ; BOTH: vector.memcheck:
31 for.body: ; preds = %for.body, %entry
32 %ind = phi i64 [ 0, %entry ], [ %inc, %for.body ]
34 %arrayidxA = getelementptr inbounds i32, i32* %a, i64 %ind
36 ; LV: = load {{.*}} !alias.scope !0
37 %loadA = load i32, i32* %arrayidxA, align 4
39 %add = add nuw i32 %loadA, 2
41 %arrayidxC = getelementptr inbounds i32, i32* %c, i64 %ind
42 ; Noalias with scope 1 and 6
43 ; LV: store {{.*}} !alias.scope !3, !noalias !5
45 store i32 %add, i32* %arrayidxC, align 4
47 %arrayidxB = getelementptr inbounds i32, i32* %b, i64 %ind
49 ; LV: = load {{.*}} !alias.scope !7
50 %loadB = load i32, i32* %arrayidxB, align 4
52 %add2 = add nuw i32 %add, %loadB
54 ; Noalias with scope 1 and 6
55 ; LV: store {{.*}} !alias.scope !3, !noalias !5
57 store i32 %add2, i32* %arrayidxC, align 4
59 %inc = add nuw nsw i64 %ind, 1
60 %exitcond = icmp eq i64 %inc, 20
61 br i1 %exitcond, label %for.end, label %for.body
64 ; BOTH-NOT: !alias.scope
67 for.end: ; preds = %for.body
72 ; LV: !1 = distinct !{!1, !2}
73 ; LV: !2 = distinct !{!2, !"LVerDomain"}
75 ; LV: !4 = distinct !{!4, !2}
77 ; LV: !6 = distinct !{!6, !2}