| OLD | NEW |
| 1 ; Tests the branch optimizations under O2 (against a lack of | 1 ; Tests the branch optimizations under O2 (against a lack of |
| 2 ; optimizations under Om1). | 2 ; optimizations under Om1). |
| 3 | 3 |
| 4 ; RUN: %p2i -i %s --args -O2 --verbose none \ | 4 ; RUN: %p2i -i %s --args -O2 --verbose none \ |
| 5 ; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj \ | 5 ; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj \ |
| 6 ; RUN: | llvm-objdump -d -symbolize -x86-asm-syntax=intel - \ | 6 ; RUN: | llvm-objdump -d -symbolize -x86-asm-syntax=intel - \ |
| 7 ; RUN: | FileCheck --check-prefix=O2 %s | 7 ; RUN: | FileCheck --check-prefix=O2 %s |
| 8 ; RUN: %p2i -i %s --args -Om1 --verbose none \ | 8 ; RUN: %p2i -i %s --args -Om1 --verbose none \ |
| 9 ; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj \ | 9 ; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj \ |
| 10 ; RUN: | llvm-objdump -d -symbolize -x86-asm-syntax=intel - \ | 10 ; RUN: | llvm-objdump -d -symbolize -x86-asm-syntax=intel - \ |
| 11 ; RUN: | FileCheck --check-prefix=OM1 %s | 11 ; RUN: | FileCheck --check-prefix=OM1 %s |
| 12 ; RUN: %p2i -i %s --args --verbose none | FileCheck --check-prefix=ERRORS %s | 12 ; RUN: %p2i -i %s --args --verbose none | FileCheck --check-prefix=ERRORS %s |
| 13 ; RUN: %p2i -i %s --insts | %szdiff %s | FileCheck --check-prefix=DUMP %s | 13 ; RUN: %p2i -i %s --insts | %szdiff %s | FileCheck --check-prefix=DUMP %s |
| 14 | 14 |
| 15 declare void @dummy() | 15 declare void @dummy() |
| 16 | 16 |
| 17 ; An unconditional branch to the next block should be removed. | 17 ; An unconditional branch to the next block should be removed. |
| 18 define void @testUncondToNextBlock() { | 18 define void @testUncondToNextBlock() { |
| 19 entry: | 19 entry: |
| 20 call void @dummy() | 20 call void @dummy() |
| 21 br label %next | 21 br label %next |
| 22 next: | 22 next: |
| 23 call void @dummy() | 23 call void @dummy() |
| 24 ret void | 24 ret void |
| 25 } | 25 } |
| 26 ; O2-LABEL: testUncondToNextBlock | 26 ; O2-LABEL: testUncondToNextBlock |
| 27 ; O2: call | 27 ; O2: call |
| 28 ; O2-NEXT: call | 28 ; There will be nops for bundle align to end (for NaCl), but there should |
| 29 ; not be a branch. |
| 30 ; O2-NOT: j |
| 31 ; O2: call |
| 29 | 32 |
| 30 ; OM1-LABEL: testUncondToNextBlock | 33 ; OM1-LABEL: testUncondToNextBlock |
| 31 ; OM1: call | 34 ; OM1: call |
| 32 ; OM1-NEXT: jmp | 35 ; OM1-NEXT: jmp |
| 33 ; OM1-NEXT: call | 36 ; OM1: call |
| 34 | 37 |
| 35 ; For a conditional branch with a fallthrough to the next block, the | 38 ; For a conditional branch with a fallthrough to the next block, the |
| 36 ; fallthrough branch should be removed. | 39 ; fallthrough branch should be removed. |
| 37 define void @testCondFallthroughToNextBlock(i32 %arg) { | 40 define void @testCondFallthroughToNextBlock(i32 %arg) { |
| 38 entry: | 41 entry: |
| 39 %cmp = icmp sge i32 %arg, 123 | 42 %cmp = icmp sge i32 %arg, 123 |
| 40 br i1 %cmp, label %target, label %fallthrough | 43 br i1 %cmp, label %target, label %fallthrough |
| 41 fallthrough: | 44 fallthrough: |
| 42 call void @dummy() | 45 call void @dummy() |
| 43 ret void | 46 ret void |
| 44 target: | 47 target: |
| 45 call void @dummy() | 48 call void @dummy() |
| 46 ret void | 49 ret void |
| 47 } | 50 } |
| 48 ; O2-LABEL: testCondFallthroughToNextBlock | 51 ; O2-LABEL: testCondFallthroughToNextBlock |
| 49 ; O2: cmp {{.*}}, 123 | 52 ; O2: cmp {{.*}}, 123 |
| 50 ; O2-NEXT: jge | 53 ; O2-NEXT: jge |
| 51 ; O2-NEXT: call | 54 ; O2-NOT: j |
| 55 ; O2: call |
| 52 ; O2: ret | 56 ; O2: ret |
| 53 ; O2: call | 57 ; O2: call |
| 54 ; O2: ret | 58 ; O2: ret |
| 55 | 59 |
| 56 ; OM1-LABEL: testCondFallthroughToNextBlock | 60 ; OM1-LABEL: testCondFallthroughToNextBlock |
| 57 ; OM1: cmp {{.*}}, 123 | 61 ; OM1: cmp {{.*}}, 123 |
| 58 ; OM1: jge | 62 ; OM1: jge |
| 59 ; OM1: cmp | 63 ; OM1: cmp |
| 60 ; OM1: jne | 64 ; OM1: jne |
| 61 ; OM1: jmp | 65 ; OM1: jmp |
| (...skipping 13 matching lines...) Expand all Loading... |
| 75 fallthrough: | 79 fallthrough: |
| 76 call void @dummy() | 80 call void @dummy() |
| 77 ret void | 81 ret void |
| 78 target: | 82 target: |
| 79 call void @dummy() | 83 call void @dummy() |
| 80 ret void | 84 ret void |
| 81 } | 85 } |
| 82 ; O2-LABEL: testCondTargetNextBlock | 86 ; O2-LABEL: testCondTargetNextBlock |
| 83 ; O2: cmp {{.*}}, 123 | 87 ; O2: cmp {{.*}}, 123 |
| 84 ; O2-NEXT: jl | 88 ; O2-NEXT: jl |
| 85 ; O2-NEXT: call | 89 ; O2-NOT: j |
| 90 ; O2: call |
| 86 ; O2: ret | 91 ; O2: ret |
| 87 ; O2: call | 92 ; O2: call |
| 88 ; O2: ret | 93 ; O2: ret |
| 89 | 94 |
| 90 ; OM1-LABEL: testCondTargetNextBlock | 95 ; OM1-LABEL: testCondTargetNextBlock |
| 91 ; OM1: cmp {{.*}}, 123 | 96 ; OM1: cmp {{.*}}, 123 |
| 92 ; OM1: jge | 97 ; OM1: jge |
| 93 ; OM1: cmp | 98 ; OM1: cmp |
| 94 ; OM1: jne | 99 ; OM1: jne |
| 95 ; OM1: jmp | 100 ; OM1: jmp |
| 96 ; OM1: call | 101 ; OM1: call |
| 97 ; OM1: ret | 102 ; OM1: ret |
| 98 ; OM1: call | 103 ; OM1: call |
| 99 ; OM1: ret | 104 ; OM1: ret |
| 100 | 105 |
| 101 ; ERRORS-NOT: ICE translation error | 106 ; ERRORS-NOT: ICE translation error |
| 102 ; DUMP-NOT: SZ | 107 ; DUMP-NOT: SZ |
| OLD | NEW |