Mercurial > hg > Members > tobaru > cbc > CbC_llvm
comparison test/CodeGen/ARM/sub-cmp-peephole.ll @ 0:95c75e76d11b
LLVM 3.4
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 12 Dec 2013 13:56:28 +0900 |
parents | |
children | e4204d083e25 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:95c75e76d11b |
---|---|
1 ; RUN: llc < %s -mtriple=arm-apple-darwin | FileCheck %s | |
2 | |
3 define i32 @f(i32 %a, i32 %b) nounwind ssp { | |
4 entry: | |
5 ; CHECK-LABEL: f: | |
6 ; CHECK: subs | |
7 ; CHECK-NOT: cmp | |
8 %cmp = icmp sgt i32 %a, %b | |
9 %sub = sub nsw i32 %a, %b | |
10 %sub. = select i1 %cmp, i32 %sub, i32 0 | |
11 ret i32 %sub. | |
12 } | |
13 | |
14 define i32 @g(i32 %a, i32 %b) nounwind ssp { | |
15 entry: | |
16 ; CHECK-LABEL: g: | |
17 ; CHECK: subs | |
18 ; CHECK-NOT: cmp | |
19 %cmp = icmp slt i32 %a, %b | |
20 %sub = sub nsw i32 %b, %a | |
21 %sub. = select i1 %cmp, i32 %sub, i32 0 | |
22 ret i32 %sub. | |
23 } | |
24 | |
25 define i32 @h(i32 %a, i32 %b) nounwind ssp { | |
26 entry: | |
27 ; CHECK-LABEL: h: | |
28 ; CHECK: subs | |
29 ; CHECK-NOT: cmp | |
30 %cmp = icmp sgt i32 %a, 3 | |
31 %sub = sub nsw i32 %a, 3 | |
32 %sub. = select i1 %cmp, i32 %sub, i32 %b | |
33 ret i32 %sub. | |
34 } | |
35 | |
36 ; rdar://11725965 | |
37 define i32 @i(i32 %a, i32 %b) nounwind readnone ssp { | |
38 entry: | |
39 ; CHECK-LABEL: i: | |
40 ; CHECK: subs | |
41 ; CHECK-NOT: cmp | |
42 %cmp = icmp ult i32 %a, %b | |
43 %sub = sub i32 %b, %a | |
44 %sub. = select i1 %cmp, i32 %sub, i32 0 | |
45 ret i32 %sub. | |
46 } | |
47 ; If CPSR is live-out, we can't remove cmp if there exists | |
48 ; a swapped sub. | |
49 define i32 @j(i32 %a, i32 %b) nounwind { | |
50 entry: | |
51 ; CHECK-LABEL: j: | |
52 ; CHECK: sub | |
53 ; CHECK: cmp | |
54 %cmp = icmp eq i32 %b, %a | |
55 %sub = sub nsw i32 %a, %b | |
56 br i1 %cmp, label %if.then, label %if.else | |
57 | |
58 if.then: | |
59 %cmp2 = icmp sgt i32 %b, %a | |
60 %sel = select i1 %cmp2, i32 %sub, i32 %a | |
61 ret i32 %sel | |
62 | |
63 if.else: | |
64 ret i32 %sub | |
65 } | |
66 | |
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 | |
70 ; CHECK: bc_raise | |
71 ; CHECK: rsbeq | |
72 ; CHECK: cmp | |
73 define i32 @bc_raise() nounwind ssp { | |
74 entry: | |
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 | |
80 | |
81 land.lhs.true: ; preds = %num2long.exit | |
82 ret i32 17 | |
83 | |
84 if.end11: ; preds = %num2long.exit | |
85 ret i32 23 | |
86 } |