For PR1319:
[oota-llvm.git] / test / Transforms / TailDup / if-tail-dup.ll
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -tailduplicate | \
2 ; RUN:   llc -march=x86 -o %t -f
3 ; RUN: grep {je } %t
4 ; 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
15 implementation
16
17 void %foo(int %c, int* %P) {
18 entry:
19         %tmp1 = and int %c, 1           ; <int> [#uses=1]
20         %tmp1 = seteq int %tmp1, 0              ; <bool> [#uses=1]
21         br bool %tmp1, label %cond_next, label %cond_true
22
23 cond_true:              ; preds = %entry
24         store int 1, int* %P
25         br label %cond_next
26
27 cond_next:              ; preds = %entry, %cond_true
28         %tmp5 = and int %c, 2           ; <int> [#uses=1]
29         %tmp5 = seteq int %tmp5, 0              ; <bool> [#uses=1]
30         br bool %tmp5, label %cond_next10, label %cond_true6
31
32 cond_true6:             ; preds = %cond_next
33         %tmp8 = getelementptr int* %P, int 1            ; <int*> [#uses=1]
34         store int 1, int* %tmp8
35         br label %cond_next10
36
37 cond_next10:            ; preds = %cond_next, %cond_true6
38         %tmp13 = and int %c, 4          ; <int> [#uses=1]
39         %tmp13 = seteq int %tmp13, 0            ; <bool> [#uses=1]
40         br bool %tmp13, label %cond_next18, label %cond_true14
41
42 cond_true14:            ; preds = %cond_next10
43         %tmp16 = getelementptr int* %P, int 2           ; <int*> [#uses=1]
44         store int 1, int* %tmp16
45         br label %cond_next18
46
47 cond_next18:            ; preds = %cond_next10, %cond_true14
48         %tmp21 = and int %c, 8          ; <int> [#uses=1]
49         %tmp21 = seteq int %tmp21, 0            ; <bool> [#uses=1]
50         br bool %tmp21, label %return, label %cond_true22
51
52 cond_true22:            ; preds = %cond_next18
53         %tmp24 = getelementptr int* %P, int 3           ; <int*> [#uses=1]
54         store int 1, int* %tmp24
55         ret void
56
57 return:         ; preds = %cond_next18
58         ret void
59 }
60
61