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 3 4; This test verifies run-time boundary check of memory accesses. 5; The original loop: 6; void fastCopy(const char* src, char* op) { 7; int len = 32; 8; while (len > 0) { 9; *(reinterpret_cast<long long*>(op)) = *(reinterpret_cast<const long long*>(src)); 10; src += 8; 11; op += 8; 12; len -= 8; 13; } 14; } 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. 21 22;CHECK: function 'fastCopy': 23;CHECK: (Low: %op High: (32 + %op)) 24;CHECK: (Low: %src High: (32 + %src)) 25 26define void @fastCopy(i8* nocapture readonly %src, i8* nocapture %op) { 27entry: 28 br label %while.body.preheader 29 30while.body.preheader: ; preds = %entry 31 br label %while.body 32 33while.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 46 47while.end.loopexit: ; preds = %while.body 48 br label %while.end 49 50while.end: ; preds = %while.end.loopexit, %entry 51 ret void 52} 53