• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -mtriple=thumbv7-apple-darwin | FileCheck %s
2; XFAIL: *
3
4define i32 @t1(i32 %a, i32 %b, i32 %c, i32 %d) nounwind {
5; CHECK-LABEL: t1:
6; CHECK: it ne
7; CHECK: cmpne
8	switch i32 %c, label %cond_next [
9		 i32 1, label %cond_true
10		 i32 7, label %cond_true
11	]
12
13cond_true:
14	%tmp12 = add i32 %a, 1
15	%tmp1518 = add i32 %tmp12, %b
16	ret i32 %tmp1518
17
18cond_next:
19	%tmp15 = add i32 %b, %a
20	ret i32 %tmp15
21}
22
23; FIXME: Check for # of unconditional branch after adding branch folding post ifcvt.
24define i32 @t2(i32 %a, i32 %b) nounwind {
25entry:
26; CHECK-LABEL: t2:
27; CHECK: ite gt
28; CHECK: subgt
29; CHECK: suble
30	%tmp1434 = icmp eq i32 %a, %b		; <i1> [#uses=1]
31	br i1 %tmp1434, label %bb17, label %bb.outer
32
33bb.outer:		; preds = %cond_false, %entry
34	%b_addr.021.0.ph = phi i32 [ %b, %entry ], [ %tmp10, %cond_false ]		; <i32> [#uses=5]
35	%a_addr.026.0.ph = phi i32 [ %a, %entry ], [ %a_addr.026.0, %cond_false ]		; <i32> [#uses=1]
36	br label %bb
37
38bb:		; preds = %cond_true, %bb.outer
39	%indvar = phi i32 [ 0, %bb.outer ], [ %indvar.next, %cond_true ]		; <i32> [#uses=2]
40	%tmp. = sub i32 0, %b_addr.021.0.ph		; <i32> [#uses=1]
41	%tmp.40 = mul i32 %indvar, %tmp.		; <i32> [#uses=1]
42	%a_addr.026.0 = add i32 %tmp.40, %a_addr.026.0.ph		; <i32> [#uses=6]
43	%tmp3 = icmp sgt i32 %a_addr.026.0, %b_addr.021.0.ph		; <i1> [#uses=1]
44	br i1 %tmp3, label %cond_true, label %cond_false
45
46cond_true:		; preds = %bb
47	%tmp7 = sub i32 %a_addr.026.0, %b_addr.021.0.ph		; <i32> [#uses=2]
48	%tmp1437 = icmp eq i32 %tmp7, %b_addr.021.0.ph		; <i1> [#uses=1]
49	%indvar.next = add i32 %indvar, 1		; <i32> [#uses=1]
50	br i1 %tmp1437, label %bb17, label %bb
51
52cond_false:		; preds = %bb
53	%tmp10 = sub i32 %b_addr.021.0.ph, %a_addr.026.0		; <i32> [#uses=2]
54	%tmp14 = icmp eq i32 %a_addr.026.0, %tmp10		; <i1> [#uses=1]
55	br i1 %tmp14, label %bb17, label %bb.outer
56
57bb17:		; preds = %cond_false, %cond_true, %entry
58	%a_addr.026.1 = phi i32 [ %a, %entry ], [ %tmp7, %cond_true ], [ %a_addr.026.0, %cond_false ]		; <i32> [#uses=1]
59	ret i32 %a_addr.026.1
60}
61
62@x = external global i32*		; <i32**> [#uses=1]
63
64define void @foo(i32 %a) nounwind {
65entry:
66	%tmp = load i32*, i32** @x		; <i32*> [#uses=1]
67	store i32 %a, i32* %tmp
68	ret void
69}
70
71; Tail call prevents use of ifcvt in this one.  Seems like a win though.
72define void @t3(i32 %a, i32 %b) nounwind {
73entry:
74; CHECK-LABEL: t3:
75; CHECK-NOT: it lt
76; CHECK-NOT: poplt
77; CHECK: b.w _foo @ TAILCALL
78	%tmp1 = icmp sgt i32 %a, 10		; <i1> [#uses=1]
79	br i1 %tmp1, label %cond_true, label %UnifiedReturnBlock
80
81cond_true:		; preds = %entry
82	tail call void @foo( i32 %b )
83	ret void
84
85UnifiedReturnBlock:		; preds = %entry
86	ret void
87}
88