blob: 1cfa2ca006d0459e923d80f8ebbf82221897fccf [file] [edit]
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
; RUN: opt -passes='print<access-info>' -disable-output %s 2>&1 | FileCheck %s
; Stores through the same pointer must keep their order across iterations.
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
; FIXME: Stores of iterations i < j with idx[i] == idx[j] are not ordered.
define void @stores_indirect_different_blocks(ptr noalias %p, ptr noalias %idx, ptr noalias %c, i64 %n) {
; CHECK-LABEL: 'stores_indirect_different_blocks'
; CHECK-NEXT: loop:
; 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
; CHECK-NEXT: Unsafe indirect dependence.
; CHECK-NEXT: Dependences:
; CHECK-NEXT: IndirectUnsafe:
; CHECK-NEXT: store i32 2, ptr %gep.p, align 4 ->
; CHECK-NEXT: store i32 1, ptr %gep.p, align 4
; CHECK-EMPTY:
; CHECK-NEXT: Run-time memory checks:
; CHECK-NEXT: Grouped accesses:
; CHECK-EMPTY:
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
; CHECK-NEXT: SCEV assumptions:
; CHECK-EMPTY:
; CHECK-NEXT: Expressions re-written:
;
entry:
br label %loop
loop:
%iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
%gep.idx = getelementptr inbounds i32, ptr %idx, i64 %iv
%l.idx = load i32, ptr %gep.idx, align 4
%idx.ext = sext i32 %l.idx to i64
%gep.p = getelementptr inbounds i32, ptr %p, i64 %idx.ext
%gep.c = getelementptr inbounds i8, ptr %c, i64 %iv
%l.c = load i8, ptr %gep.c, align 1
%cmp = icmp eq i8 %l.c, 0
br i1 %cmp, label %then, label %else
then:
store i32 1, ptr %gep.p, align 4
br label %latch
else:
store i32 2, ptr %gep.p, align 4
br label %latch
latch:
%iv.next = add nuw nsw i64 %iv, 1
%ec = icmp eq i64 %iv.next, %n
br i1 %ec, label %exit, label %loop
exit:
ret void
}
; FIXME: Overlapping i32 stores of consecutive iterations are not ordered.
define void @stores_byte_stride_different_blocks(ptr noalias %p, ptr noalias %c, i64 %n) {
; CHECK-LABEL: 'stores_byte_stride_different_blocks'
; CHECK-NEXT: loop:
; 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
; CHECK-NEXT: Unsafe indirect dependence.
; CHECK-NEXT: Dependences:
; CHECK-NEXT: IndirectUnsafe:
; CHECK-NEXT: store i32 33686018, ptr %gep.p, align 1 ->
; CHECK-NEXT: store i32 16843009, ptr %gep.p, align 1
; CHECK-EMPTY:
; CHECK-NEXT: Run-time memory checks:
; CHECK-NEXT: Grouped accesses:
; CHECK-EMPTY:
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
; CHECK-NEXT: SCEV assumptions:
; CHECK-EMPTY:
; CHECK-NEXT: Expressions re-written:
;
entry:
br label %loop
loop:
%iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
%gep.p = getelementptr inbounds i8, ptr %p, i64 %iv
%gep.c = getelementptr inbounds i8, ptr %c, i64 %iv
%l.c = load i8, ptr %gep.c, align 1
%cmp = icmp eq i8 %l.c, 0
br i1 %cmp, label %then, label %else
then:
store i32 16843009, ptr %gep.p, align 1
br label %latch
else:
store i32 33686018, ptr %gep.p, align 1
br label %latch
latch:
%iv.next = add nuw nsw i64 %iv, 1
%ec = icmp eq i64 %iv.next, %n
br i1 %ec, label %exit, label %loop
exit:
ret void
}
; Same as @stores_byte_stride_different_blocks, but without any loads.
; FIXME: Dependences between the stores are not checked, incorrectly safe.
define void @stores_byte_stride_different_blocks_no_loads(ptr %p, i64 %n) {
; CHECK-LABEL: 'stores_byte_stride_different_blocks_no_loads'
; CHECK-NEXT: loop:
; 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
; CHECK-NEXT: Unsafe indirect dependence.
; CHECK-NEXT: Dependences:
; CHECK-NEXT: IndirectUnsafe:
; CHECK-NEXT: store i32 33686018, ptr %gep.p, align 1 ->
; CHECK-NEXT: store i32 16843009, ptr %gep.p, align 1
; CHECK-EMPTY:
; CHECK-NEXT: Run-time memory checks:
; CHECK-NEXT: Grouped accesses:
; CHECK-EMPTY:
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
; CHECK-NEXT: SCEV assumptions:
; CHECK-EMPTY:
; CHECK-NEXT: Expressions re-written:
;
entry:
br label %loop
loop:
%iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
%gep.p = getelementptr inbounds i8, ptr %p, i64 %iv
%and = and i64 %iv, 1
%cmp = icmp eq i64 %and, 0
br i1 %cmp, label %then, label %else
then:
store i32 16843009, ptr %gep.p, align 1
br label %latch
else:
store i32 33686018, ptr %gep.p, align 1
br label %latch
latch:
%iv.next = add nuw nsw i64 %iv, 1
%ec = icmp eq i64 %iv.next, %n
br i1 %ec, label %exit, label %loop
exit:
ret void
}
; FIXME: Stores to %a, directly and through %p, are not ordered.
define void @stores_invariant_address_direct_and_through_phi(ptr %a, ptr %b, ptr noalias %c, i64 %n) {
; CHECK-LABEL: 'stores_invariant_address_direct_and_through_phi'
; CHECK-NEXT: loop:
; CHECK-NEXT: Memory dependences are safe with run-time checks
; CHECK-NEXT: Dependences:
; CHECK-NEXT: Run-time memory checks:
; CHECK-NEXT: Check 0:
; CHECK-NEXT: Comparing group GRP0:
; CHECK-NEXT: ptr %a
; CHECK-NEXT: Against group GRP1:
; CHECK-NEXT: ptr %b
; CHECK-NEXT: Grouped accesses:
; CHECK-NEXT: Group GRP0:
; CHECK-NEXT: (Low: %a High: (4 + %a))
; CHECK-NEXT: Member: %a
; CHECK-NEXT: Group GRP1:
; CHECK-NEXT: (Low: %b High: (4 + %b))
; CHECK-NEXT: Member: %b
; CHECK-EMPTY:
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
; CHECK-NEXT: SCEV assumptions:
; CHECK-EMPTY:
; CHECK-NEXT: Expressions re-written:
;
entry:
br label %loop
loop:
%iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
store i32 1, ptr %a, align 4
%gep.c = getelementptr inbounds i8, ptr %c, i64 %iv
%l.c = load i8, ptr %gep.c, align 1
%cmp = icmp eq i8 %l.c, 0
br i1 %cmp, label %then, label %latch
then:
br label %latch
latch:
%p = phi ptr [ %a, %then ], [ %b, %loop ]
store i32 2, ptr %p, align 4
%iv.next = add nuw nsw i64 %iv, 1
%ec = icmp eq i64 %iv.next, %n
br i1 %ec, label %exit, label %loop
exit:
ret void
}
; FIXME: Both stores write %a, as %p is a phi of %a, and are not ordered.
define void @stores_invariant_address_direct_and_through_phi_same_incoming(ptr %a, ptr noalias %c, i64 %n) {
; CHECK-LABEL: 'stores_invariant_address_direct_and_through_phi_same_incoming'
; CHECK-NEXT: loop:
; CHECK-NEXT: Memory dependences are safe
; CHECK-NEXT: Dependences:
; CHECK-NEXT: Run-time memory checks:
; CHECK-NEXT: Grouped accesses:
; CHECK-EMPTY:
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
; CHECK-NEXT: SCEV assumptions:
; CHECK-EMPTY:
; CHECK-NEXT: Expressions re-written:
;
entry:
br label %loop
loop:
%iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
%gep.c = getelementptr inbounds i8, ptr %c, i64 %iv
%l.c = load i8, ptr %gep.c, align 1
%cmp = icmp eq i8 %l.c, 0
br i1 %cmp, label %then, label %else
then:
store i32 1, ptr %a, align 4
br label %latch
else:
%cmp.2 = icmp eq i8 %l.c, 1
br i1 %cmp.2, label %else.1, label %else.2
else.1:
br label %join
else.2:
br label %join
join:
%p = phi ptr [ %a, %else.1 ], [ %a, %else.2 ]
store i32 2, ptr %p, align 4
br label %latch
latch:
%iv.next = add nuw nsw i64 %iv, 1
%ec = icmp eq i64 %iv.next, %n
br i1 %ec, label %exit, label %loop
exit:
ret void
}