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 \ | 5 ; RUN: --target x8632 -i %s --args -O2 \ |
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 \ | 9 ; RUN: --target x8632 -i %s --args -Om1 \ |
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) | 12 ; TODO(jvoung): Stop skipping unimplemented parts (via --skip-unimplemented) |
13 ; once enough infrastructure is in. Also, switch to --filetype=obj | 13 ; once enough infrastructure is in. Also, switch to --filetype=obj |
14 ; when possible. | 14 ; when possible. |
15 ; Also test Om1 when addProlog is done. | |
16 ; RUN: %if --need=target_ARM32 --command %p2i --filetype=asm --assemble \ | 15 ; RUN: %if --need=target_ARM32 --command %p2i --filetype=asm --assemble \ |
17 ; RUN: --disassemble --target arm32 -i %s --args -O2 --skip-unimplemented \ | 16 ; RUN: --disassemble --target arm32 -i %s --args -O2 --skip-unimplemented \ |
18 ; RUN: | %if --need=target_ARM32 --command FileCheck --check-prefix ARM32O2 %s | 17 ; RUN: | %if --need=target_ARM32 --command FileCheck --check-prefix ARM32O2 %s |
19 | 18 |
| 19 ; RUN: %if --need=target_ARM32 --command %p2i --filetype=asm --assemble \ |
| 20 ; RUN: --disassemble --target arm32 -i %s --args -Om1 --skip-unimplemented \ |
| 21 ; RUN: | %if --need=target_ARM32 --command FileCheck \ |
| 22 ; RUN: --check-prefix ARM32OM1 %s |
| 23 |
20 declare void @dummy() | 24 declare void @dummy() |
21 | 25 |
22 ; An unconditional branch to the next block should be removed. | 26 ; An unconditional branch to the next block should be removed. |
23 define void @testUncondToNextBlock() { | 27 define void @testUncondToNextBlock() { |
24 entry: | 28 entry: |
25 call void @dummy() | 29 call void @dummy() |
26 br label %next | 30 br label %next |
27 next: | 31 next: |
28 call void @dummy() | 32 call void @dummy() |
29 ret void | 33 ret void |
30 } | 34 } |
31 ; O2-LABEL: testUncondToNextBlock | 35 ; O2-LABEL: testUncondToNextBlock |
32 ; O2: call | 36 ; O2: call |
33 ; There will be nops for bundle align to end (for NaCl), but there should | 37 ; There will be nops for bundle align to end (for NaCl), but there should |
34 ; not be a branch. | 38 ; not be a branch. |
35 ; O2-NOT: j | 39 ; O2-NOT: j |
36 ; O2: call | 40 ; O2: call |
37 | 41 |
38 ; OM1-LABEL: testUncondToNextBlock | 42 ; OM1-LABEL: testUncondToNextBlock |
39 ; OM1: call | 43 ; OM1: call |
40 ; OM1-NEXT: jmp | 44 ; OM1-NEXT: jmp |
41 ; OM1: call | 45 ; OM1: call |
42 | 46 |
43 ; ARM32O2-LABEL: testUncondToNextBlock | 47 ; ARM32O2-LABEL: testUncondToNextBlock |
44 ; ARM32O2: bl {{.*}} dummy | 48 ; ARM32O2: bl {{.*}} dummy |
45 ; ARM32O2-NEXT: bl {{.*}} dummy | 49 ; ARM32O2-NEXT: bl {{.*}} dummy |
46 | 50 |
| 51 ; ARM32OM1-LABEL: testUncondToNextBlock |
| 52 ; ARM32OM1: bl {{.*}} dummy |
| 53 ; ARM32OM1-NEXT: b |
| 54 ; ARM32OM1-NEXT: bl {{.*}} dummy |
| 55 |
47 ; For a conditional branch with a fallthrough to the next block, the | 56 ; For a conditional branch with a fallthrough to the next block, the |
48 ; fallthrough branch should be removed. | 57 ; fallthrough branch should be removed. |
49 define void @testCondFallthroughToNextBlock(i32 %arg) { | 58 define void @testCondFallthroughToNextBlock(i32 %arg) { |
50 entry: | 59 entry: |
51 %cmp = icmp sge i32 %arg, 123 | 60 %cmp = icmp sge i32 %arg, 123 |
52 br i1 %cmp, label %target, label %fallthrough | 61 br i1 %cmp, label %target, label %fallthrough |
53 fallthrough: | 62 fallthrough: |
54 call void @dummy() | 63 call void @dummy() |
55 ret void | 64 ret void |
56 target: | 65 target: |
(...skipping 24 matching lines...) Expand all Loading... |
81 ; ARM32O2-LABEL: testCondFallthroughToNextBlock | 90 ; ARM32O2-LABEL: testCondFallthroughToNextBlock |
82 ; ARM32O2: cmp {{.*}}, #123 | 91 ; ARM32O2: cmp {{.*}}, #123 |
83 ; ARM32O2-NEXT: movge {{.*}}, #1 | 92 ; ARM32O2-NEXT: movge {{.*}}, #1 |
84 ; ARM32O2-NEXT: cmp {{.*}}, #0 | 93 ; ARM32O2-NEXT: cmp {{.*}}, #0 |
85 ; ARM32O2-NEXT: bne | 94 ; ARM32O2-NEXT: bne |
86 ; ARM32O2-NEXT: bl | 95 ; ARM32O2-NEXT: bl |
87 ; ARM32O2-NEXT: bx lr | 96 ; ARM32O2-NEXT: bx lr |
88 ; ARM32O2-NEXT: bl | 97 ; ARM32O2-NEXT: bl |
89 ; ARM32O2-NEXT: bx lr | 98 ; ARM32O2-NEXT: bx lr |
90 | 99 |
| 100 ; ARM32OM1-LABEL: testCondFallthroughToNextBlock |
| 101 ; ARM32OM1: cmp {{.*}}, #123 |
| 102 ; ARM32OM1-NEXT: movge {{.*}}, #1 |
| 103 ; ARM32OM1: cmp {{.*}}, #0 |
| 104 ; ARM32OM1: bne |
| 105 ; ARM32OM1: b |
| 106 ; ARM32OM1: bl |
| 107 ; ARM32OM1: bx lr |
| 108 ; ARM32OM1: bl |
| 109 ; ARM32OM1: bx lr |
| 110 |
91 ; For a conditional branch with the next block as the target and a | 111 ; For a conditional branch with the next block as the target and a |
92 ; different block as the fallthrough, the branch condition should be | 112 ; different block as the fallthrough, the branch condition should be |
93 ; inverted, the fallthrough block changed to the target, and the | 113 ; inverted, the fallthrough block changed to the target, and the |
94 ; branch to the next block removed. | 114 ; branch to the next block removed. |
95 define void @testCondTargetNextBlock(i32 %arg) { | 115 define void @testCondTargetNextBlock(i32 %arg) { |
96 entry: | 116 entry: |
97 %cmp = icmp sge i32 %arg, 123 | 117 %cmp = icmp sge i32 %arg, 123 |
98 br i1 %cmp, label %fallthrough, label %target | 118 br i1 %cmp, label %fallthrough, label %target |
99 fallthrough: | 119 fallthrough: |
100 call void @dummy() | 120 call void @dummy() |
(...skipping 26 matching lines...) Expand all Loading... |
127 ; (compared to x86-32). | 147 ; (compared to x86-32). |
128 ; ARM32O2-LABEL: testCondTargetNextBlock | 148 ; ARM32O2-LABEL: testCondTargetNextBlock |
129 ; ARM32O2: cmp {{.*}}, #123 | 149 ; ARM32O2: cmp {{.*}}, #123 |
130 ; ARM32O2-NEXT: movge {{.*}}, #1 | 150 ; ARM32O2-NEXT: movge {{.*}}, #1 |
131 ; ARM32O2-NEXT: cmp {{.*}}, #0 | 151 ; ARM32O2-NEXT: cmp {{.*}}, #0 |
132 ; ARM32O2-NEXT: beq | 152 ; ARM32O2-NEXT: beq |
133 ; ARM32O2-NEXT: bl | 153 ; ARM32O2-NEXT: bl |
134 ; ARM32O2-NEXT: bx lr | 154 ; ARM32O2-NEXT: bx lr |
135 ; ARM32O2-NEXT: bl | 155 ; ARM32O2-NEXT: bl |
136 ; ARM32O2-NEXT: bx lr | 156 ; ARM32O2-NEXT: bx lr |
| 157 |
| 158 ; ARM32OM1-LABEL: testCondTargetNextBlock |
| 159 ; ARM32OM1: cmp {{.*}}, #123 |
| 160 ; ARM32OM1: movge {{.*}}, #1 |
| 161 ; ARM32OM1: cmp {{.*}}, #0 |
| 162 ; ARM32OM1: bne |
| 163 ; ARM32OM1: b |
| 164 ; ARM32OM1: bl |
| 165 ; ARM32OM1: bx lr |
| 166 ; ARM32OM1: bl |
| 167 ; ARM32OM1: bx lr |
OLD | NEW |