new testcase
[oota-llvm.git] / test / Transforms / TailDup / if-tail-dup.ll
1 ; RUN: llvm-as < %s | opt -tailduplicate | llc -march=x86 | grep 'je ' &&
2 ; RUN: llvm-as < %s | opt -tailduplicate | llc -march=x86 | not grep jmp
3 ; This should have no unconditional jumps in it.  The C source is:
4
5 ;void foo(int c, int* P) {
6 ;  if (c & 1)  P[0] = 1;
7 ;  if (c & 2)  P[1] = 1;
8 ;  if (c & 4)  P[2] = 1;
9 ;  if (c & 8)  P[3] = 1;
10 ;}
11
12
13 void %foo(int %c, int* %P) {
14 entry:
15         %tmp1 = and int %c, 1           ; <int> [#uses=1]
16         %tmp1 = seteq int %tmp1, 0              ; <bool> [#uses=1]
17         br bool %tmp1, label %cond_next, label %cond_true
18
19 cond_true:              ; preds = %entry
20         store int 1, int* %P
21         br label %cond_next
22
23 cond_next:              ; preds = %entry, %cond_true
24         %tmp5 = and int %c, 2           ; <int> [#uses=1]
25         %tmp5 = seteq int %tmp5, 0              ; <bool> [#uses=1]
26         br bool %tmp5, label %cond_next10, label %cond_true6
27
28 cond_true6:             ; preds = %cond_next
29         %tmp8 = getelementptr int* %P, int 1            ; <int*> [#uses=1]
30         store int 1, int* %tmp8
31         br label %cond_next10
32
33 cond_next10:            ; preds = %cond_next, %cond_true6
34         %tmp13 = and int %c, 4          ; <int> [#uses=1]
35         %tmp13 = seteq int %tmp13, 0            ; <bool> [#uses=1]
36         br bool %tmp13, label %cond_next18, label %cond_true14
37
38 cond_true14:            ; preds = %cond_next10
39         %tmp16 = getelementptr int* %P, int 2           ; <int*> [#uses=1]
40         store int 1, int* %tmp16
41         br label %cond_next18
42
43 cond_next18:            ; preds = %cond_next10, %cond_true14
44         %tmp21 = and int %c, 8          ; <int> [#uses=1]
45         %tmp21 = seteq int %tmp21, 0            ; <bool> [#uses=1]
46         br bool %tmp21, label %return, label %cond_true22
47
48 cond_true22:            ; preds = %cond_next18
49         %tmp24 = getelementptr int* %P, int 3           ; <int*> [#uses=1]
50         store int 1, int* %tmp24
51         ret void
52
53 return:         ; preds = %cond_next18
54         ret void
55 }
56
57