blob: 2e4f5be38d1d2b71161646a8914aa0cda1aec1cb [file] [log] [blame]
Dan Gohman3c7d3082009-09-11 18:01:28 +00001; RUN: opt < %s -tailduplicate | \
Dan Gohman2d65d352009-08-25 15:38:29 +00002; RUN: llc -march=x86 -o %t
Dan Gohman91888f02007-07-31 20:11:57 +00003; RUN: grep {\\\<je\\\>} %t
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004; RUN: not grep jmp %t
5; END.
6; This should have no unconditional jumps in it. The C source is:
7
8;void foo(int c, int* P) {
9; if (c & 1) P[0] = 1;
10; if (c & 2) P[1] = 1;
11; if (c & 4) P[2] = 1;
12; if (c & 8) P[3] = 1;
13;}
14
Tanya Lattner003eae52008-03-10 07:21:50 +000015define void @foo(i32 %c, i32* %P) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000016entry:
Tanya Lattner003eae52008-03-10 07:21:50 +000017 %tmp1 = and i32 %c, 1 ; <i32> [#uses=1]
18 %tmp1.upgrd.1 = icmp eq i32 %tmp1, 0 ; <i1> [#uses=1]
19 br i1 %tmp1.upgrd.1, label %cond_next, label %cond_true
20cond_true: ; preds = %entry
21 store i32 1, i32* %P
22 br label %cond_next
23cond_next: ; preds = %cond_true, %entry
24 %tmp5 = and i32 %c, 2 ; <i32> [#uses=1]
25 %tmp5.upgrd.2 = icmp eq i32 %tmp5, 0 ; <i1> [#uses=1]
26 br i1 %tmp5.upgrd.2, label %cond_next10, label %cond_true6
27cond_true6: ; preds = %cond_next
28 %tmp8 = getelementptr i32* %P, i32 1 ; <i32*> [#uses=1]
29 store i32 1, i32* %tmp8
30 br label %cond_next10
31cond_next10: ; preds = %cond_true6, %cond_next
32 %tmp13 = and i32 %c, 4 ; <i32> [#uses=1]
33 %tmp13.upgrd.3 = icmp eq i32 %tmp13, 0 ; <i1> [#uses=1]
34 br i1 %tmp13.upgrd.3, label %cond_next18, label %cond_true14
35cond_true14: ; preds = %cond_next10
36 %tmp16 = getelementptr i32* %P, i32 2 ; <i32*> [#uses=1]
37 store i32 1, i32* %tmp16
38 br label %cond_next18
39cond_next18: ; preds = %cond_true14, %cond_next10
40 %tmp21 = and i32 %c, 8 ; <i32> [#uses=1]
41 %tmp21.upgrd.4 = icmp eq i32 %tmp21, 0 ; <i1> [#uses=1]
42 br i1 %tmp21.upgrd.4, label %return, label %cond_true22
43cond_true22: ; preds = %cond_next18
44 %tmp24 = getelementptr i32* %P, i32 3 ; <i32*> [#uses=1]
45 store i32 1, i32* %tmp24
46 ret void
47return: ; preds = %cond_next18
48 ret void
Dan Gohmanf17a25c2007-07-18 16:29:46 +000049}