90 lines · plain
1; RUN: opt -passes='print<access-info>' -disable-output < %s 2>&1 | FileCheck %s2 3; The runtime memory check code and the access grouping4; algorithm both assume that the start and end values5; for an access range are ordered (start <= stop).6; When generating checks for accesses with negative stride7; we need to take this into account and swap the interval8; ends.9;10; for (i = 0; i < 10000; i++) {11; B[i] = A[15000 - i] * 3;12; }13 14target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"15target triple = "aarch64"16 17; CHECK: function 'f':18; CHECK: (Low: (20000 + %a)<nuw> High: (60004 + %a))19 20@B = common global ptr null, align 821@A = common global ptr null, align 822 23define void @f() {24entry:25 %a = load ptr, ptr @A, align 826 %b = load ptr, ptr @B, align 827 br label %for.body28 29for.body: ; preds = %for.body, %entry30 %idx = phi i64 [ 0, %entry ], [ %add, %for.body ]31 %negidx = sub i64 15000, %idx32 33 %arrayidxA0 = getelementptr inbounds i32, ptr %a, i64 %negidx34 %loadA0 = load i32, ptr %arrayidxA0, align 235 36 %res = mul i32 %loadA0, 337 38 %add = add nuw nsw i64 %idx, 139 40 %arrayidxB = getelementptr inbounds i32, ptr %b, i64 %idx41 store i32 %res, ptr %arrayidxB, align 242 43 %exitcond = icmp eq i64 %idx, 1000044 br i1 %exitcond, label %for.end, label %for.body45 46for.end: ; preds = %for.body47 ret void48}49 50; CHECK: function 'g':51; When the stride is not constant, we are forced to do umin/umax to get52; the interval limits.53 54; for (i = 0; i < 10000; i++) {55; B[i] = A[i] * 3;56; }57 58; Here it is not obvious what the limits are, since 'step' could be negative.59 60; CHECK: Low: ((60000 + %a) umin (60000 + (-40000 * %step) + %a)) 61; CHECK: High: (4 + ((60000 + %a) umax (60000 + (-40000 * %step) + %a)))62 63define void @g(i64 %step) {64entry:65 %a = load ptr, ptr @A, align 866 %b = load ptr, ptr @B, align 867 br label %for.body68 69for.body: ; preds = %for.body, %entry70 %idx = phi i64 [ 0, %entry ], [ %add, %for.body ]71 %idx_mul = mul i64 %idx, %step72 %negidx = sub i64 15000, %idx_mul73 74 %arrayidxA0 = getelementptr inbounds i32, ptr %a, i64 %negidx75 %loadA0 = load i32, ptr %arrayidxA0, align 276 77 %res = mul i32 %loadA0, 378 79 %add = add nuw nsw i64 %idx, 180 81 %arrayidxB = getelementptr inbounds i32, ptr %b, i64 %idx82 store i32 %res, ptr %arrayidxB, align 283 84 %exitcond = icmp eq i64 %idx, 1000085 br i1 %exitcond, label %for.end, label %for.body86 87for.end: ; preds = %for.body88 ret void89}90