hoist-md.ll
3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
; RUN: opt -S -gvn-hoist < %s | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define void @test1(i1 %b, i32* %x) {
entry:
br i1 %b, label %if.then, label %if.else
if.then: ; preds = %entry
store i32 2, i32* %x, align 4, !tbaa !1
br label %if.end
if.else: ; preds = %entry
store i32 2, i32* %x, align 4, !tbaa !5
br label %if.end
if.end: ; preds = %if.else, %if.then
ret void
}
; CHECK-LABEL: define void @test1(
; CHECK: store i32 2, i32* %x, align 4
; CHECK-NEXT: br i1 %b
define void @test2(i1 %b, i32* %x) {
entry:
br i1 %b, label %if.then, label %if.else
if.then: ; preds = %entry
%gep1 = getelementptr inbounds i32, i32* %x, i64 1
store i32 2, i32* %gep1, align 4, !tbaa !1
br label %if.end
if.else: ; preds = %entry
%gep2 = getelementptr inbounds i32, i32* %x, i64 1
store i32 2, i32* %gep2, align 4, !tbaa !5
br label %if.end
if.end: ; preds = %if.else, %if.then
ret void
}
; CHECK-LABEL: define void @test2(
; CHECK: %[[gep:.*]] = getelementptr inbounds i32, i32* %x, i64 1
; CHECK: store i32 2, i32* %[[gep]], align 4
; CHECK-NEXT: br i1 %b
define void @test3(i1 %b, i32* %x) {
entry:
br i1 %b, label %if.then, label %if.else
if.then: ; preds = %entry
%gep1 = getelementptr inbounds i32, i32* %x, i64 1
store i32 2, i32* %gep1, align 4, !tbaa !1
br label %if.end
if.else: ; preds = %entry
%gep2 = getelementptr i32, i32* %x, i64 1
store i32 2, i32* %gep2, align 4, !tbaa !5
br label %if.end
if.end: ; preds = %if.else, %if.then
ret void
}
; CHECK-LABEL: define void @test3(
; CHECK: %[[gep:.*]] = getelementptr i32, i32* %x, i64 1
; CHECK: store i32 2, i32* %[[gep]], align 4
; CHECK-NEXT: br i1 %b
!1 = !{!2, !2, i64 0}
!2 = !{!"int", !3, i64 0}
!3 = !{!"omnipotent char", !4, i64 0}
!4 = !{!"Simple C++ TBAA"}
!5 = !{!6, !6, i64 0}
!6 = !{!"_ZTS1e", !3, i64 0}
define i32 @test4(i1 %b, i32* %y) {
entry:
br i1 %b, label %if.then, label %if.end
if.then: ; preds = %entry
%0 = load i32, i32* %y, align 4, !range !7
br label %return
if.end: ; preds = %entry
%1 = load i32, i32* %y, align 4, !range !8
br label %return
return: ; preds = %if.end, %if.then
%retval.0 = phi i32 [ %0, %if.then ], [ %1, %if.end ]
ret i32 %retval.0
}
; CHECK-LABEL: define i32 @test4(
; CHECK: %[[load:.*]] = load i32, i32* %y, align 4, !range ![[range_md:.*]]
; CHECK: %[[phi:.*]] = phi i32 [ %[[load]], %{{.*}} ], [ %[[load]], %{{.*}} ]
; CHECK: ret i32 %[[phi]]
define i32* @test5(i1 %b, i32** %y) {
entry:
br i1 %b, label %if.then, label %if.end
if.then: ; preds = %entry
%0 = load i32*, i32** %y, align 4, !nonnull !9
br label %return
if.end: ; preds = %entry
%1 = load i32*, i32** %y, align 4
br label %return
return: ; preds = %if.end, %if.then
%retval.0 = phi i32* [ %0, %if.then ], [ %1, %if.end ]
ret i32* %retval.0
}
; CHECK-LABEL: define i32* @test5(
; CHECK: %[[load:.*]] = load i32*, i32** %y, align 4
; CHECK-NOT: !nonnull
; CHECK: %[[phi:.*]] = phi i32* [ %[[load]], %{{.*}} ], [ %[[load]], %{{.*}} ]
; CHECK: ret i32* %[[phi]]
!7 = !{i32 0, i32 2}
!8 = !{i32 3, i32 4}
!9 = !{}
; CHECK: ![[range_md]] = !{i32 0, i32 2, i32 3, i32 4}