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