Modify two Transforms tests to explicitly check for full function names in some cases...
[oota-llvm.git] / test / Transforms / SimplifyCFG / speculate-store.ll
1 ; RUN: opt -simplifycfg -S < %s | FileCheck %s
2
3 define void @ifconvertstore(i32 %m, i32* %A, i32* %B, i32 %C, i32 %D) {
4 entry:
5   %arrayidx = getelementptr inbounds i32* %B, i64 0
6   %0 = load i32* %arrayidx, align 4
7   %add = add nsw i32 %0, %C
8   %arrayidx2 = getelementptr inbounds i32* %A, i64 0
9
10 ; First store to the location.
11   store i32 %add, i32* %arrayidx2, align 4
12   %arrayidx4 = getelementptr inbounds i32* %B, i64 1
13   %1 = load i32* %arrayidx4, align 4
14   %add5 = add nsw i32 %1, %D
15   %cmp6 = icmp sgt i32 %add5, %C
16   br i1 %cmp6, label %if.then, label %ret.end
17
18 ; Make sure we speculate stores like the following one. It is cheap compared to
19 ; a mispredicated branch.
20 ; CHECK: @ifconvertstore
21 ; CHECK: %add5.add = select i1 %cmp6, i32 %add5, i32 %add
22 ; CHECK: store i32 %add5.add, i32* %arrayidx2, align 4
23 if.then:
24   store i32 %add5, i32* %arrayidx2, align 4
25   br label %ret.end
26
27 ret.end:
28   ret void
29 }
30
31 define void @noifconvertstore1(i32 %m, i32* %A, i32* %B, i32 %C, i32 %D) {
32 entry:
33   %arrayidx = getelementptr inbounds i32* %B, i64 0
34   %0 = load i32* %arrayidx, align 4
35   %add = add nsw i32 %0, %C
36   %arrayidx2 = getelementptr inbounds i32* %A, i64 0
37
38 ; Store to a different location.
39   store i32 %add, i32* %arrayidx, align 4
40   %arrayidx4 = getelementptr inbounds i32* %B, i64 1
41   %1 = load i32* %arrayidx4, align 4
42   %add5 = add nsw i32 %1, %D
43   %cmp6 = icmp sgt i32 %add5, %C
44   br i1 %cmp6, label %if.then, label %ret.end
45
46 ; CHECK: @noifconvertstore1
47 ; CHECK-NOT: select
48 if.then:
49   store i32 %add5, i32* %arrayidx2, align 4
50   br label %ret.end
51
52 ret.end:
53   ret void
54 }
55
56 declare void @unknown_fun()
57
58 define void @noifconvertstore2(i32 %m, i32* %A, i32* %B, i32 %C, i32 %D) {
59 entry:
60   %arrayidx = getelementptr inbounds i32* %B, i64 0
61   %0 = load i32* %arrayidx, align 4
62   %add = add nsw i32 %0, %C
63   %arrayidx2 = getelementptr inbounds i32* %A, i64 0
64
65 ; First store to the location.
66   store i32 %add, i32* %arrayidx2, align 4
67   call void @unknown_fun()
68   %arrayidx4 = getelementptr inbounds i32* %B, i64 1
69   %1 = load i32* %arrayidx4, align 4
70   %add5 = add nsw i32 %1, %D
71   %cmp6 = icmp sgt i32 %add5, %C
72   br i1 %cmp6, label %if.then, label %ret.end
73
74 ; CHECK: @noifconvertstore2
75 ; CHECK-NOT: select
76 if.then:
77   store i32 %add5, i32* %arrayidx2, align 4
78   br label %ret.end
79
80 ret.end:
81   ret void
82 }
83
84 define void @noifconvertstore_volatile(i32 %m, i32* %A, i32* %B, i32 %C, i32 %D) {
85 entry:
86   %arrayidx = getelementptr inbounds i32* %B, i64 0
87   %0 = load i32* %arrayidx, align 4
88   %add = add nsw i32 %0, %C
89   %arrayidx2 = getelementptr inbounds i32* %A, i64 0
90
91 ; First store to the location.
92   store i32 %add, i32* %arrayidx2, align 4
93   %arrayidx4 = getelementptr inbounds i32* %B, i64 1
94   %1 = load i32* %arrayidx4, align 4
95   %add5 = add nsw i32 %1, %D
96   %cmp6 = icmp sgt i32 %add5, %C
97   br i1 %cmp6, label %if.then, label %ret.end
98
99 ; Make sure we don't speculate volatile stores.
100 ; CHECK: @noifconvertstore_volatile
101 ; CHECK-NOT: select
102 if.then:
103   store volatile i32 %add5, i32* %arrayidx2, align 4
104   br label %ret.end
105
106 ret.end:
107   ret void
108 }