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: |
Anna Thomas | 4acfc7e | 2017-06-06 19:25:31 +0000 | [diff] [blame^] | 13 | ; CHECK-LABEL: entry: |
| 14 | ; CHECK-NEXT: ; LatticeVal for: 'i32 %a' is: overdefined |
| 15 | ; CHECK-NEXT: ; LatticeVal for: 'i32 %length' is: overdefined |
Anna Thomas | e27b39a | 2017-03-22 19:27:12 +0000 | [diff] [blame] | 16 | br label %loop |
Anna Thomas | e27b39a | 2017-03-22 19:27:12 +0000 | [diff] [blame] | 17 | |
Anna Thomas | 4acfc7e | 2017-06-06 19:25:31 +0000 | [diff] [blame^] | 18 | ; CHECK-LABEL: backedge: |
| 19 | ; CHECK-NEXT: ; LatticeVal for: 'i32 %a' is: overdefined |
| 20 | ; CHECK-NEXT: ; LatticeVal for: 'i32 %length' is: overdefined |
| 21 | ; CHECK-NEXT: ; LatticeVal for: ' %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]' in BB: '%backedge' is: constantrange<0, 400> |
| 22 | ; CHECK-NEXT: ; LatticeVal for: ' %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]' in BB: '%exit' is: constantrange<399, 400> |
| 23 | ; CHECK-NEXT: %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ] |
| 24 | ; CHECK-NEXT: ; LatticeVal for: ' %iv.next = add nsw i32 %iv, 1' in BB: '%backedge' is: constantrange<1, 401> |
| 25 | ; CHECK-NEXT: ; LatticeVal for: ' %iv.next = add nsw i32 %iv, 1' in BB: '%exit' is: constantrange<400, 401> |
| 26 | ; CHECK-NEXT: %iv.next = add nsw i32 %iv, 1 |
| 27 | ; CHECK-NEXT: ; LatticeVal for: ' %cont = icmp slt i32 %iv.next, 400' in BB: '%backedge' is: overdefined |
| 28 | ; CHECK-NEXT: ; LatticeVal for: ' %cont = icmp slt i32 %iv.next, 400' in BB: '%exit' is: constantrange<0, -1> |
| 29 | ; CHECK-NEXT: %cont = icmp slt i32 %iv.next, 400 |
Anna Thomas | e27b39a | 2017-03-22 19:27:12 +0000 | [diff] [blame] | 30 | ; CHECK-NOT: loop |
| 31 | loop: |
| 32 | %iv = phi i32 [0, %entry], [%iv.next, %backedge] |
| 33 | %cnd = icmp sge i32 %iv, 0 |
| 34 | br i1 %cnd, label %backedge, label %exit |
| 35 | |
| 36 | backedge: |
| 37 | %iv.next = add nsw i32 %iv, 1 |
| 38 | %cont = icmp slt i32 %iv.next, 400 |
| 39 | br i1 %cont, label %loop, label %exit |
| 40 | |
| 41 | exit: |
| 42 | ret i8 0 |
| 43 | } |
| 44 | |
Anna Thomas | e27b39a | 2017-03-22 19:27:12 +0000 | [diff] [blame] | 45 | ; Here JT does not transform the code, but LVICache is populated during the processing of blocks. |
| 46 | define i8 @test2(i32 %n) { |
| 47 | ; CHECK-LABEL: LVI for function 'test2': |
| 48 | ; CHECK-LABEL: entry: |
Anna Thomas | 4acfc7e | 2017-06-06 19:25:31 +0000 | [diff] [blame^] | 49 | ; CHECK-NEXT: ; LatticeVal for: 'i32 %n' is: overdefined |
Anna Thomas | e27b39a | 2017-03-22 19:27:12 +0000 | [diff] [blame] | 50 | ; CHECK-NEXT: br label %loop |
| 51 | entry: |
| 52 | br label %loop |
| 53 | |
| 54 | ; CHECK-LABEL: loop: |
Anna Thomas | 4acfc7e | 2017-06-06 19:25:31 +0000 | [diff] [blame^] | 55 | ; CHECK-NEXT: ; LatticeVal for: 'i32 %n' is: overdefined |
| 56 | ; CHECK-NEXT: ; LatticeVal for: ' %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]' in BB: '%loop' is: constantrange<0, -2147483647> |
| 57 | ; CHECK-DAG: ; LatticeVal for: ' %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]' in BB: '%backedge' is: constantrange<0, -2147483648> |
| 58 | ; CHECK-DAG: ; LatticeVal for: ' %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]' in BB: '%exit' is: constantrange<0, -2147483647> |
| 59 | ; CHECK-NEXT: %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ] |
Anna Thomas | e27b39a | 2017-03-22 19:27:12 +0000 | [diff] [blame] | 60 | loop: |
| 61 | %iv = phi i32 [0, %entry], [%iv.next, %backedge] |
Anna Thomas | 4acfc7e | 2017-06-06 19:25:31 +0000 | [diff] [blame^] | 62 | ; CHECK-NEXT: ; LatticeVal for: ' %iv2 = phi i32 [ %n, %entry ], [ %iv2.next, %backedge ]' in BB: '%loop' is: overdefined |
| 63 | ; CHECK-DAG: ; LatticeVal for: ' %iv2 = phi i32 [ %n, %entry ], [ %iv2.next, %backedge ]' in BB: '%backedge' is: constantrange<1, -2147483648> |
| 64 | ; CHECK-DAG: ; LatticeVal for: ' %iv2 = phi i32 [ %n, %entry ], [ %iv2.next, %backedge ]' in BB: '%exit' is: overdefined |
| 65 | ; CHECK-NEXT: %iv2 = phi i32 [ %n, %entry ], [ %iv2.next, %backedge ] |
Anna Thomas | e27b39a | 2017-03-22 19:27:12 +0000 | [diff] [blame] | 66 | %iv2 = phi i32 [%n, %entry], [%iv2.next, %backedge] |
Anna Thomas | 4acfc7e | 2017-06-06 19:25:31 +0000 | [diff] [blame^] | 67 | |
| 68 | ; CHECK-NEXT: ; LatticeVal for: ' %cnd1 = icmp sge i32 %iv, 0' in BB: '%loop' is: overdefined |
| 69 | ; CHECK-DAG: ; LatticeVal for: ' %cnd1 = icmp sge i32 %iv, 0' in BB: '%backedge' is: overdefined |
| 70 | ; CHECK-DAG: ; LatticeVal for: ' %cnd1 = icmp sge i32 %iv, 0' in BB: '%exit' is: overdefined |
| 71 | ; CHECK-NEXT: %cnd1 = icmp sge i32 %iv, 0 |
Anna Thomas | e27b39a | 2017-03-22 19:27:12 +0000 | [diff] [blame] | 72 | %cnd1 = icmp sge i32 %iv, 0 |
| 73 | %cnd2 = icmp sgt i32 %iv2, 0 |
Anna Thomas | 4acfc7e | 2017-06-06 19:25:31 +0000 | [diff] [blame^] | 74 | ; CHECK: %cnd2 = icmp sgt i32 %iv2, 0 |
| 75 | ; CHECK: ; LatticeVal for: ' %cnd = and i1 %cnd1, %cnd2' in BB: '%loop' is: overdefined |
| 76 | ; CHECK-DAG: ; LatticeVal for: ' %cnd = and i1 %cnd1, %cnd2' in BB: '%backedge' is: constantrange<-1, 0> |
| 77 | ; CHECK-DAG: ; LatticeVal for: ' %cnd = and i1 %cnd1, %cnd2' in BB: '%exit' is: overdefined |
| 78 | ; CHECK-NEXT: %cnd = and i1 %cnd1, %cnd2 |
Anna Thomas | e27b39a | 2017-03-22 19:27:12 +0000 | [diff] [blame] | 79 | %cnd = and i1 %cnd1, %cnd2 |
| 80 | br i1 %cnd, label %backedge, label %exit |
| 81 | |
| 82 | ; CHECK-LABEL: backedge: |
Anna Thomas | 4acfc7e | 2017-06-06 19:25:31 +0000 | [diff] [blame^] | 83 | ; CHECK-NEXT: ; LatticeVal for: 'i32 %n' is: overdefined |
| 84 | ; CHECK-NEXT: ; LatticeVal for: ' %iv.next = add nsw i32 %iv, 1' in BB: '%backedge' is: constantrange<1, -2147483647> |
| 85 | ; CHECK-NEXT: %iv.next = add nsw i32 %iv, 1 |
Anna Thomas | e27b39a | 2017-03-22 19:27:12 +0000 | [diff] [blame] | 86 | backedge: |
| 87 | %iv.next = add nsw i32 %iv, 1 |
| 88 | %iv2.next = sub nsw i32 %iv2, 1 |
Anna Thomas | 4acfc7e | 2017-06-06 19:25:31 +0000 | [diff] [blame^] | 89 | ; CHECK: ; LatticeVal for: ' %cont1 = icmp slt i32 %iv.next, 400' in BB: '%backedge' is: overdefined |
| 90 | ; CHECK-NEXT: %cont1 = icmp slt i32 %iv.next, 400 |
Anna Thomas | e27b39a | 2017-03-22 19:27:12 +0000 | [diff] [blame] | 91 | %cont1 = icmp slt i32 %iv.next, 400 |
Anna Thomas | 4acfc7e | 2017-06-06 19:25:31 +0000 | [diff] [blame^] | 92 | ; CHECK-NEXT: ; LatticeVal for: ' %cont2 = icmp sgt i32 %iv2.next, 0' in BB: '%backedge' is: overdefined |
| 93 | ; CHECK-NEXT: %cont2 = icmp sgt i32 %iv2.next, 0 |
Anna Thomas | e27b39a | 2017-03-22 19:27:12 +0000 | [diff] [blame] | 94 | %cont2 = icmp sgt i32 %iv2.next, 0 |
Anna Thomas | 4acfc7e | 2017-06-06 19:25:31 +0000 | [diff] [blame^] | 95 | ; CHECK-NEXT: ; LatticeVal for: ' %cont = and i1 %cont1, %cont2' in BB: '%backedge' is: overdefined |
| 96 | ; CHECK-NEXT: %cont = and i1 %cont1, %cont2 |
Anna Thomas | e27b39a | 2017-03-22 19:27:12 +0000 | [diff] [blame] | 97 | %cont = and i1 %cont1, %cont2 |
| 98 | br i1 %cont, label %loop, label %exit |
| 99 | |
| 100 | exit: |
| 101 | ret i8 0 |
| 102 | } |