Chromium Code Reviews| Index: tests_lit/llvm2ice_tests/phi.ll |
| diff --git a/tests_lit/llvm2ice_tests/phi.ll b/tests_lit/llvm2ice_tests/phi.ll |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..88ef8fc3e1a262b2c3e04490bef0c0a7871abe4e |
| --- /dev/null |
| +++ b/tests_lit/llvm2ice_tests/phi.ll |
| @@ -0,0 +1,58 @@ |
| +; This tests some of the subtleties of Phi lowering. In particular, |
| +; it tests that it does the right thing when it tries to enable |
| +; compare/branch fusing. |
| + |
| +; RUN: %llvm2ice -O2 --verbose none --no-phi-edge-split %s \ |
| +; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj \ |
| +; RUN: | llvm-objdump -d -symbolize -x86-asm-syntax=intel - | FileCheck %s |
| +; RUN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s |
| +; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s |
| +; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \ |
| +; RUN: | FileCheck --check-prefix=DUMP %s |
| + |
| +define internal i32 @testPhi1(i32 %arg) { |
| +entry: |
| + %cmp1 = icmp sgt i32 %arg, 0 |
| + br i1 %cmp1, label %next, label %target |
| +next: |
| + br label %target |
| +target: |
| + %merge = phi i1 [ %cmp1, %entry ], [ false, %next ] |
| + %result = zext i1 %merge to i32 |
| + ret i32 %result |
| +} |
| +; Test that compare/branch fusing does not happen, and Phi lowering is |
| +; put in the right place. |
| +; CHECK-LABEL: testPhi1 |
| +; CHECK: cmp {{.*}}, 0 |
| +; CHECK: mov {{.*}}, 1 |
| +; CHECK: jg |
| +; CHECK: mov {{.*}}, 0 |
| +; CHECK: mov [[PHI:.*]], |
| +; CHECK: cmp {{.*}}, 0 |
|
jvoung (off chromium)
2014/09/10 17:17:43
Would it be clearer to check for another jump? (th
Jim Stichnoth
2014/09/10 18:29:16
The problem I had is that the current code generat
|
| +; CHECK: : |
| +; CHECK: mov [[PHI]], 0 |
| +; CHECK: : |
| +; CHECK: movzx {{.*}}, [[PHI]] |
| + |
| +define internal i32 @testPhi2(i32 %arg) { |
| +entry: |
| + %cmp1 = icmp sgt i32 %arg, 0 |
| + br i1 %cmp1, label %next, label %target |
| +next: |
| + br label %target |
| +target: |
| + %merge = phi i32 [ %arg, %entry ], [ 0, %next ] |
|
jvoung (off chromium)
2014/09/10 17:17:43
If you change the %arg to a recognizable constant,
Jim Stichnoth
2014/09/10 18:29:16
Good idea, done.
|
| + ret i32 %merge |
| +} |
| +; Test that compare/branch fusing and Phi lowering happens as expected. |
| +; CHECK-LABEL: testPhi2 |
| +; CHECK: cmp {{.*}}, 0 |
| +; CHECK: jg |
|
jvoung (off chromium)
2014/09/10 17:17:43
Should this be CHECK-NEXT?
Jim Stichnoth
2014/09/10 18:29:16
Done.
|
| +; CHECK: : |
| +; CHECK: mov [[PHI:.*]], 0 |
| +; CHECK: : |
| +; CHECK: mov {{.*}}, [[PHI]] |
| + |
| +; ERRORS-NOT: ICE translation error |
| +; DUMP-NOT: SZ |