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 3 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 8; runtime checks 9define 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' 11; CHECK-NEXT: loop: 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 18; CHECK-EMPTY: 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 22; CHECK-EMPTY: 23; CHECK-NEXT: Run-time memory checks: 24; CHECK-NEXT: Grouped accesses: 25; CHECK-EMPTY: 26; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop. 27; CHECK-NEXT: SCEV assumptions: 28; CHECK-EMPTY: 29; CHECK-NEXT: Expressions re-written: 30; 31entry: 32 br label %loop 33 34loop: 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 42 %inc = add i32 %l, 1 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 49 50exit: 51 ret void 52} 53 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. 56define 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' 58; CHECK-NEXT: loop: 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 65; CHECK-EMPTY: 66; CHECK-NEXT: Run-time memory checks: 67; CHECK-NEXT: Grouped accesses: 68; CHECK-EMPTY: 69; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop. 70; CHECK-NEXT: SCEV assumptions: 71; CHECK-EMPTY: 72; CHECK-NEXT: Expressions re-written: 73; 74entry: 75 br label %loop 76 77loop: 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 84 %inc = add i32 %l, 1 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 89 90exit: 91 ret void 92} 93