|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6 |
| 2 | +; RUN: opt < %s -disable-output "-passes=print<da>" 2>&1 \ |
| 3 | +; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-ALL |
| 4 | +; RUN: opt < %s -disable-output "-passes=print<da>" -da-enable-dependence-test=weak-crossing-siv 2>&1 \ |
| 5 | +; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-WEAK-CROSSING-SIV |
| 6 | + |
| 7 | +; max_i = INT64_MAX/3 // 3074457345618258602 |
| 8 | +; for (long long i = 0; i <= max_i; i++) { |
| 9 | +; A[-3*i + INT64_MAX] = 0; |
| 10 | +; if (i) |
| 11 | +; A[3*i - 2] = 1; |
| 12 | +; } |
| 13 | +; |
| 14 | +; FIXME: DependenceAnalysis currently detects no dependency between |
| 15 | +; `A[-3*i + INT64_MAX]` and `A[3*i - 2]`, but it does exist. For example, |
| 16 | +; |
| 17 | +; memory access | i == 1 | i == max_i |
| 18 | +; ---------------------|------------------|------------------ |
| 19 | +; A[-3*i + INT64_MAX] | A[INT64_MAX - 3] | A[1] |
| 20 | +; A[3*i - 2] | A[1] | A[INT64_MAX - 3] |
| 21 | +; |
| 22 | +; The root cause is that the calculation of the differenct between the two |
| 23 | +; constants (INT64_MAX and -2) triggers an overflow. |
| 24 | + |
| 25 | +define void @weakcorssing_delta_ovfl(ptr %A) { |
| 26 | +; CHECK-ALL-LABEL: 'weakcorssing_delta_ovfl' |
| 27 | +; CHECK-ALL-NEXT: Src: store i8 0, ptr %idx.0, align 1 --> Dst: store i8 0, ptr %idx.0, align 1 |
| 28 | +; CHECK-ALL-NEXT: da analyze - none! |
| 29 | +; CHECK-ALL-NEXT: Src: store i8 0, ptr %idx.0, align 1 --> Dst: store i8 1, ptr %idx.1, align 1 |
| 30 | +; CHECK-ALL-NEXT: da analyze - none! |
| 31 | +; CHECK-ALL-NEXT: Src: store i8 1, ptr %idx.1, align 1 --> Dst: store i8 1, ptr %idx.1, align 1 |
| 32 | +; CHECK-ALL-NEXT: da analyze - none! |
| 33 | +; |
| 34 | +; CHECK-WEAK-CROSSING-SIV-LABEL: 'weakcorssing_delta_ovfl' |
| 35 | +; CHECK-WEAK-CROSSING-SIV-NEXT: Src: store i8 0, ptr %idx.0, align 1 --> Dst: store i8 0, ptr %idx.0, align 1 |
| 36 | +; CHECK-WEAK-CROSSING-SIV-NEXT: da analyze - consistent output [*]! |
| 37 | +; CHECK-WEAK-CROSSING-SIV-NEXT: Src: store i8 0, ptr %idx.0, align 1 --> Dst: store i8 1, ptr %idx.1, align 1 |
| 38 | +; CHECK-WEAK-CROSSING-SIV-NEXT: da analyze - none! |
| 39 | +; CHECK-WEAK-CROSSING-SIV-NEXT: Src: store i8 1, ptr %idx.1, align 1 --> Dst: store i8 1, ptr %idx.1, align 1 |
| 40 | +; CHECK-WEAK-CROSSING-SIV-NEXT: da analyze - consistent output [*]! |
| 41 | +; |
| 42 | +entry: |
| 43 | + br label %loop.header |
| 44 | + |
| 45 | +loop.header: |
| 46 | + %i = phi i64 [ 0, %entry ], [ %i.inc, %loop.latch ] |
| 47 | + %subscript.0 = phi i64 [ 9223372036854775807, %entry ], [ %subscript.0.next, %loop.latch ] |
| 48 | + %subscript.1 = phi i64 [ -2, %entry ], [ %subscript.1.next, %loop.latch ] |
| 49 | + %idx.0 = getelementptr inbounds i8, ptr %A, i64 %subscript.0 |
| 50 | + store i8 0, ptr %idx.0 |
| 51 | + %cond.store = icmp ne i64 %i, 0 |
| 52 | + br i1 %cond.store, label %if.store, label %loop.latch |
| 53 | + |
| 54 | +if.store: |
| 55 | + %idx.1 = getelementptr inbounds i8, ptr %A, i64 %subscript.1 |
| 56 | + store i8 1, ptr %idx.1 |
| 57 | + br label %loop.latch |
| 58 | + |
| 59 | +loop.latch: |
| 60 | + %i.inc = add nuw nsw i64 %i, 1 |
| 61 | + %subscript.0.next = add nsw i64 %subscript.0, -3 |
| 62 | + %subscript.1.next = add nsw i64 %subscript.1, 3 |
| 63 | + %ec = icmp sgt i64 %i.inc, 3074457345618258602 |
| 64 | + br i1 %ec, label %exit, label %loop.header |
| 65 | + |
| 66 | +exit: |
| 67 | + ret void |
| 68 | +} |
| 69 | + |
| 70 | +; max_i = INT64_MAX/3 // 3074457345618258602 |
| 71 | +; for (long long i = 0; i <= max_i; i++) { |
| 72 | +; A[-3*i + INT64_MAX] = 0; |
| 73 | +; A[3*i + 1] = 1; |
| 74 | +; } |
| 75 | +; |
| 76 | +; FIXME: DependenceAnalysis currently detects no dependency between |
| 77 | +; `A[-3*i + INT64_MAX]` and `A[3*i - 2]`, but it does exist. For example, |
| 78 | +; |
| 79 | +; memory access | i == 0 | i == 1 | i == max_i - 1 | i == max_i |
| 80 | +; ---------------------|--------|------------------|----------------|------------------ |
| 81 | +; A[-3*i + INT64_MAX] | | A[INT64_MAX - 3] | A[1] | |
| 82 | +; A[3*i + 1] | A[1] | | | A[INT64_MAX - 3] |
| 83 | +; |
| 84 | +; The root cause is that the product of the BTC, the coefficient, and 2 |
| 85 | +; triggers an overflow. |
| 86 | +; |
| 87 | +define void @weakcorssing_prod_ovfl(ptr %A) { |
| 88 | +; CHECK-ALL-LABEL: 'weakcorssing_prod_ovfl' |
| 89 | +; CHECK-ALL-NEXT: Src: store i8 0, ptr %idx.0, align 1 --> Dst: store i8 0, ptr %idx.0, align 1 |
| 90 | +; CHECK-ALL-NEXT: da analyze - none! |
| 91 | +; CHECK-ALL-NEXT: Src: store i8 0, ptr %idx.0, align 1 --> Dst: store i8 1, ptr %idx.1, align 1 |
| 92 | +; CHECK-ALL-NEXT: da analyze - none! |
| 93 | +; CHECK-ALL-NEXT: Src: store i8 1, ptr %idx.1, align 1 --> Dst: store i8 1, ptr %idx.1, align 1 |
| 94 | +; CHECK-ALL-NEXT: da analyze - none! |
| 95 | +; |
| 96 | +; CHECK-WEAK-CROSSING-SIV-LABEL: 'weakcorssing_prod_ovfl' |
| 97 | +; CHECK-WEAK-CROSSING-SIV-NEXT: Src: store i8 0, ptr %idx.0, align 1 --> Dst: store i8 0, ptr %idx.0, align 1 |
| 98 | +; CHECK-WEAK-CROSSING-SIV-NEXT: da analyze - consistent output [*]! |
| 99 | +; CHECK-WEAK-CROSSING-SIV-NEXT: Src: store i8 0, ptr %idx.0, align 1 --> Dst: store i8 1, ptr %idx.1, align 1 |
| 100 | +; CHECK-WEAK-CROSSING-SIV-NEXT: da analyze - none! |
| 101 | +; CHECK-WEAK-CROSSING-SIV-NEXT: Src: store i8 1, ptr %idx.1, align 1 --> Dst: store i8 1, ptr %idx.1, align 1 |
| 102 | +; CHECK-WEAK-CROSSING-SIV-NEXT: da analyze - consistent output [*]! |
| 103 | +; |
| 104 | +entry: |
| 105 | + br label %loop |
| 106 | + |
| 107 | +loop: |
| 108 | + %i = phi i64 [ 0, %entry ], [ %i.inc, %loop ] |
| 109 | + %subscript.0 = phi i64 [ 9223372036854775807, %entry ], [ %subscript.0.next, %loop ] |
| 110 | + %subscript.1 = phi i64 [ 1, %entry ], [ %subscript.1.next, %loop ] |
| 111 | + %idx.0 = getelementptr inbounds i8, ptr %A, i64 %subscript.0 |
| 112 | + %idx.1 = getelementptr inbounds i8, ptr %A, i64 %subscript.1 |
| 113 | + store i8 0, ptr %idx.0 |
| 114 | + store i8 1, ptr %idx.1 |
| 115 | + %i.inc = add nuw nsw i64 %i, 1 |
| 116 | + %subscript.0.next = add nsw i64 %subscript.0, -3 |
| 117 | + %subscript.1.next = add nsw i64 %subscript.1, 3 |
| 118 | + %ec = icmp sgt i64 %i.inc, 3074457345618258602 |
| 119 | + br i1 %ec, label %exit, label %loop |
| 120 | + |
| 121 | +exit: |
| 122 | + ret void |
| 123 | +} |
| 124 | +;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: |
| 125 | +; CHECK: {{.*}} |
0 commit comments