138 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>" 2>&1 \3; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-ALL4; RUN: opt < %s -disable-output "-passes=print<da>" -da-enable-dependence-test=symbolic-rdiv 2>&1 \5; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-SYMBOLIC-RDIV6 7; for (i = 0; i < (1LL << 62); i++) {8; if (0 <= 2*i - 2)9; A[2*i - 2] = 1;10; A[i] = 2;11; }12;13; FIXME: DependenceAnalysis currently detects no dependency between the two14; stores, but it does exist. For example, each store will access A[0] when i15; is 1 and 0 respectively.16; The root cause is that the product of the BTC and the coefficient17; ((1LL << 62) - 1 and 2) overflows in a signed sense.18define void @symbolicrdiv_prod_ovfl(ptr %A) {19; CHECK-ALL-LABEL: 'symbolicrdiv_prod_ovfl'20; CHECK-ALL-NEXT: Src: store i8 1, ptr %gep.0, align 1 --> Dst: store i8 1, ptr %gep.0, align 121; CHECK-ALL-NEXT: da analyze - none!22; CHECK-ALL-NEXT: Src: store i8 1, ptr %gep.0, align 1 --> Dst: store i8 2, ptr %gep.1, align 123; CHECK-ALL-NEXT: da analyze - none!24; CHECK-ALL-NEXT: Src: store i8 2, ptr %gep.1, align 1 --> Dst: store i8 2, ptr %gep.1, align 125; CHECK-ALL-NEXT: da analyze - none!26;27; CHECK-SYMBOLIC-RDIV-LABEL: 'symbolicrdiv_prod_ovfl'28; CHECK-SYMBOLIC-RDIV-NEXT: Src: store i8 1, ptr %gep.0, align 1 --> Dst: store i8 1, ptr %gep.0, align 129; CHECK-SYMBOLIC-RDIV-NEXT: da analyze - none!30; CHECK-SYMBOLIC-RDIV-NEXT: Src: store i8 1, ptr %gep.0, align 1 --> Dst: store i8 2, ptr %gep.1, align 131; CHECK-SYMBOLIC-RDIV-NEXT: da analyze - none!32; CHECK-SYMBOLIC-RDIV-NEXT: Src: store i8 2, ptr %gep.1, align 1 --> Dst: store i8 2, ptr %gep.1, align 133; CHECK-SYMBOLIC-RDIV-NEXT: da analyze - consistent output [*]!34;35entry:36 br label %loop.header37 38loop.header:39 %i = phi i64 [ 0, %entry ], [ %i.inc, %loop.latch ]40 %offset = phi i64 [ -2, %entry ], [ %offset.next, %loop.latch ]41 %ec = icmp eq i64 %i, 461168601842738790442 br i1 %ec, label %exit, label %loop.body43 44loop.body:45 %cond = icmp sge i64 %offset, 046 br i1 %cond, label %if.then, label %loop.latch47 48if.then:49 %gep.0 = getelementptr inbounds i8, ptr %A, i64 %offset50 store i8 1, ptr %gep.051 br label %loop.latch52 53loop.latch:54 %gep.1 = getelementptr inbounds i8, ptr %A, i64 %i55 store i8 2, ptr %gep.156 %i.inc = add nuw nsw i64 %i, 157 %offset.next = add nsw i64 %offset, 258 br label %loop.header59 60exit:61 ret void62}63 64; offset0 = -4611686018427387904; // -2^6265; offset1 = 4611686018427387904; // 2^6266; for (i = 0; i < (1LL << 62) - 100; i++) {67; if (0 <= offset0)68; A[offset0] = 1;69; if (0 <= offset1)70; A[offset1] = 2;71; offset0 += 2;72; offset1 -= 1;73; }74;75; FIXME: DependenceAnalysis currently detects no dependency between the two76; stores, but it does exist. For example,77;78; memory access | i == 2^61 | i == 2^61 + 2^59 | i == 2^61 + 2^6079; -------------------------|-----------|------------------|-------------------80; A[2*i - 2^62] (offset0) | | A[2^60] | A[2^61]81; A[-i + 2^62] (offset1) | A[2^61] | | A[2^60]82;83; The root cause is that the calculation of the differenct between the two84; constants (-2^62 and 2^62) overflows in a signed sense.85define void @symbolicrdiv_delta_ovfl(ptr %A) {86; CHECK-ALL-LABEL: 'symbolicrdiv_delta_ovfl'87; CHECK-ALL-NEXT: Src: store i8 1, ptr %gep.0, align 1 --> Dst: store i8 1, ptr %gep.0, align 188; CHECK-ALL-NEXT: da analyze - none!89; CHECK-ALL-NEXT: Src: store i8 1, ptr %gep.0, align 1 --> Dst: store i8 2, ptr %gep.1, align 190; CHECK-ALL-NEXT: da analyze - none!91; CHECK-ALL-NEXT: Src: store i8 2, ptr %gep.1, align 1 --> Dst: store i8 2, ptr %gep.1, align 192; CHECK-ALL-NEXT: da analyze - none!93;94; CHECK-SYMBOLIC-RDIV-LABEL: 'symbolicrdiv_delta_ovfl'95; CHECK-SYMBOLIC-RDIV-NEXT: Src: store i8 1, ptr %gep.0, align 1 --> Dst: store i8 1, ptr %gep.0, align 196; CHECK-SYMBOLIC-RDIV-NEXT: da analyze - consistent output [*]!97; CHECK-SYMBOLIC-RDIV-NEXT: Src: store i8 1, ptr %gep.0, align 1 --> Dst: store i8 2, ptr %gep.1, align 198; CHECK-SYMBOLIC-RDIV-NEXT: da analyze - none!99; CHECK-SYMBOLIC-RDIV-NEXT: Src: store i8 2, ptr %gep.1, align 1 --> Dst: store i8 2, ptr %gep.1, align 1100; CHECK-SYMBOLIC-RDIV-NEXT: da analyze - consistent output [*]!101;102entry:103 br label %loop.header104 105loop.header:106 %i = phi i64 [ 0, %entry ], [ %i.inc, %loop.latch ]107 %offset.0 = phi i64 [ -4611686018427387904, %entry ], [ %offset.0.next, %loop.latch ]108 %offset.1 = phi i64 [ 4611686018427387904, %entry ], [ %offset.1.next, %loop.latch ]109 %cond.0 = icmp sge i64 %offset.0, 0110 %cond.1 = icmp sge i64 %offset.1, 0111 br i1 %cond.0, label %if.then.0, label %loop.middle112 113if.then.0:114 %gep.0 = getelementptr inbounds i8, ptr %A, i64 %offset.0115 store i8 1, ptr %gep.0116 br label %loop.middle117 118loop.middle:119 br i1 %cond.1, label %if.then.1, label %loop.latch120 121if.then.1:122 %gep.1 = getelementptr inbounds i8, ptr %A, i64 %offset.1123 store i8 2, ptr %gep.1124 br label %loop.latch125 126loop.latch:127 %i.inc = add nuw nsw i64 %i, 1128 %offset.0.next = add nsw i64 %offset.0, 2129 %offset.1.next = sub nsw i64 %offset.1, 1130 %ec = icmp eq i64 %i.inc, 4611686018427387804 ; 2^62 - 100131 br i1 %ec, label %exit, label %loop.header132 133exit:134 ret void135}136;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:137; CHECK: {{.*}}138