Chromium Code Reviews| Index: tests_lit/llvm2ice_tests/loop-nest-depth.ll |
| diff --git a/tests_lit/llvm2ice_tests/loop-nest-depth.ll b/tests_lit/llvm2ice_tests/loop-nest-depth.ll |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a1c7480843e589c4fb264aae33f35526762c954b |
| --- /dev/null |
| +++ b/tests_lit/llvm2ice_tests/loop-nest-depth.ll |
| @@ -0,0 +1,164 @@ |
| +; Test the the loop nest depth is correctly calculated for basic blocks. |
| + |
|
jvoung (off chromium)
2015/09/01 18:56:18
Can you check that this works with "make -f Makefi
ascull
2015/09/03 19:52:38
Yep, MINIAL=1 fails but the require fixes things.
|
| +; Single threaded so that the dumps used for checking happen in order |
| +; RUN: %p2i --filetype=obj --disassemble -i %s --args -O2 --verbose=loop \ |
| +; RUN: --threads=0 | FileCheck %s |
| + |
|
Jim Stichnoth
2015/09/01 22:17:38
I'd like to see at least one test with loops and p
ascull
2015/09/03 19:52:38
Does the early exit satisfy this need?
All test a
|
| +define void @test_single_loop(i1 %a) { |
|
jvoung (off chromium)
2015/09/01 18:56:18
Hmm, technically PNaCl does not allow i1 parameter
ascull
2015/09/03 19:52:38
Done.
|
| +entry: |
| + br label %loop0 |
| + |
| +loop0: ; <-+ |
| + br label %loop1 ; | |
| +loop1: ; | |
| + br i1 %a, label %loop0, label %out ; --+ |
| + |
| +out: |
| + ret void |
| +} |
| + |
|
jvoung (off chromium)
2015/09/01 18:56:18
Can you still CHECK-LABEL: test_single_loop
to he
ascull
2015/09/03 19:52:38
Done.
|
| +; CHECK: After loop nest depth analysis |
| +; CHECK-NEXT: LoopNestDepth = 0 |
| +; CHECK-NEXT: LoopNestDepth = 1 |
| +; CHECK-NEXT: LoopNestDepth = 1 |
| +; CHECK-NEXT: LoopNestDepth = 0 |
| + |
|
jvoung (off chromium)
2015/09/01 18:56:18
Could add a "negative" test -- some non-loopy code
ascull
2015/09/03 19:52:38
Done.
|
| +define void @test_single_loop_with_continue(i1 %a, i1 %b) { |
| +entry: |
| + br label %loop0 |
| + |
| +loop0: ; <-+ |
| + br label %loop1 ; | |
| +loop1: ; | |
| + br i1 %a, label %loop0, label %loop2 ; --+ |
| +loop2: ; | |
| + br i1 %b, label %loop0, label %out ; --+ |
| + |
| +out: |
| + ret void |
| +} |
| + |
| +; CHECK: After loop nest depth analysis |
| +; CHECK-NEXT: LoopNestDepth = 0 |
| +; CHECK-NEXT: LoopNestDepth = 1 |
| +; CHECK-NEXT: LoopNestDepth = 1 |
| +; CHECK-NEXT: LoopNestDepth = 1 |
| +; CHECK-NEXT: LoopNestDepth = 0 |
| + |
| +define void @test_two_nested_loops(i1 %a, i1 %b) { |
| +entry: |
| + br label %loop0_0 |
| + |
| +loop0_0: ; <---+ |
| + br label %loop1_0 ; | |
| +loop1_0: ; <-+ | |
| + br label %loop1_1 ; | | |
| +loop1_1: ; | | |
| + br i1 %a, label %loop1_0, label %loop0_1 ; --+ | |
| +loop0_1: ; | |
| + br i1 %b, label %loop0_0, label %out ; ----+ |
| + |
| +out: |
| + ret void |
| +} |
| + |
| +; CHECK: After loop nest depth analysis |
| +; CHECK-NEXT: LoopNestDepth = 0 |
| +; CHECK-NEXT: LoopNestDepth = 1 |
| +; CHECK-NEXT: LoopNestDepth = 2 |
| +; CHECK-NEXT: LoopNestDepth = 2 |
| +; CHECK-NEXT: LoopNestDepth = 1 |
| +; CHECK-NEXT: LoopNestDepth = 0 |
| + |
| +define void @test_two_nested_loops_with_continue(i1 %a, i1 %b, i1 %c) { |
| +entry: |
| + br label %loop0_0 |
| + |
| +loop0_0: ; <---+ |
| + br label %loop1_0 ; | |
| +loop1_0: ; <-+ | |
| + br label %loop1_1 ; | | |
| +loop1_1: ; | | |
| + br i1 %a, label %loop1_0, label %loop1_2 ; --+ | |
| +loop1_2: ; | | |
| + br i1 %a, label %loop1_0, label %loop0_1 ; --+ | |
| +loop0_1: ; | |
| + br i1 %b, label %loop0_0, label %out ; ----+ |
| + |
| +out: |
| + ret void |
| +} |
| + |
| +; CHECK: After loop nest depth analysis |
| +; CHECK-NEXT: LoopNestDepth = 0 |
| +; CHECK-NEXT: LoopNestDepth = 1 |
| +; CHECK-NEXT: LoopNestDepth = 2 |
| +; CHECK-NEXT: LoopNestDepth = 2 |
| +; CHECK-NEXT: LoopNestDepth = 2 |
| +; CHECK-NEXT: LoopNestDepth = 1 |
| +; CHECK-NEXT: LoopNestDepth = 0 |
| + |
| +define void @test_multiple_nested_loops(i1 %a, i1 %b) { |
| +entry: |
| + br label %loop0_0 |
| + |
| +loop0_0: ; <---+ |
| + br label %loop1_0 ; | |
| +loop1_0: ; <-+ | |
| + br label %loop1_1 ; | | |
| +loop1_1: ; | | |
| + br i1 %a, label %loop1_0, label %loop0_1 ; --+ | |
| +loop0_1: ; | |
| + br label %loop2_0 ; | |
| +loop2_0: ; <-+ | |
| + br label %loop2_1 ; | | |
| +loop2_1: ; | | |
| + br i1 %a, label %loop2_0, label %loop0_2 ; --+ | |
| +loop0_2: ; | |
| + br i1 %b, label %loop0_0, label %out ; ----+ |
| + |
| +out: |
| + ret void |
| +} |
| + |
| +; CHECK: After loop nest depth analysis |
| +; CHECK-NEXT: LoopNestDepth = 0 |
| +; CHECK-NEXT: LoopNestDepth = 1 |
| +; CHECK-NEXT: LoopNestDepth = 2 |
| +; CHECK-NEXT: LoopNestDepth = 2 |
| +; CHECK-NEXT: LoopNestDepth = 1 |
| +; CHECK-NEXT: LoopNestDepth = 2 |
| +; CHECK-NEXT: LoopNestDepth = 2 |
| +; CHECK-NEXT: LoopNestDepth = 1 |
| +; CHECK-NEXT: LoopNestDepth = 0 |
| + |
| +define void @test_three_nested_loops(i1 %a, i1 %b, i1 %c) { |
| +entry: |
| + br label %loop0_0 |
| + |
| +loop0_0: ; <-----+ |
| + br label %loop1_0 ; | |
| +loop1_0: ; <---+ | |
| + br label %loop2_0 ; | | |
| +loop2_0: ; <-+ | | |
| + br label %loop2_1 ; | | | |
| +loop2_1: ; | | | |
| + br i1 %a, label %loop2_0, label %loop1_1 ; --+ | | |
| +loop1_1: ; | | |
| + br i1 %b, label %loop1_0, label %loop0_1 ; ----+ | |
| +loop0_1: ; | |
| + br i1 %c, label %loop0_0, label %out ; ------+ |
| + |
| +out: |
| + ret void |
| +} |
| + |
| +; CHECK: After loop nest depth analysis |
| +; CHECK-NEXT: LoopNestDepth = 0 |
| +; CHECK-NEXT: LoopNestDepth = 1 |
| +; CHECK-NEXT: LoopNestDepth = 2 |
| +; CHECK-NEXT: LoopNestDepth = 3 |
| +; CHECK-NEXT: LoopNestDepth = 3 |
| +; CHECK-NEXT: LoopNestDepth = 2 |
| +; CHECK-NEXT: LoopNestDepth = 1 |
| +; CHECK-NEXT: LoopNestDepth = 0 |