|
| 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>" -da-dump-monotonicity-report \ |
| 3 | +; RUN: -da-enable-monotonicity-check 2>&1 | FileCheck %s |
| 4 | + |
| 5 | +; The offset SCEV will be delinearized into a 2D array access, like as follows: |
| 6 | +; |
| 7 | +; - Outer subscript: {0,+,1}<nuw><nsw><%loop.i.header> |
| 8 | +; - Inner subscript: {0,+,1}<nuw><nsw><%loop.j.header> |
| 9 | +; |
| 10 | +; These subscripts are both monotonic, but we also need to check the |
| 11 | +; monotonicity of the original addrec. |
| 12 | +; |
| 13 | +; char A[...][32]; |
| 14 | +; for (i = 0; i < 1ll << 62; i++) |
| 15 | +; for (j = 0; j < 32; j++) |
| 16 | +; if (i < (1ll << 57)) |
| 17 | +; A[i][j] = 0; |
| 18 | +; |
| 19 | +define void @linearized_offset_wrap(ptr %a) { |
| 20 | +; CHECK-LABEL: 'linearized_offset_wrap' |
| 21 | +; CHECK-NEXT: Monotonicity check: |
| 22 | +; CHECK-NEXT: Inst: store i8 0, ptr %gep, align 1 |
| 23 | +; CHECK-NEXT: Expr: {{\{\{}}0,+,32}<%loop.i.header>,+,1}<nw><%loop.j.header> |
| 24 | +; CHECK-NEXT: Monotonicity: Unknown |
| 25 | +; CHECK-NEXT: Reason: {{\{\{}}0,+,32}<%loop.i.header>,+,1}<nw><%loop.j.header> |
| 26 | +; CHECK-EMPTY: |
| 27 | +; CHECK-NEXT: Src: store i8 0, ptr %gep, align 1 --> Dst: store i8 0, ptr %gep, align 1 |
| 28 | +; CHECK-NEXT: da analyze - confused! |
| 29 | +; |
| 30 | +entry: |
| 31 | + br label %loop.i.header |
| 32 | + |
| 33 | +loop.i.header: |
| 34 | + %i = phi i64 [ 0, %entry ], [ %i.inc, %loop.i.latch ] |
| 35 | + br label %loop.j.header |
| 36 | + |
| 37 | +loop.j.header: |
| 38 | + %j = phi i64 [ 0, %loop.i.header ], [ %j.inc, %loop.j.latch ] |
| 39 | + %cond = icmp slt i64 %i, 144115188075855872 ; 2^57 |
| 40 | + br i1 %cond, label %if.then, label %loop.j.latch |
| 41 | + |
| 42 | +if.then: |
| 43 | + %gep = getelementptr inbounds [32 x i8], ptr %a, i64 %i, i64 %j |
| 44 | + store i8 0, ptr %gep |
| 45 | + br label %loop.j.latch |
| 46 | + |
| 47 | +loop.j.latch: |
| 48 | + %j.inc = add nuw nsw i64 %j, 1 |
| 49 | + %ec.j = icmp eq i64 %j.inc, 32 |
| 50 | + br i1 %ec.j, label %loop.i.latch, label %loop.j.header |
| 51 | + |
| 52 | +loop.i.latch: |
| 53 | + %i.inc = add nuw nsw i64 %i, 1 |
| 54 | + %ec.i = icmp eq i64 %i.inc, 4611686018427387904 ; 2^62 |
| 55 | + br i1 %ec.i, label %exit, label %loop.i.header |
| 56 | + |
| 57 | +exit: |
| 58 | + ret void |
| 59 | +} |
0 commit comments