1 ; RUN: llc < %s -mtriple=arm-apple-darwin | FileCheck %s
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=V8
6 define i32 @f(i32 %a, i32 %b) nounwind ssp {
11 %cmp = icmp sgt i32 %a, %b
12 %sub = sub nsw i32 %a, %b
13 %sub. = select i1 %cmp, i32 %sub, i32 0
17 define i32 @g(i32 %a, i32 %b) nounwind ssp {
22 %cmp = icmp slt i32 %a, %b
23 %sub = sub nsw i32 %b, %a
24 %sub. = select i1 %cmp, i32 %sub, i32 0
28 define i32 @h(i32 %a, i32 %b) nounwind ssp {
33 %cmp = icmp sgt i32 %a, 3
34 %sub = sub nsw i32 %a, 3
35 %sub. = select i1 %cmp, i32 %sub, i32 %b
40 define i32 @i(i32 %a, i32 %b) nounwind readnone ssp {
45 %cmp = icmp ult i32 %a, %b
47 %sub. = select i1 %cmp, i32 %sub, i32 0
50 ; If CPSR is live-out, we can't remove cmp if there exists
52 define i32 @j(i32 %a, i32 %b) nounwind {
57 %cmp = icmp eq i32 %b, %a
58 %sub = sub nsw i32 %a, %b
59 br i1 %cmp, label %if.then, label %if.else
62 %cmp2 = icmp sgt i32 %b, %a
63 %sel = select i1 %cmp2, i32 %sub, i32 %a
70 ; If the sub/rsb instruction is predicated, we can't use the flags.
71 ; <rdar://problem/12263428>
72 ; Test case from MultiSource/Benchmarks/Ptrdist/bc/number.s
76 define i32 @bc_raise() nounwind ssp {
78 %val.2.i = select i1 undef, i32 0, i32 undef
79 %sub.i = sub nsw i32 0, %val.2.i
80 %retval.0.i = select i1 undef, i32 %val.2.i, i32 %sub.i
81 %cmp1 = icmp eq i32 %retval.0.i, 0
82 br i1 %cmp1, label %land.lhs.true, label %if.end11
84 land.lhs.true: ; preds = %num2long.exit
87 if.end11: ; preds = %num2long.exit
91 define float @float_sel(i32 %a, i32 %b, float %x, float %y) {
93 ; CHECK-LABEL: float_sel:
95 ; V8-LABEL: float_sel:
99 %cmp = icmp eq i32 %sub, 0
100 %ret = select i1 %cmp, float %x, float %y
104 define double @double_sel(i32 %a, i32 %b, double %x, double %y) {
106 ; CHECK-LABEL: double_sel:
108 ; V8-LABEL: double_sel:
111 %sub = sub i32 %a, %b
112 %cmp = icmp eq i32 %sub, 0
113 %ret = select i1 %cmp, double %x, double %y
117 @t = common global i32 0
118 define double @double_sub(i32 %a, i32 %b, double %x, double %y) {
120 ; CHECK-LABEL: double_sub:
123 ; V8-LABEL: double_sub:
125 %cmp = icmp sgt i32 %a, %b
126 %sub = sub i32 %a, %b
127 store i32 %sub, i32* @t
128 %ret = select i1 %cmp, double %x, double %y
132 define double @double_sub_swap(i32 %a, i32 %b, double %x, double %y) {
134 ; V7-LABEL: double_sub_swap:
137 ; V8-LABEL: double_sub_swap:
141 %cmp = icmp sgt i32 %a, %b
142 %sub = sub i32 %b, %a
143 %ret = select i1 %cmp, double %x, double %y
144 store i32 %sub, i32* @t