brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.3 KiB · 569bba0 Raw
182 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=gcd-miv 2>&1 \5; RUN:     | FileCheck %s --check-prefixes=CHECK,CHECK-GCD-MIV6 7; offset0 = 4;8; offset1 = 0;9; for (i = 0; i < 100; i++) {10;   A[offset0] = 1;11;   A[offset1] = 2;12;   offset0 += 3*m;13;   offset1 += 3;14; }15;16; Dependency exists between the two stores. E.g., consider `m` is17; 12297829382473034411, which is a modular multiplicative inverse of 3 under18; modulo 2^64. Then `offset0` is effectively `i + 4`, so accesses will be as19; follows:20;21;   - A[offset0] : A[4], A[5], A[6], ...22;   - A[offset1] : A[0], A[3], A[6], ...23;24define void @gcdmiv_coef_ovfl(ptr %A, i64 %m) {25; CHECK-ALL-LABEL: 'gcdmiv_coef_ovfl'26; CHECK-ALL-NEXT:  Src: store i8 1, ptr %gep.0, align 1 --> Dst: store i8 1, ptr %gep.0, align 127; CHECK-ALL-NEXT:    da analyze - none!28; CHECK-ALL-NEXT:  Src: store i8 1, ptr %gep.0, align 1 --> Dst: store i8 2, ptr %gep.1, align 129; CHECK-ALL-NEXT:    da analyze - output [*|<]!30; CHECK-ALL-NEXT:  Src: store i8 2, ptr %gep.1, align 1 --> Dst: store i8 2, ptr %gep.1, align 131; CHECK-ALL-NEXT:    da analyze - none!32;33; CHECK-GCD-MIV-LABEL: 'gcdmiv_coef_ovfl'34; CHECK-GCD-MIV-NEXT:  Src: store i8 1, ptr %gep.0, align 1 --> Dst: store i8 1, ptr %gep.0, align 135; CHECK-GCD-MIV-NEXT:    da analyze - consistent output [*]!36; CHECK-GCD-MIV-NEXT:  Src: store i8 1, ptr %gep.0, align 1 --> Dst: store i8 2, ptr %gep.1, align 137; CHECK-GCD-MIV-NEXT:    da analyze - consistent output [*|<]!38; CHECK-GCD-MIV-NEXT:  Src: store i8 2, ptr %gep.1, align 1 --> Dst: store i8 2, ptr %gep.1, align 139; CHECK-GCD-MIV-NEXT:    da analyze - consistent output [*]!40;41entry:42  %step = mul i64 3, %m43  br label %loop44 45loop:46  %i = phi i64 [ 0, %entry ], [ %i.inc, %loop ]47  %offset.0 = phi i64 [ 4, %entry ] , [ %offset.0.next, %loop ]48  %offset.1 = phi i64 [ 0, %entry ] , [ %offset.1.next, %loop ]49  %gep.0 = getelementptr inbounds i8, ptr %A, i64 %offset.050  %gep.1 = getelementptr inbounds i8, ptr %A, i64 %offset.151  store i8 1, ptr %gep.052  store i8 2, ptr %gep.153  %i.inc = add nuw nsw i64 %i, 154  %offset.0.next = add nsw i64 %offset.0, %step55  %offset.1.next = add nsw i64 %offset.1, 356  %ec = icmp eq i64 %i.inc, 10057  br i1 %ec, label %exit, label %loop58 59exit:60  ret void61}62 63; max_i = INT64_MAX/6  // 153722867280912930164; for (long long i = 0; i <= max_i; i++) {65;   A[-6*i + INT64_MAX] = 0;66;   if (i)67;     A[3*i - 2] = 1;68; }69;70; FIXME: DependenceAnalysis currently detects no dependency between the two71; stores, but it does exist. For example,72;73;  memory access       | i == 1 | i == (max_i + 1) / 2 | i == max_i74; ---------------------|--------|----------------------|-------------------75;  A[-6*i + INT64_MAX] |        | A[3*max_i - 2]       | A[1]76;  A[3*i - 2]          | A[1]   |                      | A[3*max_i - 2]77;78;79define void @gcdmiv_delta_ovfl(ptr %A) {80; CHECK-ALL-LABEL: 'gcdmiv_delta_ovfl'81; CHECK-ALL-NEXT:  Src: store i8 0, ptr %idx.0, align 1 --> Dst: store i8 0, ptr %idx.0, align 182; CHECK-ALL-NEXT:    da analyze - none!83; CHECK-ALL-NEXT:  Src: store i8 0, ptr %idx.0, align 1 --> Dst: store i8 1, ptr %idx.1, align 184; CHECK-ALL-NEXT:    da analyze - none!85; CHECK-ALL-NEXT:  Src: store i8 1, ptr %idx.1, align 1 --> Dst: store i8 1, ptr %idx.1, align 186; CHECK-ALL-NEXT:    da analyze - none!87;88; CHECK-GCD-MIV-LABEL: 'gcdmiv_delta_ovfl'89; CHECK-GCD-MIV-NEXT:  Src: store i8 0, ptr %idx.0, align 1 --> Dst: store i8 0, ptr %idx.0, align 190; CHECK-GCD-MIV-NEXT:    da analyze - consistent output [*]!91; CHECK-GCD-MIV-NEXT:  Src: store i8 0, ptr %idx.0, align 1 --> Dst: store i8 1, ptr %idx.1, align 192; CHECK-GCD-MIV-NEXT:    da analyze - consistent output [*|<]!93; CHECK-GCD-MIV-NEXT:  Src: store i8 1, ptr %idx.1, align 1 --> Dst: store i8 1, ptr %idx.1, align 194; CHECK-GCD-MIV-NEXT:    da analyze - consistent output [*]!95;96entry:97  br label %loop.header98 99loop.header:100  %i = phi i64 [ 0, %entry ], [ %i.inc, %loop.latch ]101  %subscript.0 = phi i64 [ 9223372036854775807, %entry ], [ %subscript.0.next, %loop.latch ]102  %subscript.1 = phi i64 [ -2, %entry ], [ %subscript.1.next, %loop.latch ]103  %idx.0 = getelementptr inbounds i8, ptr %A, i64 %subscript.0104  store i8 0, ptr %idx.0105  %cond.store = icmp ne i64 %i, 0106  br i1 %cond.store, label %if.store, label %loop.latch107 108if.store:109  %idx.1 = getelementptr i8, ptr %A, i64 %subscript.1110  store i8 1, ptr %idx.1111  br label %loop.latch112 113loop.latch:114  %i.inc = add nuw nsw i64 %i, 1115  %subscript.0.next = add nsw i64 %subscript.0, -6116  %subscript.1.next = add nsw i64 %subscript.1, 3117  %exitcond = icmp sgt i64 %i.inc, 1537228672809129301118  br i1 %exitcond, label %exit, label %loop.header119 120exit:121  ret void122}123 124; max_i = INT64_MAX/3  // 3074457345618258602125; for (i = 0; i < max_i; i++) {126;   A[3*i] = 0;127;   A[-3*i - 3*m - INT64_MAX] = 1;128; }129;130; Dependency may exist between the two stores. For example, consider `m = 1`.131; Then, `-3*m - INT64_MAX` is `INT64_MAX - 1`. So `-3*i - 3*m - INT64_MAX` is132; effectively `-3*i + (INT64_MAX - 1)`. Thus, accesses will be as follows:133;134;  memory access             | i == 1           | i == max_i - 1135; ---------------------------|------------------|------------------136;  A[3*i]                    | A[3]             | A[INT64_MAX - 4]137;  A[-3*i - 3*m - INT64_MAX] | A[INT64_MAX - 4] | A[3]138;139 140define void @gcdmiv_const_ovfl(ptr %A, i64 %m) {141; CHECK-ALL-LABEL: 'gcdmiv_const_ovfl'142; CHECK-ALL-NEXT:  Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 0, ptr %gep.0, align 1143; CHECK-ALL-NEXT:    da analyze - none!144; CHECK-ALL-NEXT:  Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 1, ptr %gep.1, align 1145; CHECK-ALL-NEXT:    da analyze - output [*|<]!146; CHECK-ALL-NEXT:  Src: store i8 1, ptr %gep.1, align 1 --> Dst: store i8 1, ptr %gep.1, align 1147; CHECK-ALL-NEXT:    da analyze - none!148;149; CHECK-GCD-MIV-LABEL: 'gcdmiv_const_ovfl'150; CHECK-GCD-MIV-NEXT:  Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 0, ptr %gep.0, align 1151; CHECK-GCD-MIV-NEXT:    da analyze - consistent output [*]!152; CHECK-GCD-MIV-NEXT:  Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 1, ptr %gep.1, align 1153; CHECK-GCD-MIV-NEXT:    da analyze - consistent output [*|<]!154; CHECK-GCD-MIV-NEXT:  Src: store i8 1, ptr %gep.1, align 1 --> Dst: store i8 1, ptr %gep.1, align 1155; CHECK-GCD-MIV-NEXT:    da analyze - consistent output [*]!156;157entry:158  %m.3 = mul nsw i64 -3, %m159  %const = sub i64 %m.3, 9223372036854775807160  %guard = icmp ne i64 %const, 0161  br i1 %guard, label %loop, label %exit162 163loop:164  %i = phi i64 [ 0, %entry ], [ %i.inc, %loop ]165  %offset.0 = phi i64 [ 0, %entry ], [ %offset.0.next, %loop ]166  %offset.1 = phi i64 [ %const, %entry ], [ %offset.1.next, %loop ]167  %gep.0 = getelementptr inbounds i8, ptr %A, i64 %offset.0168  %gep.1 = getelementptr inbounds i8, ptr %A, i64 %offset.1169  store i8 0, ptr %gep.0170  store i8 1, ptr %gep.1171  %i.inc = add nuw nsw i64 %i, 1172  %offset.0.next = add nsw i64 %offset.0, 3173  %offset.1.next = add nsw i64 %offset.1, -3174  %ec = icmp eq i64 %i.inc, 3074457345618258602175  br i1 %ec, label %exit, label %loop176 177exit:178  ret void179}180;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:181; CHECK: {{.*}}182