| 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: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ | 4 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ |
| 5 ; RUN: --target x8632 -i %s --args -O2 -allow-externally-defined-symbols \ | 5 ; RUN: --target x8632 -i %s --args -O2 -allow-externally-defined-symbols \ |
| 6 ; RUN: | %if --need=target_X8632 --command FileCheck --check-prefix=O2 %s | 6 ; RUN: | %if --need=target_X8632 --command FileCheck --check-prefix=O2 %s |
| 7 | 7 |
| 8 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ | 8 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ |
| 9 ; RUN: --target x8632 -i %s --args -Om1 -allow-externally-defined-symbols \ | 9 ; RUN: --target x8632 -i %s --args -Om1 -allow-externally-defined-symbols \ |
| 10 ; RUN: | %if --need=target_X8632 --command FileCheck --check-prefix=OM1 %s | 10 ; RUN: | %if --need=target_X8632 --command FileCheck --check-prefix=OM1 %s |
| 11 | 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. |
| 12 ; RUN: %if --need=target_ARM32 --need=allow_dump \ | 15 ; RUN: %if --need=target_ARM32 --need=allow_dump \ |
| 13 ; RUN: --command %p2i --filetype=obj --assemble \ | 16 ; RUN: --command %p2i --filetype=asm --assemble \ |
| 14 ; RUN: --disassemble --target arm32 -i %s --args -O2 \ | 17 ; RUN: --disassemble --target arm32 -i %s --args -O2 \ |
| 15 ; RUN: -allow-externally-defined-symbols \ | 18 ; RUN: -allow-externally-defined-symbols \ |
| 16 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ | 19 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ |
| 17 ; RUN: --command FileCheck --check-prefix ARM32O2 %s | 20 ; RUN: --command FileCheck --check-prefix ARM32O2 %s |
| 18 | 21 |
| 19 ; RUN: %if --need=target_ARM32 --need=allow_dump \ | 22 ; RUN: %if --need=target_ARM32 --need=allow_dump \ |
| 20 ; RUN: --command %p2i --filetype=obj --assemble \ | 23 ; RUN: --command %p2i --filetype=asm --assemble \ |
| 21 ; RUN: --disassemble --target arm32 -i %s --args -Om1 \ | 24 ; RUN: --disassemble --target arm32 -i %s --args -Om1 \ |
| 22 ; RUN: -allow-externally-defined-symbols \ | 25 ; RUN: -allow-externally-defined-symbols \ |
| 23 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ | 26 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ |
| 24 ; RUN: --command FileCheck \ | 27 ; RUN: --command FileCheck \ |
| 25 ; RUN: --check-prefix ARM32OM1 %s | 28 ; RUN: --check-prefix ARM32OM1 %s |
| 26 | 29 |
| 27 declare void @dummy() | 30 declare void @dummy() |
| 28 | 31 |
| 29 ; An unconditional branch to the next block should be removed. | 32 ; An unconditional branch to the next block should be removed. |
| 30 define internal void @testUncondToNextBlock() { | 33 define internal void @testUncondToNextBlock() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 41 ; not be a branch. | 44 ; not be a branch. |
| 42 ; O2-NOT: j | 45 ; O2-NOT: j |
| 43 ; O2: call | 46 ; O2: call |
| 44 | 47 |
| 45 ; OM1-LABEL: testUncondToNextBlock | 48 ; OM1-LABEL: testUncondToNextBlock |
| 46 ; OM1: call | 49 ; OM1: call |
| 47 ; OM1-NEXT: jmp | 50 ; OM1-NEXT: jmp |
| 48 ; OM1: call | 51 ; OM1: call |
| 49 | 52 |
| 50 ; ARM32O2-LABEL: testUncondToNextBlock | 53 ; ARM32O2-LABEL: testUncondToNextBlock |
| 51 ; ARM32O2: movw {{.+}} dummy | 54 ; ARM32O2: bl {{.*}} dummy |
| 52 ; ARM32O2-NEXT: movt | 55 ; ARM32O2-NEXT: bl {{.*}} dummy |
| 53 ; ARM32O2-NEXT: blx | |
| 54 ; ARM32O2-NEXT: movw {{.+}} dummy | |
| 55 ; ARM32O2-NEXT: movt | |
| 56 ; ARM32O2-NEXT: blx | |
| 57 | 56 |
| 58 ; ARM32OM1-LABEL: testUncondToNextBlock | 57 ; ARM32OM1-LABEL: testUncondToNextBlock |
| 59 ; ARM32OM1: movw {{.+}} dummy | 58 ; ARM32OM1: bl {{.*}} dummy |
| 60 ; ARM32OM1-NEXT: movt | |
| 61 ; ARM32OM1-NEXT: blx | |
| 62 ; ARM32OM1-NEXT: b | 59 ; ARM32OM1-NEXT: b |
| 63 ; ARM32OM1-NEXT: movw {{.+}} dummy | 60 ; ARM32OM1-NEXT: bl {{.*}} dummy |
| 64 ; ARM32OM1-NEXT: movt | |
| 65 ; ARM32OM1-NEXT: blx | |
| 66 | |
| 67 | 61 |
| 68 ; For a conditional branch with a fallthrough to the next block, the | 62 ; For a conditional branch with a fallthrough to the next block, the |
| 69 ; fallthrough branch should be removed. | 63 ; fallthrough branch should be removed. |
| 70 define internal void @testCondFallthroughToNextBlock(i32 %arg) { | 64 define internal void @testCondFallthroughToNextBlock(i32 %arg) { |
| 71 entry: | 65 entry: |
| 72 %cmp = icmp sge i32 %arg, 123 | 66 %cmp = icmp sge i32 %arg, 123 |
| 73 br i1 %cmp, label %target, label %fallthrough | 67 br i1 %cmp, label %target, label %fallthrough |
| 74 fallthrough: | 68 fallthrough: |
| 75 call void @dummy() | 69 call void @dummy() |
| 76 ret void | 70 ret void |
| (...skipping 15 matching lines...) Expand all Loading... |
| 92 ; OM1: setge | 86 ; OM1: setge |
| 93 ; OM1: cmp | 87 ; OM1: cmp |
| 94 ; OM1: jne | 88 ; OM1: jne |
| 95 ; OM1: jmp | 89 ; OM1: jmp |
| 96 ; OM1: call | 90 ; OM1: call |
| 97 ; OM1: ret | 91 ; OM1: ret |
| 98 ; OM1: call | 92 ; OM1: call |
| 99 ; OM1: ret | 93 ; OM1: ret |
| 100 | 94 |
| 101 ; ARM32O2-LABEL: testCondFallthroughToNextBlock | 95 ; ARM32O2-LABEL: testCondFallthroughToNextBlock |
| 102 ; ARM32O2: cmp {{.*}}, #123 | 96 ; ARM32O2: cmp {{.*}}, #123 |
| 103 ; ARM32O2-NEXT: bge | 97 ; ARM32O2-NEXT: bge |
| 104 ; ARM32O2-NEXT: movw {{.+}} dummy | 98 ; ARM32O2-NEXT: bl |
| 105 ; ARM32O2-NEXT: movt | 99 ; ARM32O2: bx lr |
| 106 ; ARM32O2-NEXT: blx | 100 ; ARM32O2: bl |
| 107 ; ARM32O2: bx lr | 101 ; ARM32O2: bx lr |
| 108 ; ARM32O2-NEXT: movw {{.+}} dummy | |
| 109 ; ARM32O2-NEXT: movt | |
| 110 ; ARM32O2-NEXT: blx | |
| 111 ; ARM32O2: bx lr | |
| 112 | 102 |
| 113 ; ARM32OM1-LABEL: testCondFallthroughToNextBlock | 103 ; ARM32OM1-LABEL: testCondFallthroughToNextBlock |
| 114 ; ARM32OM1: mov {{.*}}, #0 | 104 ; ARM32OM1: mov {{.*}}, #0 |
| 115 ; ARM32OM1: cmp {{.*}}, #123 | 105 ; ARM32OM1: cmp {{.*}}, #123 |
| 116 ; ARM32OM1: movge {{.*}}, #1 | 106 ; ARM32OM1: movge {{.*}}, #1 |
| 117 ; ARM32OM1: tst {{.*}}, #1 | 107 ; ARM32OM1: tst {{.*}}, #1 |
| 118 ; ARM32OM1: bne | 108 ; ARM32OM1: bne |
| 119 ; ARM32OM1: b | 109 ; ARM32OM1: b |
| 120 ; ARM32OM1: movw | 110 ; ARM32OM1: bl |
| 121 ; ARM32OM1: movt | |
| 122 ; ARM32OM1: blx | |
| 123 ; ARM32OM1: bx lr | 111 ; ARM32OM1: bx lr |
| 124 ; ARM32OM1: movw | 112 ; ARM32OM1: bl |
| 125 ; ARM32OM1: movt | |
| 126 ; ARM32OM1: blx | |
| 127 ; ARM32OM1: bx lr | 113 ; ARM32OM1: bx lr |
| 128 | 114 |
| 129 ; For a conditional branch with the next block as the target and a | 115 ; For a conditional branch with the next block as the target and a |
| 130 ; different block as the fallthrough, the branch condition should be | 116 ; different block as the fallthrough, the branch condition should be |
| 131 ; inverted, the fallthrough block changed to the target, and the | 117 ; inverted, the fallthrough block changed to the target, and the |
| 132 ; branch to the next block removed. | 118 ; branch to the next block removed. |
| 133 define internal void @testCondTargetNextBlock(i32 %arg) { | 119 define internal void @testCondTargetNextBlock(i32 %arg) { |
| 134 entry: | 120 entry: |
| 135 %cmp = icmp sge i32 %arg, 123 | 121 %cmp = icmp sge i32 %arg, 123 |
| 136 br i1 %cmp, label %fallthrough, label %target | 122 br i1 %cmp, label %fallthrough, label %target |
| (...skipping 20 matching lines...) Expand all Loading... |
| 157 ; OM1: jne | 143 ; OM1: jne |
| 158 ; OM1: jmp | 144 ; OM1: jmp |
| 159 ; OM1: call | 145 ; OM1: call |
| 160 ; OM1: ret | 146 ; OM1: ret |
| 161 ; OM1: call | 147 ; OM1: call |
| 162 ; OM1: ret | 148 ; OM1: ret |
| 163 | 149 |
| 164 ; Note that compare and branch folding isn't implemented yet | 150 ; Note that compare and branch folding isn't implemented yet |
| 165 ; (compared to x86-32). | 151 ; (compared to x86-32). |
| 166 ; ARM32O2-LABEL: testCondTargetNextBlock | 152 ; ARM32O2-LABEL: testCondTargetNextBlock |
| 167 ; ARM32O2: cmp {{.*}}, #123 | 153 ; ARM32O2: cmp {{.*}}, #123 |
| 168 ; ARM32O2-NEXT: blt | 154 ; ARM32O2-NEXT: blt |
| 169 ; ARM32O2-NEXT: movw | 155 ; ARM32O2-NEXT: bl |
| 170 ; ARM32O2-NEXT: movt | 156 ; ARM32O2: bx lr |
| 171 ; ARM32O2-NEXT: blx | 157 ; ARM32O2: bl |
| 172 ; ARM32O2: bx lr | 158 ; ARM32O2: bx lr |
| 173 ; ARM32O2-NEXT: movw | |
| 174 ; ARM32O2-NEXT: movt | |
| 175 ; ARM32O2-NEXT: blx | |
| 176 ; ARM32O2: bx lr | |
| 177 | 159 |
| 178 ; ARM32OM1-LABEL: testCondTargetNextBlock | 160 ; ARM32OM1-LABEL: testCondTargetNextBlock |
| 179 ; ARM32OM1: cmp {{.*}}, #123 | 161 ; ARM32OM1: cmp {{.*}}, #123 |
| 180 ; ARM32OM1: movge {{.*}}, #1 | 162 ; ARM32OM1: movge {{.*}}, #1 |
| 181 ; ARM32OM1: tst {{.*}}, #1 | 163 ; ARM32OM1: tst {{.*}}, #1 |
| 182 ; ARM32OM1: bne | 164 ; ARM32OM1: bne |
| 183 ; ARM32OM1: b | 165 ; ARM32OM1: b |
| 184 ; ARM32OM1: blx | 166 ; ARM32OM1: bl |
| 185 ; ARM32OM1: bx lr | 167 ; ARM32OM1: bx lr |
| 186 ; ARM32OM1: blx | 168 ; ARM32OM1: bl |
| 187 ; ARM32OM1: bx lr | 169 ; ARM32OM1: bx lr |
| 188 | 170 |
| 189 ; Unconditional branches to the block after a contracted block should be | 171 ; Unconditional branches to the block after a contracted block should be |
| 190 ; removed. | 172 ; removed. |
| 191 define internal void @testUncondToBlockAfterContract() { | 173 define internal void @testUncondToBlockAfterContract() { |
| 192 entry: | 174 entry: |
| 193 call void @dummy() | 175 call void @dummy() |
| 194 br label %target | 176 br label %target |
| 195 contract: | 177 contract: |
| 196 br label %target | 178 br label %target |
| 197 target: | 179 target: |
| 198 call void @dummy() | 180 call void @dummy() |
| 199 ret void | 181 ret void |
| 200 } | 182 } |
| 201 | 183 |
| 202 ; O2-LABEL: testUncondToBlockAfterContract | 184 ; O2-LABEL: testUncondToBlockAfterContract |
| 203 ; O2: call | 185 ; O2: call |
| 204 ; There will be nops for bundle align to end (for NaCl), but there should | 186 ; There will be nops for bundle align to end (for NaCl), but there should |
| 205 ; not be a branch. | 187 ; not be a branch. |
| 206 ; O2-NOT: j | 188 ; O2-NOT: j |
| 207 ; O2: call | 189 ; O2: call |
| 208 | 190 |
| 209 ; OM1-LABEL: testUncondToBlockAfterContract | 191 ; OM1-LABEL: testUncondToBlockAfterContract |
| 210 ; OM1: call | 192 ; OM1: call |
| 211 ; OM1-NEXT: jmp | 193 ; OM1-NEXT: jmp |
| 212 ; OM1: call | 194 ; OM1: call |
| 213 | 195 |
| 214 ; ARM32O2-LABEL: testUncondToBlockAfterContract | 196 ; ARM32O2-LABEL: testUncondToBlockAfterContract |
| 215 ; ARM32O2: movw {{.+}} dummy | 197 ; ARM32O2: bl {{.*}} dummy |
| 216 ; ARM32O2-NEXT: movt | 198 ; ARM32O2-NEXT: bl {{.*}} dummy |
| 217 ; ARM32O2-NEXT: blx | |
| 218 ; ARM32O2-NEXT: movw {{.+}} dummy | |
| 219 ; ARM32O2-NEXT: movt | |
| 220 ; ARM32O2-NEXT: blx | |
| 221 | 199 |
| 222 ; ARM32OM1-LABEL: testUncondToBlockAfterContract | 200 ; ARM32OM1-LABEL: testUncondToBlockAfterContract |
| 223 ; ARM32OM1: movw {{.+}} dummy | 201 ; ARM32OM1: bl {{.*}} dummy |
| 224 ; ARM32OM1-NEXT: movt | |
| 225 ; ARM32OM1-NEXT: blx | |
| 226 ; ARM32OM1-NEXT: b | 202 ; ARM32OM1-NEXT: b |
| 227 ; ARM32OM1-NEXT: movw {{.+}} dummy | 203 ; ARM32OM1-NEXT: bl {{.*}} dummy |
| 228 ; ARM32OM1-NEXT: movt | |
| 229 ; ARM32OM1-NEXT: blx | |
| OLD | NEW |