OLD | NEW |
1 ; RUN: llc < %s -mtriple=arm-apple-darwin | FileCheck %s | 1 ; RUN: llc < %s -mtriple=arm-apple-darwin | FileCheck %s |
2 ; RUN: llc < %s -mtriple=arm-apple-darwin | FileCheck %s --check-prefix=V7 | 2 ; RUN: llc < %s -mtriple=arm-apple-darwin | FileCheck %s --check-prefix=V7 |
3 ; RUN: llc < %s -mtriple=armv8-none-linux-gnueabi | FileCheck %s -check-prefix=V
8 | 3 ; RUN: llc < %s -mtriple=armv8-none-linux-gnueabi | FileCheck %s -check-prefix=V
8 |
4 | 4 |
5 | 5 |
6 define i32 @f(i32 %a, i32 %b) nounwind ssp { | 6 define i32 @f(i32 %a, i32 %b) nounwind ssp { |
7 entry: | 7 entry: |
8 ; CHECK-LABEL: f: | 8 ; CHECK-LABEL: f: |
9 ; CHECK: subs | 9 ; CHECK: subs |
10 ; CHECK-NOT: cmp | 10 ; CHECK-NOT: cmp |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 %cmp1 = icmp eq i32 %retval.0.i, 0 | 81 %cmp1 = icmp eq i32 %retval.0.i, 0 |
82 br i1 %cmp1, label %land.lhs.true, label %if.end11 | 82 br i1 %cmp1, label %land.lhs.true, label %if.end11 |
83 | 83 |
84 land.lhs.true: ; preds = %num2long.exit | 84 land.lhs.true: ; preds = %num2long.exit |
85 ret i32 17 | 85 ret i32 17 |
86 | 86 |
87 if.end11: ; preds = %num2long.exit | 87 if.end11: ; preds = %num2long.exit |
88 ret i32 23 | 88 ret i32 23 |
89 } | 89 } |
90 | 90 |
| 91 ; When considering the producer of cmp's src as the subsuming instruction, |
| 92 ; only consider that when the comparison is to 0. |
| 93 define i32 @cmp_src_nonzero(i32 %a, i32 %b, i32 %x, i32 %y) { |
| 94 entry: |
| 95 ; CHECK-LABEL: cmp_src_nonzero: |
| 96 ; CHECK: sub |
| 97 ; CHECK: cmp |
| 98 %sub = sub i32 %a, %b |
| 99 %cmp = icmp eq i32 %sub, 17 |
| 100 %ret = select i1 %cmp, i32 %x, i32 %y |
| 101 ret i32 %ret |
| 102 } |
| 103 |
91 define float @float_sel(i32 %a, i32 %b, float %x, float %y) { | 104 define float @float_sel(i32 %a, i32 %b, float %x, float %y) { |
92 entry: | 105 entry: |
93 ; CHECK-LABEL: float_sel: | 106 ; CHECK-LABEL: float_sel: |
94 ; CHECK-NOT: cmp | 107 ; CHECK-NOT: cmp |
95 ; V8-LABEL: float_sel: | 108 ; V8-LABEL: float_sel: |
96 ; V8-NOT: cmp | 109 ; V8-NOT: cmp |
97 ; V8: vseleq.f32 | 110 ; V8: vseleq.f32 |
98 %sub = sub i32 %a, %b | 111 %sub = sub i32 %a, %b |
99 %cmp = icmp eq i32 %sub, 0 | 112 %cmp = icmp eq i32 %sub, 0 |
100 %ret = select i1 %cmp, float %x, float %y | 113 %ret = select i1 %cmp, float %x, float %y |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 ; V8-LABEL: double_sub_swap: | 150 ; V8-LABEL: double_sub_swap: |
138 ; V8-NOT: subs | 151 ; V8-NOT: subs |
139 ; V8: cmp | 152 ; V8: cmp |
140 ; V8: vsel | 153 ; V8: vsel |
141 %cmp = icmp sgt i32 %a, %b | 154 %cmp = icmp sgt i32 %a, %b |
142 %sub = sub i32 %b, %a | 155 %sub = sub i32 %b, %a |
143 %ret = select i1 %cmp, double %x, double %y | 156 %ret = select i1 %cmp, double %x, double %y |
144 store i32 %sub, i32* @t | 157 store i32 %sub, i32* @t |
145 ret double %ret | 158 ret double %ret |
146 } | 159 } |
| 160 |
| 161 declare void @abort() |
| 162 declare void @exit(i32) |
| 163 |
| 164 ; If the comparison uses the V bit (signed overflow/underflow), we can't |
| 165 ; omit the comparison. |
| 166 define i32 @cmp_slt0(i32 %a, i32 %b, i32 %x, i32 %y) { |
| 167 entry: |
| 168 ; CHECK-LABEL: cmp_slt0 |
| 169 ; CHECK: sub |
| 170 ; CHECK: cmp |
| 171 ; CHECK: bge |
| 172 %load = load i32* @t, align 4 |
| 173 %sub = sub i32 %load, 17 |
| 174 %cmp = icmp slt i32 %sub, 0 |
| 175 br i1 %cmp, label %if.then, label %if.else |
| 176 |
| 177 if.then: |
| 178 call void @abort() |
| 179 unreachable |
| 180 |
| 181 if.else: |
| 182 call void @exit(i32 0) |
| 183 unreachable |
| 184 } |
| 185 |
| 186 ; Same for the C bit. (Note the ult X, 0 is trivially |
| 187 ; false, so the DAG combiner may or may not optimize it). |
| 188 define i32 @cmp_ult0(i32 %a, i32 %b, i32 %x, i32 %y) { |
| 189 entry: |
| 190 ; CHECK-LABEL: cmp_ult0 |
| 191 ; CHECK: sub |
| 192 ; CHECK: cmp |
| 193 ; CHECK: bhs |
| 194 %load = load i32* @t, align 4 |
| 195 %sub = sub i32 %load, 17 |
| 196 %cmp = icmp ult i32 %sub, 0 |
| 197 br i1 %cmp, label %if.then, label %if.else |
| 198 |
| 199 if.then: |
| 200 call void @abort() |
| 201 unreachable |
| 202 |
| 203 if.else: |
| 204 call void @exit(i32 0) |
| 205 unreachable |
| 206 } |
OLD | NEW |