brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.1 KiB · 6247336 Raw
78 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 62; RUN: opt < %s -disable-output -passes="print<da>" -da-dump-monotonicity-report \3; RUN:     -da-enable-monotonicity-check 2>&1 | FileCheck %s4; RUN: opt < %s -disable-output -passes="print<da>" 2>&1 | FileCheck %s -check-prefix=DISABLE-CHECK5 6;7; for (i = 0; i < (1ULL << 60); i++) {8;   A[i] = 1;9;10;   unsigned long long offset = i * 32 + (1ULL << 62);11;   // offset is positive when interpreted as a signed value.12;   // To prevent violating the size limitation for an allocated object.13;   if (offset < (1ULL << 63))14;     A[offset] = 2;15; }16;17; -----------------------------------------------------------------------------18;19; There is a dependency between the two stores. To detect it, we need to check20; the monotonicity and bail out the analysis since `offset` is not monotonic.21;22;  memory location  | first store (A[i]) | second store (A[offset])23; ------------------|--------------------|----------------------------24;  A[0]             | i = 0              | i = 2^59 - 2^5725;  A[2^60 - 32]     | i = 2^60 - 32      | i = 2^59 - 2^57 + 2^55 - 126;27define void @f(ptr %A) {28; CHECK-LABEL: 'f'29; CHECK-NEXT:  Monotonicity check:30; CHECK-NEXT:    Inst: store i8 1, ptr %idx.0, align 131; CHECK-NEXT:      Expr: {0,+,1}<nuw><nsw><%loop.header>32; CHECK-NEXT:      Monotonicity: MultivariateSignedMonotonic33; CHECK-NEXT:    Inst: store i8 2, ptr %idx.1, align 134; CHECK-NEXT:      Expr: {4611686018427387904,+,32}<%loop.header>35; CHECK-NEXT:      Monotonicity: Unknown36; CHECK-NEXT:      Reason: {4611686018427387904,+,32}<%loop.header>37; CHECK-EMPTY:38; CHECK-NEXT:  Src: store i8 1, ptr %idx.0, align 1 --> Dst: store i8 1, ptr %idx.0, align 139; CHECK-NEXT:    da analyze - none!40; CHECK-NEXT:  Src: store i8 1, ptr %idx.0, align 1 --> Dst: store i8 2, ptr %idx.1, align 141; CHECK-NEXT:    da analyze - confused!42; CHECK-NEXT:  Src: store i8 2, ptr %idx.1, align 1 --> Dst: store i8 2, ptr %idx.1, align 143; CHECK-NEXT:    da analyze - confused!44;45; DISABLE-CHECK-LABEL: 'f'46; DISABLE-CHECK-NEXT:  Src: store i8 1, ptr %idx.0, align 1 --> Dst: store i8 1, ptr %idx.0, align 147; DISABLE-CHECK-NEXT:    da analyze - none!48; DISABLE-CHECK-NEXT:  Src: store i8 1, ptr %idx.0, align 1 --> Dst: store i8 2, ptr %idx.1, align 149; DISABLE-CHECK-NEXT:    da analyze - none!50; DISABLE-CHECK-NEXT:  Src: store i8 2, ptr %idx.1, align 1 --> Dst: store i8 2, ptr %idx.1, align 151; DISABLE-CHECK-NEXT:    da analyze - none!52;53entry:54  br label %loop.header55 56loop.header:57  %i = phi i64 [ 0, %entry ], [ %i.next, %loop.latch ]58  %idx.0 = getelementptr inbounds i8, ptr %A, i64 %i59  store i8 1, ptr %idx.060  %offset.tmp = mul i64 %i, 3261  %offset = add i64 %offset.tmp, 4611686018427387904 ; 1ULL << 6262  %if.cond = icmp sge i64 %offset, 063  br i1 %if.cond, label %if.then, label %loop.latch64 65if.then:66  %idx.1 = getelementptr inbounds i8, ptr %A, i64 %offset67  store i8 2, ptr %idx.168  br label %loop.latch69 70loop.latch:71  %i.next = add nuw nsw i64 %i, 172  %exit.cond = icmp eq i64 %i.next, 1152921504606846976 ; 1ULL << 6073  br i1 %exit.cond, label %exit, label %loop.header74 75exit:76  ret void77}78