1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -passes='print<access-info>' -disable-output 2>&1 < %s | FileCheck %s
4 ; PR79137: If the noalias.scope.decl is located inside the loop, we cannot
5 ; assume that the accesses don't alias across iterations.
7 define void @test_scope_in_loop(ptr %arg, i64 %num) {
8 ; CHECK-LABEL: 'test_scope_in_loop'
10 ; CHECK-NEXT: Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
11 ; CHECK-NEXT: Backward loop carried data dependence.
12 ; CHECK-NEXT: Dependences:
13 ; CHECK-NEXT: Backward:
14 ; CHECK-NEXT: %load.prev = load i8, ptr %prev.ptr, align 1, !alias.scope !0, !noalias !3 ->
15 ; CHECK-NEXT: store i8 %add, ptr %cur.ptr, align 1, !alias.scope !3
17 ; CHECK-NEXT: Forward:
18 ; CHECK-NEXT: %load.cur = load i8, ptr %cur.ptr, align 1, !alias.scope !3 ->
19 ; CHECK-NEXT: store i8 %add, ptr %cur.ptr, align 1, !alias.scope !3
21 ; CHECK-NEXT: Run-time memory checks:
22 ; CHECK-NEXT: Grouped accesses:
24 ; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
25 ; CHECK-NEXT: SCEV assumptions:
27 ; CHECK-NEXT: Expressions re-written:
30 %icmp = icmp ult i64 %num, 2
31 br i1 %icmp, label %exit, label %preheader
34 %arg.1 = getelementptr inbounds i8, ptr %arg, i64 1
35 %end = add i64 %num, -2
39 %prev.ptr = phi ptr [ %cur.ptr, %loop ], [ %arg, %preheader ]
40 %iv = phi i64 [ %iv.next, %loop ], [ 0, %preheader ]
41 %cur.ptr = getelementptr inbounds i8, ptr %arg.1, i64 %iv
42 call void @llvm.experimental.noalias.scope.decl(metadata !0)
43 call void @llvm.experimental.noalias.scope.decl(metadata !3)
44 %load.prev = load i8, ptr %prev.ptr, align 1, !alias.scope !0, !noalias !3
45 %load.cur = load i8, ptr %cur.ptr, align 1, !alias.scope !3
46 %add = add i8 %load.cur, %load.prev
47 store i8 %add, ptr %cur.ptr, align 1, !alias.scope !3
48 %iv.next = add nuw i64 %iv, 1
49 %cmp = icmp eq i64 %iv, %end
50 br i1 %cmp, label %exit, label %loop
56 define void @test_scope_out_of_loop(ptr %arg, i64 %num) {
57 ; CHECK-LABEL: 'test_scope_out_of_loop'
59 ; CHECK-NEXT: Memory dependences are safe
60 ; CHECK-NEXT: Dependences:
61 ; CHECK-NEXT: Run-time memory checks:
62 ; CHECK-NEXT: Grouped accesses:
64 ; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
65 ; CHECK-NEXT: SCEV assumptions:
67 ; CHECK-NEXT: Expressions re-written:
70 %icmp = icmp ult i64 %num, 2
71 br i1 %icmp, label %exit, label %preheader
74 call void @llvm.experimental.noalias.scope.decl(metadata !0)
75 call void @llvm.experimental.noalias.scope.decl(metadata !3)
76 %arg.1 = getelementptr inbounds i8, ptr %arg, i64 1
77 %end = add i64 %num, -2
81 %prev.ptr = phi ptr [ %cur.ptr, %loop ], [ %arg, %preheader ]
82 %iv = phi i64 [ %iv.next, %loop ], [ 0, %preheader ]
83 %cur.ptr = getelementptr inbounds i8, ptr %arg.1, i64 %iv
84 %load.prev = load i8, ptr %prev.ptr, align 1, !alias.scope !0, !noalias !3
85 %load.cur = load i8, ptr %cur.ptr, align 1, !alias.scope !3
86 %add = add i8 %load.cur, %load.prev
87 store i8 %add, ptr %cur.ptr, align 1, !alias.scope !3
88 %iv.next = add nuw i64 %iv, 1
89 %cmp = icmp eq i64 %iv, %end
90 br i1 %cmp, label %exit, label %loop
96 declare void @llvm.experimental.noalias.scope.decl(metadata)
99 !1 = distinct !{!1, !2}
102 !4 = distinct !{!4, !5}