brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.4 KiB · ba57c7b Raw
126 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=weak-crossing-siv 2>&1 \5; RUN:     | FileCheck %s --check-prefixes=CHECK,CHECK-WEAK-CROSSING-SIV6 7; max_i = INT64_MAX/3  // 30744573456182586028; 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 between15; `A[-3*i + INT64_MAX]` and `A[3*i - 2]`, but it does exist. For example,16;17;  memory access       | i == 1           | i == max_i18; ---------------------|------------------|------------------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 two23; constants (INT64_MAX and -2) triggers an overflow.24 25define 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 128; 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 130; 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 132; 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 136; 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 138; 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 140; CHECK-WEAK-CROSSING-SIV-NEXT:    da analyze - consistent output [*]!41;42entry:43  br label %loop.header44 45loop.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.050  store i8 0, ptr %idx.051  %cond.store = icmp ne i64 %i, 052  br i1 %cond.store, label %if.store, label %loop.latch53 54if.store:55  %idx.1 = getelementptr inbounds i8, ptr %A, i64 %subscript.156  store i8 1, ptr %idx.157  br label %loop.latch58 59loop.latch:60  %i.inc = add nuw nsw i64 %i, 161  %subscript.0.next = add nsw i64 %subscript.0, -362  %subscript.1.next = add nsw i64 %subscript.1, 363  %ec = icmp sgt i64 %i.inc, 307445734561825860264  br i1 %ec, label %exit, label %loop.header65 66exit:67  ret void68}69 70; max_i = INT64_MAX/3  // 307445734561825860271; 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 between77; `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_i80; ---------------------|--------|------------------|----------------|------------------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 285; triggers an overflow.86;87define 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 190; 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 192; 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 194; 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 198; 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 1100; 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 1102; CHECK-WEAK-CROSSING-SIV-NEXT:    da analyze - consistent output [*]!103;104entry:105  br label %loop106 107loop: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.0112  %idx.1 = getelementptr inbounds i8, ptr %A, i64 %subscript.1113  store i8 0, ptr %idx.0114  store i8 1, ptr %idx.1115  %i.inc = add nuw nsw i64 %i, 1116  %subscript.0.next = add nsw i64 %subscript.0, -3117  %subscript.1.next = add nsw i64 %subscript.1, 3118  %ec = icmp sgt i64 %i.inc, 3074457345618258602119  br i1 %ec, label %exit, label %loop120 121exit:122  ret void123}124;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:125; CHECK: {{.*}}126