1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -passes='print<access-info>' -disable-output %s 2>&1 | FileCheck %s
4 ; Test case for https://github.com/llvm/llvm-project/issues/87189.
5 ; It is not safe to vectorize because %indices are loaded in the loop and the
6 ; same indices could be loaded in later iterations.
7 ; FIXME: currently this is incorrectly considered safe for vectorization with
9 define void @B_indices_loaded_in_loop_A_stored(ptr %A, ptr noalias %B, i64 %N, i64 %off) {
10 ; CHECK-LABEL: 'B_indices_loaded_in_loop_A_stored'
12 ; 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
13 ; CHECK-NEXT: Unsafe indirect dependence.
14 ; CHECK-NEXT: Dependences:
15 ; CHECK-NEXT: IndirectUnsafe:
16 ; CHECK-NEXT: %l = load i32, ptr %gep.B, align 4 ->
17 ; CHECK-NEXT: store i32 %inc, ptr %gep.B, align 4
19 ; CHECK-NEXT: Unknown:
20 ; CHECK-NEXT: %indices = load i8, ptr %gep.A, align 1 ->
21 ; CHECK-NEXT: store i32 %l, ptr %gep.C, align 4
23 ; CHECK-NEXT: Run-time memory checks:
24 ; CHECK-NEXT: Grouped accesses:
26 ; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
27 ; CHECK-NEXT: SCEV assumptions:
29 ; CHECK-NEXT: Expressions re-written:
35 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
36 %iv.off = add nuw nsw i64 %iv, %off
37 %gep.A = getelementptr inbounds i8, ptr %A, i64 %iv.off
38 %indices = load i8, ptr %gep.A, align 1
39 %indices.ext = zext i8 %indices to i64
40 %gep.B = getelementptr inbounds i32, ptr %B, i64 %indices.ext
41 %l = load i32, ptr %gep.B, align 4
43 store i32 %inc, ptr %gep.B, align 4
44 %gep.C = getelementptr inbounds i32, ptr %A, i64 %iv
45 store i32 %l, ptr %gep.C, align 4
46 %iv.next = add nuw nsw i64 %iv, 1
47 %ec = icmp eq i64 %iv.next, %N
48 br i1 %ec, label %exit, label %loop
54 ; It is not safe to vectorize because %indices are loaded in the loop and the
55 ; same indices could be loaded in later iterations.
56 define void @B_indices_loaded_in_loop_A_not_stored(ptr %A, ptr noalias %B, i64 %N) {
57 ; CHECK-LABEL: 'B_indices_loaded_in_loop_A_not_stored'
59 ; 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
60 ; CHECK-NEXT: Unsafe indirect dependence.
61 ; CHECK-NEXT: Dependences:
62 ; CHECK-NEXT: IndirectUnsafe:
63 ; CHECK-NEXT: %l = load i32, ptr %gep.B, align 4 ->
64 ; CHECK-NEXT: store i32 %inc, ptr %gep.B, align 4
66 ; CHECK-NEXT: Run-time memory checks:
67 ; CHECK-NEXT: Grouped accesses:
69 ; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
70 ; CHECK-NEXT: SCEV assumptions:
72 ; CHECK-NEXT: Expressions re-written:
78 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
79 %gep.A = getelementptr inbounds i8, ptr %A, i64 %iv
80 %indices = load i8, ptr %gep.A, align 1
81 %indices.ext = zext i8 %indices to i64
82 %gep.B = getelementptr inbounds i32, ptr %B, i64 %indices.ext
83 %l = load i32, ptr %gep.B, align 4
85 store i32 %inc, ptr %gep.B, align 4
86 %iv.next = add nuw nsw i64 %iv, 1
87 %ec = icmp eq i64 %iv.next, %N
88 br i1 %ec, label %exit, label %loop