1 ; RUN: opt -analyze --loop-accesses %s -enable-new-pm=0 | FileCheck %s
2 ; RUN: opt -passes=print-access-info %s -disable-output 2>&1 | FileCheck %s
4 ; This test verifies run-time boundary check of memory accesses.
6 ; void fastCopy(const char* src, char* op) {
9 ; *(reinterpret_cast<long long*>(op)) = *(reinterpret_cast<const long long*>(src));
15 ; Boundaries calculations before this patch:
16 ; (Low: %src High: (24 + %src))
17 ; and the actual distance between two pointers was 31, (%op - %src = 31)
18 ; IsConflict = (24 > 31) = false -> execution is directed to the vectorized loop.
19 ; The loop was vectorized to 4, 32 byte memory access ( <4 x i64> ),
20 ; store a value at *%op touched memory under *%src.
22 ;CHECK: function 'fastCopy':
23 ;CHECK: (Low: %op High: (32 + %op))
24 ;CHECK: (Low: %src High: (32 + %src))
26 define void @fastCopy(i8* nocapture readonly %src, i8* nocapture %op) {
28 br label %while.body.preheader
30 while.body.preheader: ; preds = %entry
33 while.body: ; preds = %while.body.preheader, %while.body
34 %len.addr.07 = phi i32 [ %sub, %while.body ], [ 32, %while.body.preheader ]
35 %op.addr.06 = phi i8* [ %add.ptr1, %while.body ], [ %op, %while.body.preheader ]
36 %src.addr.05 = phi i8* [ %add.ptr, %while.body ], [ %src, %while.body.preheader ]
37 %0 = bitcast i8* %src.addr.05 to i64*
38 %1 = load i64, i64* %0, align 8
39 %2 = bitcast i8* %op.addr.06 to i64*
40 store i64 %1, i64* %2, align 8
41 %add.ptr = getelementptr inbounds i8, i8* %src.addr.05, i64 8
42 %add.ptr1 = getelementptr inbounds i8, i8* %op.addr.06, i64 8
43 %sub = add nsw i32 %len.addr.07, -8
44 %cmp = icmp sgt i32 %len.addr.07, 8
45 br i1 %cmp, label %while.body, label %while.end.loopexit
47 while.end.loopexit: ; preds = %while.body
50 while.end: ; preds = %while.end.loopexit, %entry