| 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 --filetype=obj --disassemble -i %s --args -O2 \ | 4 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ | 
| 5 ; RUN:   | FileCheck --check-prefix=O2 %s | 5 ; RUN:   --target x8632 -i %s --args -O2 \ | 
| 6 ; RUN: %p2i --filetype=obj --disassemble -i %s --args -Om1 \ | 6 ; RUN:   | %if --need=target_X8632 --command FileCheck --check-prefix=O2 %s | 
| 7 ; RUN:   | FileCheck --check-prefix=OM1 %s | 7 | 
|  | 8 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ | 
|  | 9 ; RUN:   --target x8632 -i %s --args -Om1 \ | 
|  | 10 ; RUN:   | %if --need=target_X8632 --command FileCheck --check-prefix=OM1 %s | 
|  | 11 | 
|  | 12 ; TODO(jvoung): Stop skipping unimplemented parts (via --skip-unimplemented) | 
|  | 13 ; once enough infrastructure is in. Also, switch to --filetype=obj | 
|  | 14 ; when possible. | 
|  | 15 ; Also test Om1 when addProlog is done. | 
|  | 16 ; RUN: %if --need=target_ARM32 --command %p2i --filetype=asm --assemble \ | 
|  | 17 ; RUN:   --disassemble --target arm32 -i %s --args -O2 --skip-unimplemented \ | 
|  | 18 ; RUN:   | %if --need=target_ARM32 --command FileCheck --check-prefix ARM32O2 %s | 
| 8 | 19 | 
| 9 declare void @dummy() | 20 declare void @dummy() | 
| 10 | 21 | 
| 11 ; An unconditional branch to the next block should be removed. | 22 ; An unconditional branch to the next block should be removed. | 
| 12 define void @testUncondToNextBlock() { | 23 define void @testUncondToNextBlock() { | 
| 13 entry: | 24 entry: | 
| 14   call void @dummy() | 25   call void @dummy() | 
| 15   br label %next | 26   br label %next | 
| 16 next: | 27 next: | 
| 17   call void @dummy() | 28   call void @dummy() | 
| 18   ret void | 29   ret void | 
| 19 } | 30 } | 
| 20 ; O2-LABEL: testUncondToNextBlock | 31 ; O2-LABEL: testUncondToNextBlock | 
| 21 ; O2: call | 32 ; O2: call | 
| 22 ; There will be nops for bundle align to end (for NaCl), but there should | 33 ; There will be nops for bundle align to end (for NaCl), but there should | 
| 23 ; not be a branch. | 34 ; not be a branch. | 
| 24 ; O2-NOT: j | 35 ; O2-NOT: j | 
| 25 ; O2: call | 36 ; O2: call | 
| 26 | 37 | 
| 27 ; OM1-LABEL: testUncondToNextBlock | 38 ; OM1-LABEL: testUncondToNextBlock | 
| 28 ; OM1: call | 39 ; OM1: call | 
| 29 ; OM1-NEXT: jmp | 40 ; OM1-NEXT: jmp | 
| 30 ; OM1: call | 41 ; OM1: call | 
| 31 | 42 | 
|  | 43 ; ARM32O2-LABEL: testUncondToNextBlock | 
|  | 44 ; ARM32O2: bl {{.*}} dummy | 
|  | 45 ; ARM32O2-NEXT: bl {{.*}} dummy | 
|  | 46 | 
| 32 ; For a conditional branch with a fallthrough to the next block, the | 47 ; For a conditional branch with a fallthrough to the next block, the | 
| 33 ; fallthrough branch should be removed. | 48 ; fallthrough branch should be removed. | 
| 34 define void @testCondFallthroughToNextBlock(i32 %arg) { | 49 define void @testCondFallthroughToNextBlock(i32 %arg) { | 
| 35 entry: | 50 entry: | 
| 36   %cmp = icmp sge i32 %arg, 123 | 51   %cmp = icmp sge i32 %arg, 123 | 
| 37   br i1 %cmp, label %target, label %fallthrough | 52   br i1 %cmp, label %target, label %fallthrough | 
| 38 fallthrough: | 53 fallthrough: | 
| 39   call void @dummy() | 54   call void @dummy() | 
| 40   ret void | 55   ret void | 
| 41 target: | 56 target: | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 55 ; OM1: cmp {{.*}},0x7b | 70 ; OM1: cmp {{.*}},0x7b | 
| 56 ; OM1: setge | 71 ; OM1: setge | 
| 57 ; OM1: cmp | 72 ; OM1: cmp | 
| 58 ; OM1: jne | 73 ; OM1: jne | 
| 59 ; OM1: jmp | 74 ; OM1: jmp | 
| 60 ; OM1: call | 75 ; OM1: call | 
| 61 ; OM1: ret | 76 ; OM1: ret | 
| 62 ; OM1: call | 77 ; OM1: call | 
| 63 ; OM1: ret | 78 ; OM1: ret | 
| 64 | 79 | 
|  | 80 ; Note that compare and branch folding isn't implemented yet (unlike x86-32). | 
|  | 81 ; ARM32O2-LABEL: testCondFallthroughToNextBlock | 
|  | 82 ; ARM32O2: cmp {{.*}}, #123 | 
|  | 83 ; ARM32O2-NEXT: movge {{.*}}, #1 | 
|  | 84 ; ARM32O2-NEXT: cmp {{.*}}, #0 | 
|  | 85 ; ARM32O2-NEXT: bne | 
|  | 86 ; ARM32O2-NEXT: bl | 
|  | 87 ; ARM32O2-NEXT: bx lr | 
|  | 88 ; ARM32O2-NEXT: bl | 
|  | 89 ; ARM32O2-NEXT: bx lr | 
|  | 90 | 
| 65 ; For a conditional branch with the next block as the target and a | 91 ; For a conditional branch with the next block as the target and a | 
| 66 ; different block as the fallthrough, the branch condition should be | 92 ; different block as the fallthrough, the branch condition should be | 
| 67 ; inverted, the fallthrough block changed to the target, and the | 93 ; inverted, the fallthrough block changed to the target, and the | 
| 68 ; branch to the next block removed. | 94 ; branch to the next block removed. | 
| 69 define void @testCondTargetNextBlock(i32 %arg) { | 95 define void @testCondTargetNextBlock(i32 %arg) { | 
| 70 entry: | 96 entry: | 
| 71   %cmp = icmp sge i32 %arg, 123 | 97   %cmp = icmp sge i32 %arg, 123 | 
| 72   br i1 %cmp, label %fallthrough, label %target | 98   br i1 %cmp, label %fallthrough, label %target | 
| 73 fallthrough: | 99 fallthrough: | 
| 74   call void @dummy() | 100   call void @dummy() | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 89 ; OM1-LABEL: testCondTargetNextBlock | 115 ; OM1-LABEL: testCondTargetNextBlock | 
| 90 ; OM1: cmp {{.*}},0x7b | 116 ; OM1: cmp {{.*}},0x7b | 
| 91 ; OM1: setge | 117 ; OM1: setge | 
| 92 ; OM1: cmp | 118 ; OM1: cmp | 
| 93 ; OM1: jne | 119 ; OM1: jne | 
| 94 ; OM1: jmp | 120 ; OM1: jmp | 
| 95 ; OM1: call | 121 ; OM1: call | 
| 96 ; OM1: ret | 122 ; OM1: ret | 
| 97 ; OM1: call | 123 ; OM1: call | 
| 98 ; OM1: ret | 124 ; OM1: ret | 
|  | 125 | 
|  | 126 ; Note that compare and branch folding isn't implemented yet | 
|  | 127 ; (compared to x86-32). | 
|  | 128 ; ARM32O2-LABEL: testCondTargetNextBlock | 
|  | 129 ; ARM32O2: cmp {{.*}}, #123 | 
|  | 130 ; ARM32O2-NEXT: movge {{.*}}, #1 | 
|  | 131 ; ARM32O2-NEXT: cmp {{.*}}, #0 | 
|  | 132 ; ARM32O2-NEXT: beq | 
|  | 133 ; ARM32O2-NEXT: bl | 
|  | 134 ; ARM32O2-NEXT: bx lr | 
|  | 135 ; ARM32O2-NEXT: bl | 
|  | 136 ; ARM32O2-NEXT: bx lr | 
| OLD | NEW | 
|---|