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