Anna Thomas | e27b39a | 2017-03-22 19:27:12 +0000 | [diff] [blame^] | 1 | ; RUN: opt < %s -jump-threading -print-lazy-value-info -disable-output 2>&1 | FileCheck %s |
| 2 | |
| 3 | ; Testing LVI cache after jump-threading |
| 4 | |
| 5 | ; Jump-threading transforms the IR below to one where |
| 6 | ; loop and backedge basic blocks are merged into one. |
| 7 | ; basic block (named backedge) with the branch being: |
| 8 | ; %cont = icmp slt i32 %iv.next, 400 |
| 9 | ; br i1 %cont, label %backedge, label %exit |
| 10 | define i8 @test1(i32 %a, i32 %length) { |
| 11 | ; CHECK-LABEL: LVI for function 'test1': |
| 12 | entry: |
| 13 | br label %loop |
| 14 | ; CHECK-LABEL: backedge: |
| 15 | ; CHECK-NEXT: ; CachedLatticeValues for: ' %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]' |
| 16 | ; CHECK-DAG: ; at beginning of BasicBlock: '%backedge' LatticeVal: 'constantrange<0, 400>' |
| 17 | ; CHECK-NEXT: %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ] |
| 18 | ; CHECK-NEXT: ; CachedLatticeValues for: ' %iv.next = add nsw i32 %iv, 1' |
| 19 | ; CHECK-NEXT: ; at beginning of BasicBlock: '%backedge' LatticeVal: 'constantrange<1, 401>' |
| 20 | ; CHECK-NEXT: %iv.next = add nsw i32 %iv, 1 |
| 21 | ; CHECK-NEXT: %cont = icmp slt i32 %iv.next, 400 |
| 22 | ; CHECK-NEXT: br i1 %cont, label %backedge, label %exit |
| 23 | |
| 24 | ; CHECK-NOT: loop |
| 25 | loop: |
| 26 | %iv = phi i32 [0, %entry], [%iv.next, %backedge] |
| 27 | %cnd = icmp sge i32 %iv, 0 |
| 28 | br i1 %cnd, label %backedge, label %exit |
| 29 | |
| 30 | backedge: |
| 31 | %iv.next = add nsw i32 %iv, 1 |
| 32 | %cont = icmp slt i32 %iv.next, 400 |
| 33 | br i1 %cont, label %loop, label %exit |
| 34 | |
| 35 | exit: |
| 36 | ret i8 0 |
| 37 | } |
| 38 | |
| 39 | |
| 40 | ; Here JT does not transform the code, but LVICache is populated during the processing of blocks. |
| 41 | define i8 @test2(i32 %n) { |
| 42 | ; CHECK-LABEL: LVI for function 'test2': |
| 43 | ; CHECK-LABEL: entry: |
| 44 | ; CHECK-LABEL: ; OverDefined values for block are: |
| 45 | ; CHECK-NEXT: ;i32 %n |
| 46 | ; CHECK-NEXT: br label %loop |
| 47 | entry: |
| 48 | br label %loop |
| 49 | |
| 50 | ; CHECK-LABEL: loop: |
| 51 | ; CHECK-LABEL: ; OverDefined values for block are: |
| 52 | ; CHECK-NEXT: ; %iv2 = phi i32 [ %n, %entry ], [ %iv2.next, %backedge ] |
| 53 | ; CHECK-NEXT: ; CachedLatticeValues for: ' %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]' |
| 54 | ; CHECK-DAG: ; at beginning of BasicBlock: '%loop' LatticeVal: 'constantrange<0, -2147483647>' |
| 55 | ; CHECK-DAG: ; at beginning of BasicBlock: '%backedge' LatticeVal: 'constantrange<0, -2147483648>' |
| 56 | ; CHECK-NEXT: %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ] |
| 57 | ; CHECK: %cnd = and i1 %cnd1, %cnd2 |
| 58 | ; CHECK: br i1 %cnd, label %backedge, label %exit |
| 59 | loop: |
| 60 | %iv = phi i32 [0, %entry], [%iv.next, %backedge] |
| 61 | %iv2 = phi i32 [%n, %entry], [%iv2.next, %backedge] |
| 62 | %cnd1 = icmp sge i32 %iv, 0 |
| 63 | %cnd2 = icmp sgt i32 %iv2, 0 |
| 64 | %cnd = and i1 %cnd1, %cnd2 |
| 65 | br i1 %cnd, label %backedge, label %exit |
| 66 | |
| 67 | ; CHECK-LABEL: backedge: |
| 68 | ; CHECK-NEXT: ; CachedLatticeValues for: ' %iv.next = add nsw i32 %iv, 1' |
| 69 | ; CHECK-NEXT: ; at beginning of BasicBlock: '%backedge' LatticeVal: 'constantrange<1, -2147483647>' |
| 70 | ; CHECK-NEXT: %iv.next = add nsw i32 %iv, 1 |
| 71 | ; CHECK-NEXT: %iv2.next = sub nsw i32 %iv2, 1 |
| 72 | ; CHECK: %cont = and i1 %cont1, %cont2 |
| 73 | ; CHECK: br i1 %cont, label %loop, label %exit |
| 74 | backedge: |
| 75 | %iv.next = add nsw i32 %iv, 1 |
| 76 | %iv2.next = sub nsw i32 %iv2, 1 |
| 77 | %cont1 = icmp slt i32 %iv.next, 400 |
| 78 | %cont2 = icmp sgt i32 %iv2.next, 0 |
| 79 | %cont = and i1 %cont1, %cont2 |
| 80 | br i1 %cont, label %loop, label %exit |
| 81 | |
| 82 | exit: |
| 83 | ret i8 0 |
| 84 | } |