1 ; RUN: llc < %s -mtriple=arm-apple-darwin | FileCheck %s
3 define i32 @f(i32 %a, i32 %b) nounwind ssp {
8 %cmp = icmp sgt i32 %a, %b
9 %sub = sub nsw i32 %a, %b
10 %sub. = select i1 %cmp, i32 %sub, i32 0
14 define i32 @g(i32 %a, i32 %b) nounwind ssp {
19 %cmp = icmp slt i32 %a, %b
20 %sub = sub nsw i32 %b, %a
21 %sub. = select i1 %cmp, i32 %sub, i32 0
25 define i32 @h(i32 %a, i32 %b) nounwind ssp {
30 %cmp = icmp sgt i32 %a, 3
31 %sub = sub nsw i32 %a, 3
32 %sub. = select i1 %cmp, i32 %sub, i32 %b
37 define i32 @i(i32 %a, i32 %b) nounwind readnone ssp {
42 %cmp = icmp ult i32 %a, %b
44 %sub. = select i1 %cmp, i32 %sub, i32 0
47 ; If CPSR is live-out, we can't remove cmp if there exists
49 define i32 @j(i32 %a, i32 %b) nounwind {
54 %cmp = icmp eq i32 %b, %a
55 %sub = sub nsw i32 %a, %b
56 br i1 %cmp, label %if.then, label %if.else
59 %cmp2 = icmp sgt i32 %b, %a
60 %sel = select i1 %cmp2, i32 %sub, i32 %a
67 ; If the sub/rsb instruction is predicated, we can't use the flags.
68 ; <rdar://problem/12263428>
69 ; Test case from MultiSource/Benchmarks/Ptrdist/bc/number.s
73 define i32 @bc_raise() nounwind ssp {
75 %val.2.i = select i1 undef, i32 0, i32 undef
76 %sub.i = sub nsw i32 0, %val.2.i
77 %retval.0.i = select i1 undef, i32 %val.2.i, i32 %sub.i
78 %cmp1 = icmp eq i32 %retval.0.i, 0
79 br i1 %cmp1, label %land.lhs.true, label %if.end11
81 land.lhs.true: ; preds = %num2long.exit
84 if.end11: ; preds = %num2long.exit