1 ; RUN: opt %s -newgvn -S | FileCheck %s
2 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
3 target triple = "x86_64-unknown-linux-gnu"
5 define i8* @test1(i8** %v0, i8** %v1) {
8 ; CHECK-NEXT: [[V2:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]], align 8, !nonnull !0
9 ; CHECK-NEXT: store i8* [[V2]], i8** [[V1:%.*]]
10 ; CHECK-NEXT: ret i8* [[V2]]
13 %v2 = load i8*, i8** %v0, !nonnull !0
14 store i8* %v2, i8** %v1
15 %v3 = load i8*, i8** %v1
19 ; FIXME: could propagate nonnull to first load?
20 define i8* @test2(i8** %v0, i8** %v1) {
21 ; CHECK-LABEL: @test2(
23 ; CHECK-NEXT: [[V2:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]]
25 ; CHECK-NEXT: store i8* [[V2]], i8** [[V1:%.*]]
26 ; CHECK-NEXT: ret i8* [[V2]]
29 %v2 = load i8*, i8** %v0
30 store i8* %v2, i8** %v1
31 %v3 = load i8*, i8** %v1, !nonnull !0
35 declare void @use1(i8* %a) readonly
37 define i8* @test3(i8** %v0) {
38 ; CHECK-LABEL: @test3(
40 ; CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]]
42 ; CHECK-NEXT: call void @use1(i8* [[V1]])
43 ; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
45 ; CHECK-NEXT: ret i8* [[V1]]
47 ; CHECK-NEXT: ret i8* [[V1]]
50 %v1 = load i8*, i8** %v0
51 call void @use1(i8* %v1)
52 br i1 undef, label %bb1, label %bb2
55 %v2 = load i8*, i8** %v0, !nonnull !0
59 %v3 = load i8*, i8** %v0
63 define i8* @test4(i8** %v0) {
64 ; CHECK-LABEL: @test4(
66 ; CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]]
68 ; CHECK-NEXT: call void @use1(i8* [[V1]])
69 ; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
71 ; CHECK-NEXT: ret i8* [[V1]]
73 ; CHECK-NEXT: ret i8* [[V1]]
76 %v1 = load i8*, i8** %v0
77 call void @use1(i8* %v1)
78 br i1 undef, label %bb1, label %bb2
81 %v2 = load i8*, i8** %v0
85 %v3 = load i8*, i8** %v0, !nonnull !0
89 define i8* @test5(i8** %v0) {
90 ; CHECK-LABEL: @test5(
92 ; CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]], align 8, !nonnull !0
93 ; CHECK-NEXT: call void @use1(i8* [[V1]])
94 ; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
96 ; CHECK-NEXT: ret i8* [[V1]]
98 ; CHECK-NEXT: ret i8* [[V1]]
101 %v1 = load i8*, i8** %v0, !nonnull !0
102 call void @use1(i8* %v1)
103 br i1 undef, label %bb1, label %bb2
106 %v2 = load i8*, i8** %v0
110 %v3 = load i8*, i8** %v0
114 define i8* @test6(i8** %v0, i8** %v1) {
115 ; CHECK-LABEL: @test6(
117 ; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
119 ; CHECK-NEXT: [[V2:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]], align 8, !nonnull !0
120 ; CHECK-NEXT: store i8* [[V2]], i8** [[V1:%.*]]
121 ; CHECK-NEXT: ret i8* [[V2]]
123 ; CHECK-NEXT: [[V4:%.*]] = load i8*, i8** [[V0]]
124 ; CHECK-NOT: !nonnull
125 ; CHECK-NEXT: store i8* [[V4]], i8** [[V1]]
126 ; CHECK-NOT: !nonnull
127 ; CHECK-NEXT: ret i8* [[V4]]
130 br i1 undef, label %bb1, label %bb2
133 %v2 = load i8*, i8** %v0, !nonnull !0
134 store i8* %v2, i8** %v1
135 %v3 = load i8*, i8** %v1
139 %v4 = load i8*, i8** %v0
140 store i8* %v4, i8** %v1
141 %v5 = load i8*, i8** %v1, !nonnull !0
145 declare void @use2(i8* %a)
147 define i8* @test7(i8** %v0) {
148 ; CHECK-LABEL: @test7(
150 ; CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]], align 8, !nonnull !0
151 ; CHECK-NEXT: call void @use2(i8* [[V1]])
152 ; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
154 ; CHECK-NEXT: [[V2:%.*]] = load i8*, i8** [[V0]]
155 ; CHECK-NOT: !nonnull
156 ; CHECK-NEXT: ret i8* [[V2]]
158 ; CHECK-NEXT: [[V3:%.*]] = load i8*, i8** [[V0]]
159 ; CHECK-NOT: !nonnull
160 ; CHECK-NEXT: ret i8* [[V3]]
163 %v1 = load i8*, i8** %v0, !nonnull !0
164 call void @use2(i8* %v1)
165 br i1 undef, label %bb1, label %bb2
168 %v2 = load i8*, i8** %v0
172 %v3 = load i8*, i8** %v0