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