OLD | NEW |
(Empty) | |
| 1 ; This tests some of the subtleties of Phi lowering. In particular, |
| 2 ; it tests that it does the right thing when it tries to enable |
| 3 ; compare/branch fusing. |
| 4 |
| 5 ; RUN: %llvm2ice -O2 --verbose none --no-phi-edge-split %s \ |
| 6 ; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj \ |
| 7 ; RUN: | llvm-objdump -d -symbolize -x86-asm-syntax=intel - | FileCheck %s |
| 8 ; RUN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s |
| 9 ; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s |
| 10 ; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \ |
| 11 ; RUN: | FileCheck --check-prefix=DUMP %s |
| 12 |
| 13 define internal i32 @testPhi1(i32 %arg) { |
| 14 entry: |
| 15 %cmp1 = icmp sgt i32 %arg, 0 |
| 16 br i1 %cmp1, label %next, label %target |
| 17 next: |
| 18 br label %target |
| 19 target: |
| 20 %merge = phi i1 [ %cmp1, %entry ], [ false, %next ] |
| 21 %result = zext i1 %merge to i32 |
| 22 ret i32 %result |
| 23 } |
| 24 ; Test that compare/branch fusing does not happen, and Phi lowering is |
| 25 ; put in the right place. |
| 26 ; CHECK-LABEL: testPhi1 |
| 27 ; CHECK: cmp {{.*}}, 0 |
| 28 ; CHECK: mov {{.*}}, 1 |
| 29 ; CHECK: jg |
| 30 ; CHECK: mov {{.*}}, 0 |
| 31 ; CHECK: mov [[PHI:.*]], |
| 32 ; CHECK: cmp {{.*}}, 0 |
| 33 ; CHECK: jne |
| 34 ; CHECK: : |
| 35 ; CHECK: mov [[PHI]], 0 |
| 36 ; CHECK: : |
| 37 ; CHECK: movzx {{.*}}, [[PHI]] |
| 38 |
| 39 define internal i32 @testPhi2(i32 %arg) { |
| 40 entry: |
| 41 %cmp1 = icmp sgt i32 %arg, 0 |
| 42 br i1 %cmp1, label %next, label %target |
| 43 next: |
| 44 br label %target |
| 45 target: |
| 46 %merge = phi i32 [ 12345, %entry ], [ 54321, %next ] |
| 47 ret i32 %merge |
| 48 } |
| 49 ; Test that compare/branch fusing and Phi lowering happens as expected. |
| 50 ; CHECK-LABEL: testPhi2 |
| 51 ; CHECK: mov {{.*}}, 12345 |
| 52 ; CHECK: cmp {{.*}}, 0 |
| 53 ; CHECK-NEXT: jg |
| 54 ; CHECK: : |
| 55 ; CHECK: mov [[PHI:.*]], 54321 |
| 56 ; CHECK: : |
| 57 ; CHECK: mov {{.*}}, [[PHI]] |
| 58 |
| 59 ; ERRORS-NOT: ICE translation error |
| 60 ; DUMP-NOT: SZ |
OLD | NEW |