93 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 52; RUN: opt -passes='print<access-info>' -disable-output %s 2>&1 | FileCheck %s3 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 the6; same indices could be loaded in later iterations.7; FIXME: currently this is incorrectly considered safe for vectorization with8; runtime checks9define 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 loop13; 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 418; 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 422; 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 %loop33 34loop:35 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]36 %iv.off = add nuw nsw i64 %iv, %off37 %gep.A = getelementptr inbounds i8, ptr %A, i64 %iv.off38 %indices = load i8, ptr %gep.A, align 139 %indices.ext = zext i8 %indices to i6440 %gep.B = getelementptr inbounds i32, ptr %B, i64 %indices.ext41 %l = load i32, ptr %gep.B, align 442 %inc = add i32 %l, 143 store i32 %inc, ptr %gep.B, align 444 %gep.C = getelementptr inbounds i32, ptr %A, i64 %iv45 store i32 %l, ptr %gep.C, align 446 %iv.next = add nuw nsw i64 %iv, 147 %ec = icmp eq i64 %iv.next, %N48 br i1 %ec, label %exit, label %loop49 50exit:51 ret void52}53 54; It is not safe to vectorize because %indices are loaded in the loop and the55; 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 loop60; 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 465; 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 %loop76 77loop:78 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]79 %gep.A = getelementptr inbounds i8, ptr %A, i64 %iv80 %indices = load i8, ptr %gep.A, align 181 %indices.ext = zext i8 %indices to i6482 %gep.B = getelementptr inbounds i32, ptr %B, i64 %indices.ext83 %l = load i32, ptr %gep.B, align 484 %inc = add i32 %l, 185 store i32 %inc, ptr %gep.B, align 486 %iv.next = add nuw nsw i64 %iv, 187 %ec = icmp eq i64 %iv.next, %N88 br i1 %ec, label %exit, label %loop89 90exit:91 ret void92}93